From 3ea278aff4692e037ffff4db0f7ac665598e1fc2 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 6 Apr 2024 12:52:03 +0200 Subject: [PATCH] [feat] preferences: button to enable/disable all engines --- .../themes/simple/src/js/main/preferences.js | 16 ++++++++++++++++ .../themes/simple/src/less/preferences.less | 5 +++++ searx/templates/simple/preferences/engines.html | 6 ++++++ 3 files changed, 27 insertions(+) diff --git a/searx/static/themes/simple/src/js/main/preferences.js b/searx/static/themes/simple/src/js/main/preferences.js index e9dc7c85c..a0b853d61 100644 --- a/searx/static/themes/simple/src/js/main/preferences.js +++ b/searx/static/themes/simple/src/js/main/preferences.js @@ -27,6 +27,22 @@ searxng.on(el, 'mouseenter', load_engine_descriptions); } + const enableAllEngines = d.querySelectorAll(".enable-all-engines"); + const disableAllEngines = d.querySelectorAll(".disable-all-engines"); + const engineToggles = d.querySelectorAll('tbody input[type=checkbox][class~=checkbox-onoff]'); + const toggleEngines = (enable) => { + for (const el of engineToggles) { + // check if element visible, so that only engines of the current category are modified + if (el.offsetParent !== null) el.checked = !enable; + } + }; + for (const el of enableAllEngines) { + searxng.on(el, 'click', () => toggleEngines(true)); + } + for (const el of disableAllEngines) { + searxng.on(el, 'click', () => toggleEngines(false)); + } + const copyHashButton = d.querySelector("#copy-hash"); searxng.on(copyHashButton, 'click', (e) => { e.preventDefault(); diff --git a/searx/static/themes/simple/src/less/preferences.less b/searx/static/themes/simple/src/less/preferences.less index 88543e03b..ecbcceee7 100644 --- a/searx/static/themes/simple/src/less/preferences.less +++ b/searx/static/themes/simple/src/less/preferences.less @@ -185,6 +185,11 @@ table { } } + #toggle-all-engines-container { + width: max-content; + margin-left: auto; + } + div.selectable_url { pre { width: 100%; diff --git a/searx/templates/simple/preferences/engines.html b/searx/templates/simple/preferences/engines.html index ae71e1c97..f51f156d2 100644 --- a/searx/templates/simple/preferences/engines.html +++ b/searx/templates/simple/preferences/engines.html @@ -10,6 +10,12 @@ {{- ' ' -}}

{%- endif -%} + +
+ + +
+
{{- '' -}} {{- '' -}}