check for stuck hotkey prefixe sequences and abort them

This commit is contained in:
Andrew Dolgov 2009-10-06 15:04:46 +04:00
parent c9f185bd28
commit 164469f902
2 changed files with 27 additions and 1 deletions

View 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();
}

View File

@ -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;
}