/** * Wrapper function for navigateTo */ function goToView(dest) { var supported_views = gadgets.views.getSupportedViews(); gadgets.views.requestNavigateTo(supported_views[dest]); }; /** * When called, this method post an activity to the Updates gadget */ function postActivity() { var params = {}; params[opensocial.Activity.Field.TITLE] = "I posted something interesting..."; var activity = opensocial.newActivity(params); opensocial.requestCreateActivity(activity, opensocial.CreateActivityPriority.HIGH, callback); }; function callback() { alert ("activity posted"); }; /** * When called, this method calls opensocial apis to get viewer's friendlist */ function loadFriends() { var req = opensocial.newDataRequest(); req.add(req.newFetchPersonRequest('VIEWER'), 'viewer'); req.add(req.newFetchPeopleRequest('VIEWER_FRIENDS'), 'viewerFriends'); req.send(printFriendsList); }; /** * When called, this method pushes the friends list into the gadget UI */ function printFriendsList(data) { var viewerFriends = data.get('viewerFriends').getData(); html = new Array(); html.push(''); document.getElementById('friends').innerHTML = html.join(''); }; /** * When called, this method initializes the gadget on load */ function init() { loadFriends(); };