diff options
author | Alexandre Flament <alex@al-f.net> | 2021-11-05 10:26:01 +0100 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2021-11-05 12:42:44 +0100 |
commit | d1c09c84e21ac66d2701e74dd25dbbf33895c0f9 (patch) | |
tree | 67930d737b9ba029b26b5371d81af29eed71ebf0 /searx/static/themes | |
parent | ba342db55e419a84b462bca17b16395f7a08c777 (diff) | |
download | searxng-d1c09c84e21ac66d2701e74dd25dbbf33895c0f9.tar.gz searxng-d1c09c84e21ac66d2701e74dd25dbbf33895c0f9.zip |
[fix] simple theme: disable hotkeys when they are not enabled in the preferences
Diffstat (limited to 'searx/static/themes')
-rw-r--r-- | searx/static/themes/simple/src/js/head/00_init.js | 1 | ||||
-rw-r--r-- | searx/static/themes/simple/src/js/main/keyboard.js | 29 |
2 files changed, 16 insertions, 14 deletions
diff --git a/searx/static/themes/simple/src/js/head/00_init.js b/searx/static/themes/simple/src/js/head/00_init.js index 4406b764e..d359a9174 100644 --- a/searx/static/themes/simple/src/js/head/00_init.js +++ b/searx/static/themes/simple/src/js/head/00_init.js @@ -21,6 +21,7 @@ autocompleter: script.getAttribute('data-autocompleter') === 'true', search_on_category_select: script.getAttribute('data-search-on-category-select') === 'true', infinite_scroll: script.getAttribute('data-infinite-scroll') === 'true', + hotkeys: script.getAttribute('data-hotkeys') === 'true', static_path: script.getAttribute('data-static-path'), translations: JSON.parse(script.getAttribute('data-translations')), }; diff --git a/searx/static/themes/simple/src/js/main/keyboard.js b/searx/static/themes/simple/src/js/main/keyboard.js index 394f97730..26cc6f7d0 100644 --- a/searx/static/themes/simple/src/js/main/keyboard.js +++ b/searx/static/themes/simple/src/js/main/keyboard.js @@ -119,20 +119,22 @@ searxng.ready(function() { } }; - searxng.on(document, "keydown", function(e) { - // check for modifiers so we don't break browser's hotkeys - if (Object.prototype.hasOwnProperty.call(vimKeys, e.keyCode) && !e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey) { - var tagName = e.target.tagName.toLowerCase(); - if (e.keyCode === 27) { - vimKeys[e.keyCode].fun(e); - } else { - if (e.target === document.body || tagName === 'a' || tagName === 'button') { - e.preventDefault(); - vimKeys[e.keyCode].fun(); + if (searxng.hotkeys) { + searxng.on(document, "keydown", function(e) { + // check for modifiers so we don't break browser's hotkeys + if (Object.prototype.hasOwnProperty.call(vimKeys, e.keyCode) && !e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey) { + var tagName = e.target.tagName.toLowerCase(); + if (e.keyCode === 27) { + vimKeys[e.keyCode].fun(e); + } else { + if (e.target === document.body || tagName === 'a' || tagName === 'button') { + e.preventDefault(); + vimKeys[e.keyCode].fun(); + } } } - } - }); + }); + } function highlightResult(which) { return function(noScroll) { @@ -353,8 +355,7 @@ searxng.ready(function() { } function toggleHelp() { - var helpPanel = document.querySelector('#vim-hotkeys-help'); - console.log(helpPanel); + var helpPanel = document.querySelector('#vim-hotkeys-help'); if (helpPanel === undefined || helpPanel === null) { // first call helpPanel = document.createElement('div'); |