-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReadActivity.xml
37 lines (32 loc) · 1.07 KB
/
ReadActivity.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="Read Activities - v0.8" >
<Require feature="opensocial-0.8"/>
</ModulePrefs>
<Content type="html">
<![CDATA[
<div id="content_div"></div>
<script type="text/javascript">
var div = document.getElementById('content_div');
/**
* Create the new activity and send it to the server.
*/
function getData() {
var req = opensocial.newDataRequest();
var viewer = opensocial.newIdSpec({'userId' : 'VIEWER'});
req.add(req.newFetchActivitiesRequest(viewer), 'activities');
req.send(onLoadActivities);
};
function onLoadActivities(dataResponse) {
var data = dataResponse.get('activities').getData();
var activities = data.asArray();
for (var i = 0; i < activities.length; i++) {
alert(activities[i].getField(opensocial.Activity.Field.TITLE) + " at " + activities[i].getField(opensocial.Activity.Field.POSTED_TIME));
}
};
//Call getData as soon as the gadget finishes loading.
gadgets.util.registerOnLoadHandler(getData);
</script>
]]>
</Content>
</Module>