]> git.wh0rd.org Git - tt-rss.git/commitdiff
check for stuck hotkey prefixe sequences and abort them
authorAndrew Dolgov <fox@bah.org.ru>
Tue, 6 Oct 2009 11:04:46 +0000 (15:04 +0400)
committerAndrew Dolgov <fox@bah.org.ru>
Tue, 6 Oct 2009 11:04:46 +0000 (15:04 +0400)
feedlist.js
tt-rss.js

index 7de5559b5ec7779642a5c532e9b7b76b7ec0a1b5..7a7869bbf457012cacf66f4314b188f65b9cb695 100644 (file)
@@ -454,6 +454,8 @@ function feedlist_init() {
 
                if (!offline_mode) setTimeout("timeout()", 1);
 
+               setTimeout("hotkey_prefix_timeout()", 5*1000);
+
                if (typeof correctPNG != 'undefined') {
                        correctPNG();
                }
index e5bcbf595144930c492d01e429db70b3085e4bc1..c185ea37cbe83f3290486d9075578453cc302c1e 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -15,6 +15,7 @@ var number_of_feeds = 0;
 var sanity_check_done = false;
 var _hfd_scrolltop = 0;
 var hotkey_prefix = false;
+var hotkey_prefix_pressed = false;
 var init_params = new Object();
 var ver_offset = 0;
 var hor_offset = 0;
@@ -313,6 +314,25 @@ function viewfeed(feed, subop) {
        f.viewfeed(feed, subop);
 }
 
+function hotkey_prefix_timeout() {
+       try {
+
+               var date = new Date();
+               var ts = Math.round(date.getTime() / 1000);
+
+               if (hotkey_prefix_pressed && ts - hotkey_prefix_pressed >= 5) {
+                       debug("hotkey_prefix seems to be stuck, aborting");
+                       hotkey_prefix_pressed = false;
+                       hotkey_prefix = false;
+               }
+
+               setTimeout("hotkey_prefix_timeout()", 10);
+
+       } catch  (e) {
+               exception_error("hotkey_prefix_timeout", e);
+       }
+}
+
 function timeout() {
        if (getInitParam("bw_limit") == "1") return;
 
@@ -1072,8 +1092,12 @@ function hotkey_handler(e) {
                if ((keycode == 70 || keycode == 67 || keycode == 71) 
                                && !hotkey_prefix) {
 
+                       var date = new Date();
+                       var ts = Math.round(date.getTime() / 1000);
+
                        hotkey_prefix = keycode;
-                       debug("KP: PREFIX=" + keycode + " CHAR=" + keychar);
+                       hotkey_prefix_pressed = ts;
+                       debug("KP: PREFIX=" + keycode + " CHAR=" + keychar + " TS=" + ts);
                        return true;
                }