From eec498c3d5ce6b13560502e09195de93f1879b45 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 18 May 2008 04:44:59 +0100 Subject: [PATCH] hotkey system bugfixes --- prefs.js | 54 +++++++++++++++++++++++++--------------- tt-rss.js | 74 ++++++++++++++++++++++++++++++++++--------------------- 2 files changed, 80 insertions(+), 48 deletions(-) diff --git a/prefs.js b/prefs.js index ad64f4812..698bc7163 100644 --- a/prefs.js +++ b/prefs.js @@ -1202,7 +1202,7 @@ function editSelectedFeedCat() { } -function localPiggieFunction(enable) { +function piggie(enable) { if (enable) { debug("I LOVEDED IT!"); var piggie = document.getElementById("piggie"); @@ -1705,6 +1705,8 @@ function pref_hotkey_handler(e) { keycode = e.which; } + var keychar = String.fromCharCode(keycode); + if (keycode == 27) { // escape if (Element.visible("hotkey_help_overlay")) { Element.hide("hotkey_help_overlay"); @@ -1722,7 +1724,7 @@ function pref_hotkey_handler(e) { if ((keycode == 67 || keycode == 71) && !hotkey_prefix) { hotkey_prefix = keycode; - debug("KP: PREFIX=" + keycode); + debug("KP: PREFIX=" + keycode + " CHAR=" + keychar); return; } @@ -1752,24 +1754,25 @@ function pref_hotkey_handler(e) { return; } - if (keycode == 191 && shift_key) { // ? + if ((keycode == 191 || keychar == '?') && shift_key) { // ? if (!Element.visible("hotkey_help_overlay")) { //Element.show("hotkey_help_overlay"); Effect.Appear("hotkey_help_overlay", {duration : 0.3}); } else { Element.hide("hotkey_help_overlay"); } - return; + return false; } - if (keycode == 191) { // / + if (keycode == 191 || keychar == '/') { // / var search_boxes = new Array("label_search", "feed_search", "filter_search", "user_search"); for (var i = 0; i < search_boxes.length; i++) { var elem = document.getElementById(search_boxes[i]); if (elem) { - return focus_element(search_boxes[i]); + focus_element(search_boxes[i]); + return false; } } } @@ -1781,15 +1784,18 @@ function pref_hotkey_handler(e) { hotkey_prefix = false; if (keycode == 70) { // f - return displayDlg("quickAddFilter"); + displayDlg("quickAddFilter"); + return false; } if (keycode == 83) { // s - return displayDlg("quickAddFeed"); + displayDlg("quickAddFeed"); + return false; } if (keycode == 76) { // l - return displayDlg("quickAddLabel"); + displayDlg("quickAddLabel"); + return false; } if (keycode == 85) { // u @@ -1797,11 +1803,13 @@ function pref_hotkey_handler(e) { } if (keycode == 67) { // c - return editFeedCats(); + editFeedCats(); + return false; } if (keycode == 84 && shift_key) { // T - return browseFeeds(); + browseFeeds(); + return false; } } @@ -1814,26 +1822,32 @@ function pref_hotkey_handler(e) { if (keycode == 49 && document.getElementById("genConfigTab")) { // 1 selectTab("genConfig"); + return false; } if (keycode == 50 && document.getElementById("feedConfigTab")) { // 2 - return selectTab("feedConfig"); + selectTab("feedConfig"); + return false; } if (keycode == 51 && document.getElementById("feedBrowserTab")) { // 3 - return selectTab("feedBrowser"); + selectTab("feedBrowser"); + return false; } if (keycode == 52 && document.getElementById("filterConfigTab")) { // 4 - return selectTab("filterConfig"); + selectTab("filterConfig"); + return false; } if (keycode == 53 && document.getElementById("labelConfigTab")) { // 5 - return selectTab("labelConfig"); + selectTab("labelConfig"); + return false; } if (keycode == 54 && document.getElementById("userConfigTab")) { // 6 - return selectTab("userConfig"); + selectTab("userConfig"); + return false; } if (keycode == 88) { // x @@ -1846,16 +1860,16 @@ function pref_hotkey_handler(e) { if (seq.match("807371717369")) { seq = ""; - localPiggieFunction(true); + piggie(true); } else { - localPiggieFunction(false); + piggie(false); } } if (hotkey_prefix) { - debug("KP: PREFIX=" + hotkey_prefix + " CODE=" + keycode); + debug("KP: PREFIX=" + hotkey_prefix + " CODE=" + keycode + " CHAR=" + keychar); } else { - debug("KP: CODE=" + keycode); + debug("KP: CODE=" + keycode + " CHAR=" + keychar); } } catch (e) { diff --git a/tt-rss.js b/tt-rss.js index aea274095..3b16e13f8 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -931,7 +931,7 @@ function hotkey_handler(e) { keycode = e.which; } - keychar = String.fromCharCode(keycode); + var keychar = String.fromCharCode(keycode); if (keycode == 27) { // escape if (Element.visible("hotkey_help_overlay")) { @@ -950,7 +950,7 @@ function hotkey_handler(e) { if ((keycode == 70 || keycode == 67 || keycode == 71) && !hotkey_prefix) { hotkey_prefix = keycode; - debug("KP: PREFIX=" + keycode); + debug("KP: PREFIX=" + keycode + " CHAR=" + keychar); return; } @@ -974,27 +974,30 @@ function hotkey_handler(e) { return; } - if (keycode == 191 && shift_key) { // ? + if ((keycode == 191 || keychar == '?') && shift_key) { // ? if (!Element.visible("hotkey_help_overlay")) { //Element.show("hotkey_help_overlay"); Effect.Appear("hotkey_help_overlay", {duration : 0.3}); } else { Element.hide("hotkey_help_overlay"); } - return; + return false; } - if (keycode == 191 || (is_opera() && keycode == 47)) { // / - return displayDlg("search", getActiveFeedId() + ":" + activeFeedIsCat()); + if (keycode == 191 || keychar == '/') { // / + displayDlg("search", getActiveFeedId() + ":" + activeFeedIsCat()); + return false; } if (keycode == 82 && shift_key) { // R - return scheduleFeedUpdate(true); + scheduleFeedUpdate(true); + return false; } if (keycode == 82) { // r if (getActiveFeedId()) { - return viewfeed(getActiveFeedId(), "ForceUpdate"); + viewfeed(getActiveFeedId(), "ForceUpdate"); + return false; } } @@ -1002,14 +1005,14 @@ function hotkey_handler(e) { var feed = getActiveFeedId(); var new_feed = getRelativeFeedId(feedlist, feed, 'prev'); if (new_feed) viewfeed(new_feed, ''); - return; + return false; } if (keycode == 75) { // k var feed = getActiveFeedId(); var new_feed = getRelativeFeedId(feedlist, feed, 'next'); if (new_feed) viewfeed(new_feed, ''); - return; + return false; } if (shift_key && (keycode == 78 || keycode == 40)) { // shift - n, down @@ -1041,7 +1044,7 @@ function hotkey_handler(e) { if (id) { togglePub(id); } - return; + return false; } if (keycode == 83) { // s @@ -1049,7 +1052,7 @@ function hotkey_handler(e) { if (id) { toggleMark(id); } - return; + return false; } @@ -1058,13 +1061,14 @@ function hotkey_handler(e) { if (id) { toggleUnread(id); } - return; + return false; } if (keycode == 84 && shift_key) { // T var id = getActiveArticleId(); if (id) { editArticleTags(id, getActiveFeedId(), isCdmMode()); + return false; } } @@ -1076,15 +1080,15 @@ function hotkey_handler(e) { if (cb) { cb.checked = !cb.checked; toggleSelectRowById(cb, "RROW-" + id); + return false; } - - return false; } } if (keycode == 79) { // o if (getActiveArticleId()) { openArticleInNewWindow(getActiveArticleId()); + return false; } } @@ -1097,36 +1101,43 @@ function hotkey_handler(e) { hotkey_prefix = false; if (keycode == 65) { // a - return toggleDispRead(); + toggleDispRead(); + return false; } if (keycode == 85 && shift_key) { // U - return scheduleFeedUpdate(true); + scheduleFeedUpdate(true); + return false; } if (keycode == 85) { // u if (getActiveFeedId()) { - return viewfeed(getActiveFeedId(), "ForceUpdate"); + viewfeed(getActiveFeedId(), "ForceUpdate"); + return false; } } if (keycode == 69) { // e - return editFeedDlg(getActiveFeedId()); + editFeedDlg(getActiveFeedId()); + return false; } if (keycode == 83) { // s - return displayDlg("quickAddFeed"); + displayDlg("quickAddFeed"); + return false; } if (keycode == 67 && shift_key) { // C if (typeof catchupAllFeeds != 'undefined') { - return catchupAllFeeds(); + catchupAllFeeds(); + return false; } } if (keycode == 67) { // c if (getActiveFeedId()) { - return catchupCurrentFeed(); + catchupCurrentFeed(); + return false; } } @@ -1138,12 +1149,14 @@ function hotkey_handler(e) { hotkey_prefix = false; if (keycode == 70) { // f - return displayDlg("quickAddFilter", getActiveFeedId()); + displayDlg("quickAddFilter", getActiveFeedId()); + return false; } if (keycode == 83) { // s if (typeof collapse_feedlist != 'undefined') { - return collapse_feedlist(); + collapse_feedlist(); + return false; } } @@ -1156,23 +1169,28 @@ function hotkey_handler(e) { hotkey_prefix = false; if (keycode == 83) { // s - return viewfeed(-1); + viewfeed(-1); + return false; } if (keycode == 80 && shift_key) { // P - return gotoPreferences(); + gotoPreferences(); + return false; } if (keycode == 80) { // p - return viewfeed(-2); + viewfeed(-2); + return false; } if (keycode == 70) { // f - return viewfeed(-3); + viewfeed(-3); + return false; } if (keycode == 84 && shift_key) { // T toggleTags(); + return false; } }