X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=www%2Fjs%2Fblerg.js;h=ba1e39e35464480d366060fe1b19cd6fa722df7f;hb=e396ecb2bf773e4df131b6edf769ca69868575bd;hp=d0135b8abda05ff5591979b11c02b0253946704e;hpb=e3f8f23d96899146464a0b3ced1eb0833bcd634f;p=blerg.git diff --git a/www/js/blerg.js b/www/js/blerg.js index d0135b8..ba1e39e 100644 --- a/www/js/blerg.js +++ b/www/js/blerg.js @@ -3,15 +3,15 @@ */ // Config -var baseURL = ''; +var baseURL = '/admin/blerg'; var recordTemplate = new Template( - '
#{data}
Posted #{date}. [permalink] [reply]
' + '
#{data}
Posted #{date}. [permalink] [reply]
' ); var tagRecordTemplate = new Template( - '
#{data}
Posted by @#{author} on #{date}. [permalink] [reply]
' + '
#{data}
Posted by @#{author} on #{date}. [permalink] [reply]
' ); var latestRecordsTemplate = new Template( - '
@#{author} #{data}
' + '
@#{author} #{data}
' ); // Page elements @@ -80,9 +80,9 @@ LoginStatus.prototype.logout = function() { LoginStatus.prototype.update = function() { if (this.loggedIn) { - $('userlink').href = '/#' + this.username; + $('userlink').href = baseURL + '/#' + this.username; $('userlink').update('@' + this.username); - $('reflink').href = '/#/ref/' + this.username; + $('reflink').href = baseURL + '/#/ref/' + this.username; $('login').hide(); $('logout').show(); } else { @@ -180,14 +180,14 @@ Pager.prototype.displayItems = function() { } if (this.pageStart < this.itemCount - 1) { - $('newer_link').href = '/#' + this.baseFrag + '/p' + (this.pageStart + this.itemsPerPage); + $('newer_link').href = baseURL + '/#' + this.baseFrag + '/p' + (this.pageStart + this.itemsPerPage); $('newer_link').show(); } else { $('newer_link').hide(); } if (this.pageStart >= 10) { - $('older_link').href = '/#' + this.baseFrag + '/p' + (this.pageStart - this.itemsPerPage); + $('older_link').href = baseURL + '/#' + this.baseFrag + '/p' + (this.pageStart - this.itemsPerPage); $('older_link').show(); } else { $('older_link').hide(); @@ -253,13 +253,13 @@ User.prototype.show = function() { $('rss').show(); $('rsslink').href = '/rss/' + this.username; $$('[name=user.reflink]').each(function(e) { - e.href = '/#/ref/' + this.username; + e.href = baseURL + '/#/ref/' + this.username; }.bind(this)); $('usercontrols').show(); - if (this.permalink && this.pageStart) { + if (this.permalink && this.pageStart >= 0) { this.showRecord(this.pageStart); - } else if (this.pageStart) { + } else if (this.pageStart >= 0) { this.showPageAt(this.pageStart); } else { this.reload(); @@ -311,6 +311,9 @@ User.prototype.reload = function() { } User.prototype.loadItems = function(from, to, continuation) { + if (to < 0) + return; + var url; if (from != undefined && to != undefined) { url = baseURL + '/get/' + this.username + '/' + from + '-' + to; @@ -719,12 +722,13 @@ function stopTicker() { function loadLatest() { new Ajax.Request(baseURL + '/latest.json', { + method: 'GET', onSuccess: function(r) { var j = r.responseText.evalJSON(); $('latest-tags').update(); j.tags.each(function(v) { - var a = new Element('a', {href: '/#/tag/' + v}); + var a = new Element('a', {href: baseURL + '/#/tag/' + v}); a.insert('#' + v); a.onclick = "return qlink()"; a.className = 'ref';