Fix some absolutisms and zero-based bugs
authorChip Black <bytex64@bytex64.net>
Mon, 11 Apr 2011 00:47:19 +0000 (19:47 -0500)
committerChip Black <bytex64@bytex64.net>
Mon, 11 Apr 2011 00:47:19 +0000 (19:47 -0500)
www/index.html
www/js/blerg.js

index 49a9be3..4437546 100644 (file)
@@ -16,8 +16,8 @@
 
 <div id="header">
   <div id="siteid">
-    <img src="/images/blerglogo.png" class="logo" width="125" height="122">
-    <h1><a href="/">Blërg!</a></h1>
+    <img src="images/blerglogo.png" class="logo" width="125" height="122">
+    <h1><a href="#">Blërg!</a></h1>
     <h2><span name="section">Welcome</span></h2>
     <div id="usercontrols" style="display:none">
       <a href="#" name="user.reflink" onclick="return qlink()">[chatter]</a>
@@ -36,9 +36,9 @@
       Hello, <a href="#" id="userlink" onclick="return qlink()"></a>. <a href="#" onclick="loginStatus.logout(); return false">logout</a><br>
       <a href="#" onclick="postPopup(); return false">Write new entry</a><br>
       <a href="#" id="reflink" onclick="return qlink()">Chatter about me</a><br>
-      <a href="/#/feed" onclick="return qlink()">Stalk your victims</a>
+      <a href="#/feed" onclick="return qlink()">Stalk your victims</a>
     </div>
-    <div id="rss" style="display:none"><a id="rsslink" href=""><img src="/images/rss.png" width="16" height="16"> RSS</a></div>
+    <div id="rss" style="display:none"><a id="rsslink" href=""><img src="images/rss.png" width="16" height="16"> RSS</a></div>
   </div>
   <div style="clear:both"></div>
   <div id="post" style="display:none">
index d0135b8..ba1e39e 100644 (file)
@@ -3,15 +3,15 @@
  */
 
 // Config
-var baseURL = '';
+var baseURL = '/admin/blerg';
 var recordTemplate = new Template(
-    '<div class="record">#{data}<div class="info">Posted #{date}. <a href="/\##{author}/#{record}" onclick="return qlink()">[permalink]</a> <a href="#" onclick="postPopup(\'@#{author}/#{record}: \'); return false">[reply]</a></div></div>'
+    '<div class="record">#{data}<div class="info">Posted #{date}. <a href="' + baseURL + '/\##{author}/#{record}" onclick="return qlink()">[permalink]</a> <a href="#" onclick="postPopup(\'@#{author}/#{record}: \'); return false">[reply]</a></div></div>'
 );
 var tagRecordTemplate = new Template(
-    '<div class="record">#{data}<div class="info">Posted by <a class="author ref" href="/\##{author}" onclick="return qlink()">@#{author}</a> on #{date}. <a href="/\##{author}/#{record}" onclick="return qlink()">[permalink]</a> <a href="#" onclick="postPopup(\'@#{author}/#{record}: \'); return false">[reply]</a></div></div>'
+    '<div class="record">#{data}<div class="info">Posted by <a class="author ref" href="/\##{author}" onclick="return qlink()">@#{author}</a> on #{date}. <a href="' + baseURL + '/\##{author}/#{record}" onclick="return qlink()">[permalink]</a> <a href="#" onclick="postPopup(\'@#{author}/#{record}: \'); return false">[reply]</a></div></div>'
 );
 var latestRecordsTemplate = new Template(
-    '<div class="record"><a class="author ref" href="/\##{author}" onclick="return qlink()">@#{author}</a> #{data}</div>'
+    '<div class="record"><a class="author ref" href="' + baseURL + '/\##{author}" onclick="return qlink()">@#{author}</a> #{data}</div>'
 );
 
 // 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';