function byId(x) {
return document.getElementById(x);
}
function SimpleTable() {
var html = "
";
this.addRow = function(row) {
html += "
" +
row +
"
";
};
this.addPersonRow = function(person, row) {
this.addRow(
"
 + ")
" +
"
" + person.getDisplayName() + "
" +
"
" +
row +
"
"
);
};
this.getHtml = function() {
return html + "
";
};
}
function getSurface() {
return opensocial.getEnvironment().getSurface().getName();
}
var MyApp = {};
MyApp.render = function(data) {
Gadgets[gadgetToLoad](data);
}
function myInit() {
var mode = (gadgetToLoad == "profile") ? opensocial.DataRequest.PersonId.OWNER : opensocial.DataRequest.PersonId.VIEWER ;
SocialNorms.createSocialAppOnLoad(MyApp, mode, ["gifts"]);
}
myInit();
Gadgets = {};
Gadgets.hello = function(data) {
byId("main").innerHTML =
"Welcome, " + data.getViewer().getDisplayName();
}
Gadgets.friends = function(data) {
var html = "Welcome, " + data.getViewer().getDisplayName();
var table = new SimpleTable();
var friends = data.getViewerFriends().asArray();
for (var i=0; i