X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;ds=sidebyside;f=www%2Fjs%2Fblerg.js;h=944f112634cbe70f12e81cce6e824ca0d53cc75c;hb=3f2f34bd763a1f3e1da52a0ca0e66ca4daacc1ca;hp=d227a7a0e5f24f875ec7acf2b697d201f8d3fe8a;hpb=d4ad5c4cff7183fdbac1c47f3ab0fa1db204397b;p=blerg.git diff --git a/www/js/blerg.js b/www/js/blerg.js index d227a7a..944f112 100644 --- a/www/js/blerg.js +++ b/www/js/blerg.js @@ -8,7 +8,7 @@ var recordTemplate = new Template( '
#{data}
Posted #{date}. [permalink]
' ); var tagRecordTemplate = new Template( - '
#{data}
Posted by @#{author} on #{date}
' + '
#{data}
Posted by @#{author} on #{date}. [permalink]
' ); var latestRecordsTemplate = new Template( '
@#{author} #{data}
' @@ -209,18 +209,38 @@ Pager.prototype.showRecord = function(r) { } } +Pager.prototype.loadItems = function(from, to, continuation) { } + // Object to render user pages function User(username) { this.initPager(); this.username = username; this.baseFrag = username; +} +User.prototype = new Pager(); +User.prototype.constructor = User; + +User.prototype.show = function() { + $$('[name=section]').each(function(v) { v.update(' @' + this.username) }.bind(this)); + $('welcome').hide(); + items.show(); + $('rss').show(); + $('rsslink').href = '/rss/' + this.username; + $$('[name=user.reflink]').each(function(e) { + e.href = '/#/ref/' + this.username; + }.bind(this)); + $('usercontrols').show(); +} + +User.prototype.reload = function() { + this.pageStart = null; $$('[name=user.subscribelink]').each(Element.hide); $$('[name=user.unsubscribelink]').each(Element.hide); if (loginStatus.loggedIn) { - new Ajax.Request(baseURL + '/feedinfo/' + username, { + new Ajax.Request(baseURL + '/feedinfo/' + this.username, { method: 'post', parameters: { username: loginStatus.username @@ -238,7 +258,7 @@ function User(username) { }); } - new Ajax.Request(baseURL + '/info/' + username, { + new Ajax.Request(baseURL + '/info/' + this.username, { method: 'get', onSuccess: function(r) { var j = r.responseText.evalJSON(); @@ -250,20 +270,6 @@ function User(username) { }.bind(this) }); } -User.prototype = new Pager(); -User.prototype.constructor = User; - -User.prototype.show = function() { - $$('[name=section]').each(function(v) { v.update(' @' + this.username) }.bind(this)); - $('welcome').hide(); - items.show(); - $('rss').show(); - $('rsslink').href = '/rss/' + this.username; - $$('[name=user.reflink]').each(function(e) { - e.href = '/#/ref/' + this.username; - }.bind(this)); - $('usercontrols').show(); -} User.prototype.loadItems = function(from, to, continuation) { var url; @@ -344,9 +350,6 @@ function mangleRecord(record, template) { l = l.replace(/([^\w\\]|^)\*\*(\w[^*]*)\*\*(\W|$)/g, '$1$2$3'); l = l.replace(/([^\w\\]|^)\*(\w[^*]*)\*(\W|$)/g, '$1$2$3'); - // Remove backslashes from escaped metachars - l = l.replace(/\\([*\[\]])/g, '$1'); - // Turn refs and tags into links l = l.replace(/(\s|^)#([A-Za-z0-9_-]+)/g, '$1#$2'); l = l.replace(/(\s|^)@([A-Za-z0-9_-]+)/g, '$1@$2'); @@ -374,6 +377,9 @@ function mangleRecord(record, template) { } } + // Remove backslashes from escaped metachars + l = l.replace(/\\([*\[\]@#])/g, '$1'); + out.push(l); if (endpush) { out.push(endpush); @@ -714,6 +720,8 @@ function hashSwitch() { if (m[3]) { var r = parseInt(m[3]); currentPager.showPageAt(r); + } else { + currentPager.showPageAt(currentPager.itemCount - 1); } } else if (m = location.hash.match(/^#\/feed(?:\/p(\d+))?$/)) { if (loginStatus.loggedIn) { @@ -723,6 +731,8 @@ function hashSwitch() { if (m[3]) { var r = parseInt(m[3]); currentPager.showPageAt(r); + } else { + currentPager.showPageAt(currentPager.itemCount - 1); } } else { location.href = baseURL; @@ -740,8 +750,9 @@ function hashSwitch() { } else { currentPager.showRecord(r); } + } else { + currentPager.reload(); } - // Do nothing otherwise, the User constructor takes care of it } else { $$('[name=section]').each(function(v) { v.update('Welcome') }); $('signup').hide();