]> git.wh0rd.org - tt-rss.git/blobdiff - js/tt-rss.js
implement mail plugin using mailto: links; deprecate mail plugin
[tt-rss.git] / js / tt-rss.js
index 7462d933de3f1ee531a3b92a9a9dcf9d107314ec..a8552d17373e57b0cccfda5ae53951a86c002985 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) {
@@ -245,9 +244,11 @@ function init() {
                loading_set_progress(20);
 
                var hasAudio = !!((myAudioTag = document.createElement('audio')).canPlayType);
+               var hasSandbox = "sandbox" in document.createElement("iframe");
 
                new Ajax.Request("backend.php", {
-                       parameters: {op: "rpc", method: "sanityCheck", hasAudio: hasAudio},
+                       parameters: {op: "rpc", method: "sanityCheck", hasAudio: hasAudio,
+                               hasSandbox: hasSandbox},
                        onComplete: function(transport) {
                                        backend_sanity_check_callback(transport);
                                } });
@@ -284,6 +285,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
@@ -550,7 +558,7 @@ function hotkey_handler(e) {
                if (keycode == 16) return; // ignore lone shift
                if (keycode == 17) return; // ignore lone ctrl
 
-               if (!shift_key) keychar = keychar.toLowerCase();
+               keychar = keychar.toLowerCase();
 
                var hotkeys = getInitParam("hotkeys");
 
@@ -571,7 +579,11 @@ function hotkey_handler(e) {
                Element.hide(cmdline);
 
                var hotkey = keychar.search(/[a-zA-Z0-9]/) != -1 ? keychar : "(" + keycode + ")";
+
+               // ensure ^*char notation
+               if (shift_key) hotkey = "*" + hotkey;
                if (ctrl_key) hotkey = "^" + hotkey;
+
                hotkey = hotkey_prefix ? hotkey_prefix + " " + hotkey : hotkey;
                hotkey_prefix = false;
 
@@ -658,6 +670,8 @@ function hotkey_handler(e) {
                case "email_article":
                        if (typeof emailArticle != "undefined") {
                                emailArticle();
+                       } else if (typeof mailtoArticle != "undefined") {
+                               mailtoArticle();
                        } else {
                                alert(__("Please enable mail plugin first."));
                        }
@@ -769,6 +783,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);
@@ -870,8 +897,6 @@ function handle_rpc_json(transport, scheduled_call) {
                        if (runtime_info)
                                parse_runtime_info(runtime_info);
 
-                       hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
-
                        Element.hide(dijit.byId("net-alert").domNode);
 
                } else {
@@ -948,3 +973,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);
+       }
+}