]> git.wh0rd.org - tt-rss.git/blobdiff - js/tt-rss.js
Feature #446 - Allow customizing page title
[tt-rss.git] / js / tt-rss.js
index 264650c840e1658c3a5671f1d0681e03733b603b..5d6e1d81ec5399dccb4f289af4ad0dea035d36a9 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
@@ -199,7 +178,11 @@ function search() {
 }
 
 function updateTitle() {
-       var tmp = "Tiny Tiny RSS";
+       var tmp = document.title; 
+    if (tmp.indexOf('(')>0)
+    {
+       tmp = tmp.substr(0,tmp.lastIndexOf('('));
+    }
 
        if (global_unread > 0) {
                tmp = tmp + " (" + global_unread + ")";
@@ -304,6 +287,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 +614,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 ;
@@ -783,6 +779,19 @@ function hotkey_handler(e) {
                        return false;
                case "help_dialog":
                        helpDialog("main");
+                       return false;
+               case "toggle_combined_mode":
+                       notify_progress("Loading, please wait...");
+
+                       var value = isCdmMode() ? "false" : "true";
+                       var query = "?op=rpc&method=setpref&key=COMBINED_DISPLAY_MODE&value=" + value;
+
+                       new Ajax.Request("backend.php", {
+                               parameters: query,
+                               onComplete: function(transport) {
+                                       window.location.reload();
+                               } });
+
                        return false;
                default:
                        console.log("unhandled action: " + hotkey_action + "; hotkey: " + hotkey);
@@ -926,7 +935,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 +971,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);
+       }
+}