X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=www%2Fjssrc%2Fblerg%2FUser.js;fp=www%2Fjssrc%2Fblerg%2FUser.js;h=ca0916a3c4f984c7d4584e7562725b5e6ff23713;hb=9818631aecddd827374a0c01b3ec287e7b018bb1;hp=0000000000000000000000000000000000000000;hpb=8f3918fbe3d812782d70af32b0d122bcd16a4c65;p=blerg.git diff --git a/www/jssrc/blerg/User.js b/www/jssrc/blerg/User.js new file mode 100644 index 0000000..ca0916a --- /dev/null +++ b/www/jssrc/blerg/User.js @@ -0,0 +1,54 @@ +enyo.kind({ + name: "blerg.User", + kind: "blerg.Pager", + listKind: "blerg.Record", + published: { + username: "", + permalink: false, + firstRecord: null, + }, + statics: { + locationDetect: function(l) { + var m = l.hash.match(/^#([A-Za-z0-9_-]+)(?:\/(p)?(\d+))?$/); + if (m) { + return { + kind: "blerg.User", + username: m[1], + permalink: m[2] != 'p', + firstRecord: parseInt(m[3]) + }; + } + } + }, + create: function() { + this.inherited(arguments); + this.usernameChanged(); + }, + usernameChanged: function() { + this.bubble('onSetTitle', {section: '@' + this.username}); + this.$.records.destroyComponents(); + this.lastRecord = null; + this.loadMore(); + }, + loadItems: function(from, to) { + this.inherited(arguments); + + var url; + if (from != undefined && to != undefined) { + url = baseURL + '/get/' + this.username + '/' + from + '-' + to; + } else { + url = baseURL + '/get/' + this.username; + } + + var req = new enyo.Ajax({ + url: url + }); + req.response(function(inSender, inResponse) { + for (var i = 0; i < inResponse.length; i++) { + inResponse[i].author = this.username; + } + this.addItems(inResponse); + }.bind(this)); + req.go(); + } +});