]> git.wh0rd.org - tt-rss.git/blobdiff - js/tt-rss.js
assign hash-stored feed_id/is_cat earlier on startup
[tt-rss.git] / js / tt-rss.js
index 264650c840e1658c3a5671f1d0681e03733b603b..054ccf3df992c481a36f2cd56a34e93ebaebbd95 100644 (file)
@@ -1,10 +1,10 @@
 var global_unread = -1;
-var _active_feed_id = undefined;
-var _active_feed_is_cat = false;
 var hotkey_prefix = false;
 var hotkey_prefix_pressed = false;
 var _widescreen_mode = false;
 var _rpc_seq = 0;
+var _active_feed_id = 0;
+var _active_feed_is_cat = false;
 
 function next_seq() {
        _rpc_seq += 1;
@@ -21,7 +21,6 @@ function activeFeedIsCat() {
 
 function getActiveFeedId() {
        try {
-               //console.log("gAFID: " + _active_feed_id);
                return _active_feed_id;
        } catch (e) {
                exception_error("getActiveFeedId", e);
@@ -30,11 +29,11 @@ function getActiveFeedId() {
 
 function setActiveFeedId(id, is_cat) {
        try {
-               _active_feed_id = id;
+               hash_set('f', id);
+               hash_set('c', is_cat ? 1 : 0);
 
-               if (is_cat != undefined) {
-                       _active_feed_is_cat = is_cat;
-               }
+               _active_feed_id = id;
+               _active_feed_is_cat = is_cat;
 
                selectFeed(id, is_cat);
        } catch (e) {
@@ -69,25 +68,7 @@ function updateFeedList() {
                });
 
                var tree = new fox.FeedTree({
-               persist: false,
                model: treeModel,
-               onOpen: function (item, node) {
-                       var id = String(item.id);
-                       var cat_id = id.substr(id.indexOf(":")+1);
-
-                       new Ajax.Request("backend.php",
-                               { parameters: "backend.php?op=feeds&method=collapse&cid=" +
-                                       param_escape(cat_id) + "&mode=0" } );
-          },
-               onClose: function (item, node) {
-                       var id = String(item.id);
-                       var cat_id = id.substr(id.indexOf(":")+1);
-
-                       new Ajax.Request("backend.php",
-                               { parameters: "backend.php?op=feeds&method=collapse&cid=" +
-                                       param_escape(cat_id) + "&mode=1" } );
-
-          },
                onClick: function (item, node) {
                        var id = String(item.id);
                        var is_cat = id.match("^CAT:");
@@ -119,8 +100,6 @@ function updateFeedList() {
                dojo.disconnect(tmph);
                        Element.hide("feedlistLoading");
 
-                       tree.collapseHiddenCats();
-
                        feedlist_init();
 
 //                     var node = dijit.byId("feedTree")._itemNodesMap['FEED:-2'][0].domNode
@@ -304,6 +283,13 @@ function init_second_stage() {
 
                feeds_sort_by_unread = getInitParam("feeds_sort_by_unread") == 1;
 
+               var hash_feed_id = hash_get('f');
+               var hash_feed_is_cat = hash_get('c') == "1";
+
+               if (hash_feed_id != undefined) {
+                       setActiveFeedId(hash_feed_id, hash_feed_is_cat);
+               }
+
                loading_set_progress(30);
 
                // can't use cache_clear() here because viewfeed might not have initialized yet
@@ -624,6 +610,12 @@ function hotkey_handler(e) {
                case "prev_article":
                        moveToPost('prev');
                        return false;
+               case "next_article_noscroll":
+                       moveToPost('next', true);
+                       return false;
+               case "prev_article_noscroll":
+                       moveToPost('prev', true);
+                       return false;
                case "search_dialog":
                        search();
                        return ;
@@ -926,7 +918,7 @@ function switchPanelMode(wide) {
                        dijit.byId("content-insert").domNode.setStyle({width: 'auto',
                                height: '50%',
                                borderLeftWidth: '0px',
-                               borderTopWidthidth: '1px'});
+                               borderTopWidth: '1px'});
 
                        $("headlines-toolbar").setStyle({ borderBottomWidth: '1px' });
                }
@@ -962,3 +954,21 @@ function update_random_feed() {
                exception_error("update_random_feed", e);
        }
 }
+
+function hash_get(key) {
+       try {
+               kv = window.location.hash.substring(1).toQueryParams();
+               return kv[key];
+       } catch (e) {
+               exception_error("hash_set", e);
+       }
+}
+function hash_set(key, value) {
+       try {
+               kv = window.location.hash.substring(1).toQueryParams();
+               kv[key] = value;
+               window.location.hash = $H(kv).toQueryString();
+       } catch (e) {
+               exception_error("hash_set", e);
+       }
+}