Guest User

Untitled

a guest
Jun 25th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <Module>
  3. <ModulePrefs title="Gifts part 1 - Friends">
  4. <Require feature="opensocial-0.8"/>
  5. <Require feature="dynamic-height" />
  6. </ModulePrefs>
  7. <Content type="html">
  8. <![CDATA[
  9. <script type="text/javascript">
  10. function loadFriends() {
  11. var req = opensocial.newDataRequest();
  12. req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER), 'viewer');
  13.  
  14. var viewerFriends = opensocial.newIdSpec({ "userId" : "VIEWER", "groupId" : "FRIENDS" });
  15. var opt_params = {};
  16. opt_params[opensocial.DataRequest.PeopleRequestFields.MAX] = 100;
  17. req.add(req.newFetchPeopleRequest(viewerFriends, opt_params), 'viewerFriends');
  18.  
  19. req.send(onLoadFriends);
  20. }
  21.  
  22. function onLoadFriends(data) {
  23. var viewer = data.get('viewer').getData();
  24. var viewerFriends = data.get('viewerFriends').getData();
  25.  
  26. html = new Array();
  27. html.push('<ul>');
  28. viewerFriends.each(function(person) {
  29. if (person.getId()) {
  30. html.push('<li>', person.getDisplayName(), '</li>');
  31. }
  32. });
  33. html.push('</ul>');
  34. document.getElementById('friends').innerHTML = html.join('');
  35. gadgets.window.adjustHeight();
  36. }
  37.  
  38. function init() {
  39. loadFriends();
  40. }
  41.  
  42. gadgets.util.registerOnLoadHandler(init);
  43. </script>
  44. <div id='main'>
  45. Your friends:
  46. <div id='friends'></div>
  47. </div>
  48. ]]>
  49. </Content>
  50. </Module>
Add Comment
Please, Sign In to add comment