]> 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 9814718f09aeef03857beb0de98322ea9032fceb..5d6e1d81ec5399dccb4f289af4ad0dea035d36a9 100644 (file)
@@ -3,6 +3,8 @@ 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;
@@ -14,12 +16,12 @@ function get_seq() {
 }
 
 function activeFeedIsCat() {
-       return hash_get('c') == "1";
+       return _active_feed_is_cat;
 }
 
 function getActiveFeedId() {
        try {
-               return hash_get('f');
+               return _active_feed_id;
        } catch (e) {
                exception_error("getActiveFeedId", e);
        }
@@ -30,6 +32,9 @@ function setActiveFeedId(id, is_cat) {
                hash_set('f', id);
                hash_set('c', is_cat ? 1 : 0);
 
+               _active_feed_id = id;
+               _active_feed_is_cat = is_cat;
+
                selectFeed(id, is_cat);
        } catch (e) {
                exception_error("setActiveFeedId", e);
@@ -173,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 + ")";
@@ -278,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
@@ -763,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);