//
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 + "
";
};
}
var MyApp = function() {};
MyApp.render = function(data) {
this.data = data;
byId("main").innerHTML = "testing";
}
function getSurface() {
return document.location.toString().match(/mode=canvas/) ? "canvas" : "profile";
}
function myInit() {
var mode = (getSurface() == "canvas") ? "VIEWER" : "OWNER";
if (1) {
SocialNorms.createSocialAppOnLoad({
render: function(data) {
Gadgets[gadgetToLoad](data);
},
}, 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