You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by ch...@apache.org on 2008/07/10 15:07:13 UTC
svn commit: r675563 -
/incubator/shindig/trunk/javascript/samplecontainer/examples/getFriendsHasApp.xml
Author: chabotc
Date: Thu Jul 10 06:07:13 2008
New Revision: 675563
URL: http://svn.apache.org/viewvc?rev=675563&view=rev
Log:
Added a simple example gadget to test & demo the HAS_APP filter
Added:
incubator/shindig/trunk/javascript/samplecontainer/examples/getFriendsHasApp.xml
Added: incubator/shindig/trunk/javascript/samplecontainer/examples/getFriendsHasApp.xml
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/samplecontainer/examples/getFriendsHasApp.xml?rev=675563&view=auto
==============================================================================
--- incubator/shindig/trunk/javascript/samplecontainer/examples/getFriendsHasApp.xml (added)
+++ incubator/shindig/trunk/javascript/samplecontainer/examples/getFriendsHasApp.xml Thu Jul 10 06:07:13 2008
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Module>
+ <ModulePrefs title="List Friends using HAS_APP filter Example">
+ <Require feature="opensocial-0.7"/>
+ </ModulePrefs>
+ <Content type="html">
+ <![CDATA[
+ <script type="text/javascript">
+
+ /**
+ * Request for friend information.
+ */
+ function getData() {
+ var req = opensocial.newDataRequest();
+
+ req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.OWNER), 'owner');
+ var params = {};
+ params[opensocial.DataRequest.PeopleRequestFields.MAX] = 50;
+ params[opensocial.DataRequest.PeopleRequestFields.FILTER] = opensocial.DataRequest.FilterType.HAS_APP;
+ params[opensocial.DataRequest.PeopleRequestFields.SORT_ORDER] = opensocial.DataRequest.SortOrder.NAME;
+ req.add(req.newFetchPeopleRequest(opensocial.DataRequest.Group.OWNER_FRIENDS, params), 'ownerFriends');
+ req.send(onLoadFriends);
+ };
+
+ /**
+ * Parses the response to the friend information request and generates
+ * html to list the friends along with their display name.
+ *
+ * @param {Object} dataResponse Friend information that was requested.
+ */
+ function onLoadFriends(dataResponse) {
+ var owner = dataResponse.get('owner').getData();
+ var html = 'Friends of ' + owner.getDisplayName();
+ html += ':<br><ul>';
+ var ownerFriends = dataResponse.get('ownerFriends').getData();
+ ownerFriends.each(function(person) {
+ html += '<li>' + person.getDisplayName() + '</li>';
+ });
+ html += '</ul>';
+ document.getElementById('message').innerHTML = html;
+ };
+
+ gadgets.util.registerOnLoadHandler(getData);
+ </script>
+ <div id="message"> </div>
+ ]]>
+ </Content>
+</Module>