Check the type of the current pager when hash switching
authorChip Black <bytex64@bytex64.net>
Wed, 2 Mar 2011 11:02:11 +0000 (03:02 -0800)
committerChip Black <bytex64@bytex64.net>
Wed, 2 Mar 2011 11:02:11 +0000 (03:02 -0800)
www/js/blerg.js

index 713f5f1..25f1e94 100644 (file)
@@ -692,7 +692,7 @@ function hashSwitch() {
         $('post').show();
         $('post.content').value = '[' + decodeURIComponent(m[1]).replace(']','').replace('[','') + '](' + decodeURIComponent(m[2]) + ')';
     } else if (m = location.hash.match(/^#\/(ref|tag)\/([A-Za-z0-9_-]+)(?:\/p(\d+))?$/)) {
-        if (!currentPager || currentPager.type != m[1] || currentPager.tag != m[2])
+        if (!currentPager || !(currentPager instanceof Tag) || currentPager.type != m[1] || currentPager.tag != m[2])
             currentPager = new Tag(m[1], m[2]);
         currentPager.show();
 
@@ -702,7 +702,7 @@ function hashSwitch() {
         }
     } else if (m = location.hash.match(/^#\/feed(?:\/p(\d+))?$/)) {
         if (loginStatus.loggedIn) {
-            if (!currentPager || currentPager.username != loginStatus.username)
+            if (!currentPager || !(currentPager instanceof Feed) || currentPager.username != loginStatus.username)
                 currentPager = new Feed();
             currentPager.show();
             if (m[3]) {
@@ -713,7 +713,7 @@ function hashSwitch() {
             location.href = baseURL;
         }
     } else if (m = location.hash.match(/^#([A-Za-z0-9_-]+)(?:\/(p)?(\d+))?$/)) {
-        if (!currentPager || currentPager.username != m[1])
+        if (!currentPager || !(currentPager instanceof User) || currentPager.username != m[1])
             currentPager = new User(m[1]);
         currentPager.show();
         loginStatus.update();