Fix page loading scheme; fix User switching
[blerg.git] / www / jssrc / blerg / User.js
index ca0916a..b977fa0 100644 (file)
@@ -5,17 +5,17 @@ enyo.kind({
        published: {
                username: "",
                permalink: false,
-               firstRecord: null,
+               record: null,
        },
        statics: {
                locationDetect: function(l) {
-                       var m = l.hash.match(/^#([A-Za-z0-9_-]+)(?:\/(p)?(\d+))?$/);
+                       var m = l.hash.match(/^#([A-Za-z0-9_-]+)(?:\/(\d+))?$/);
                        if (m) {
                                return {
                                        kind: "blerg.User",
                                        username: m[1],
-                                       permalink: m[2] != 'p',
-                                       firstRecord: parseInt(m[3])
+                                       permalink: m[2] != undefined,
+                                       record: parseInt(m[2])
                                };
                        }
                }
@@ -28,7 +28,12 @@ enyo.kind({
                this.bubble('onSetTitle', {section: '@' + this.username});
                this.$.records.destroyComponents();
                this.lastRecord = null;
-               this.loadMore();
+               this.$.loadMoreButton.hide();
+               if (this.permalink) {
+                       this.loadItems(this.record, this.record);
+               } else {
+                       this.loadMore();
+               }
        },
        loadItems: function(from, to) {
                this.inherited(arguments);
@@ -44,9 +49,16 @@ enyo.kind({
                        url: url
                });
                req.response(function(inSender, inResponse) {
+                       if (this.permalink) {
+                               this.$.loadMoreButton.hide();
+                       } else {
+                               this.$.loadMoreButton.show();
+                       }
+
                        for (var i = 0; i < inResponse.length; i++) {
                                inResponse[i].author = this.username;
                        }
+
                        this.addItems(inResponse);
                }.bind(this));
                req.go();