commit:2cd5a96d3ce0f362cf7d0951d3affccef1a794a5
author:Chip Black
committer:Chip Black
date:Wed Mar 2 03:02:11 2011 -0800
parents:c75a75b8c56f80e9364fcbe0b88a2b432f15bc75
Check the type of the current pager when hash switching
diff --git a/www/js/blerg.js b/www/js/blerg.js
line changes: +3/-3
index 713f5f1..25f1e94
--- a/www/js/blerg.js
+++ b/www/js/blerg.js
@@ -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();