google.friendconnect.container.initOpenSocialApi({
site: '11495691767188717914',
onload: function(securityToken) { initAllData(); }
}
);
function initAllData() {
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest("VIEWER"), "viewer_data");
req.send(onData);
}
function onData(data) {
var viewer_info = document.getElementById("viewer-info");
if (data.get("viewer_data").hadError()) {
document.getElementById('gfc-button').style.display="inline";
//google.friendconnect.renderSignInButton({'id': 'gfc-button' });
} else {
var viewer = data.get("viewer_data").getData();
document.getElementById('gfc-button').style.display="none";
viewer_info.innerHTML = "Hello, " + viewer.getDisplayName() + " " +
"Settings | " +
"Invite | " +
"Sign out";
redirectToSpecial(window.location);
}
}
function redirectToSpecial(location) {
// Check for our #_special_login_ tag
// at the end of the url. if it is there, redirect to the give path
// sadly, this path i don't think can contain url params.
// use cookies instead.
// convert location to a string
location = location + '';
var split_location = location.split('#');
if (split_location.length == 2) {
location = split_location[1];
if (location.search("^_special_login_.*") == 0) {
// this is our special login key..redirecto to the
// url encoded path.
var new_location = location.slice(15);
window.location = new_location;
}
}
}