This gadget requires a feature that is not available in your locale at this time. Please check back at a later date. (note: canvas view is unavailable)

]]>
var hasSocial = false; var hasViewer = false; var hasACL = false; function init() { checkPermissions(); } function checkPermissions() { var u = gadgets.util; if (u.hasFeature('opensocial-0.8')) { hasSocial = true; var req = opensocial.newDataRequest(); var spec = opensocial.newIdSpec({'userId' : 'VIEWER', 'groupId' : 'FRIENDS'}); req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER), 'viewer'); req.add(req.newFetchPeopleRequest(spec), 'friends'); req.send(function(data) { var viewer = data.get('viewer'); if (viewer.hadError()) { if (viewer.getErrorCode() == 'forbidden' || viewer.getErrorCode() == '403') { // user needs to approve social data access doACLMessage(); } else { doGenericError(); } } else if (viewer.getData().getId() == -1) { // user needs to log in doLoginMessage(); } else { hasACL = true; // do social things doSocial(data); } }); } else { // user is on non-social domain doNonSocialMessage(); } } function doACLMessage() { document.getElementById('status').innerHTML = 'This gadget lets you share and collaborate with friends on iGoogle. Please adjust the gadgets settings to use these features.'; } function doLoginMessage() { document.getElementById('status').innerHTML = 'This gadget cannot access the information it needs so that you can share or collaborate with friends. Please sign in to enable access.'; } function doNonSocialMessage() { document.getElementById('status').innerHTML = 'This gadget requires a feature that is not available in your locale at this time. Please check back at a later date. (note: social is unavailable)'; } function doGenericError() { document.getElementById('status').innerHTML = 'An unexpected error occurred.'; } function doSocial(data) { document.getElementById('appdata_status').style.display = 'block'; document.getElementById('invite_status').style.display = 'block'; var viewer = data.get('viewer'); document.getElementById('viewer').innerHTML = viewer.getData().getDisplayName(); var friends = data.get('friends'); var html = [''); document.getElementById('friends').innerHTML = html.join(''); gadgets.window.adjustHeight(); } function gotoCanvas() { gadgets.views.requestNavigateTo('canvas'); } function gotoHome() { gadgets.views.requestNavigateTo('home'); } function inviteFriends() { var params = []; params[opensocial.Message.Field.TITLE] = 'Invitation'; var message = opensocial.newMessage('invitation', params); opensocial.requestShareApp(null, message, function (data) { if (data.hadError()) { document.getElementById('invite_response').innerHTML = data.getErrorCode(); } else { document.getElementById('invite_response').innerHTML = 'Invited friends'; console.log(data); } }); } function setAppdata() { var req = opensocial.newDataRequest(); req.add(req.newUpdatePersonAppDataRequest(opensocial.IdSpec.PersonId.VIEWER, 'token', 'test')); req.send(function (data) { document.getElementById('appdata').innerHTML = 'Appdata set: test'; }); } function retrieveAppdata() { var req = opensocial.newDataRequest(); req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER), 'viewer'); var spec = opensocial.newIdSpec({'userId':'VIEWER', 'groupId':'SELF'}); req.add(req.newFetchPersonAppDataRequest(spec, '*'), 'data'); req.send(function (data) { if (data.hadError()) { document.getElementById('appdata').innerHTML = data.getErrorCode(); } else { var viewer = data.get('viewer').getData(); document.getElementById('appdata').innerHTML = 'Appdata retrieved: ' + data.get('data').getData()[viewer.getId()]['token']; } }); } _IG_RegisterOnloadHandler(init);
Viewer:
Friends:



Navigate to home, canvas
]]>