From 164469f902b1bc0be328e0ecdab555a891e94c05 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 6 Oct 2009 15:04:46 +0400 Subject: [PATCH] check for stuck hotkey prefixe sequences and abort them --- feedlist.js | 2 ++ tt-rss.js | 26 +++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/feedlist.js b/feedlist.js index 7de5559b..7a7869bb 100644 --- a/feedlist.js +++ b/feedlist.js @@ -454,6 +454,8 @@ function feedlist_init() { if (!offline_mode) setTimeout("timeout()", 1); + setTimeout("hotkey_prefix_timeout()", 5*1000); + if (typeof correctPNG != 'undefined') { correctPNG(); } diff --git a/tt-rss.js b/tt-rss.js index e5bcbf59..c185ea37 100644 --- 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; } -- 2.39.5