[feat] preferences: button to enable/disable all engines

This commit is contained in:
Bnyro 2024-04-06 12:52:03 +02:00 committed by Markus Heiser
parent 46efb2f36d
commit 3ea278aff4
3 changed files with 27 additions and 0 deletions

View File

@ -27,6 +27,22 @@
searxng.on(el, 'mouseenter', load_engine_descriptions); 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"); const copyHashButton = d.querySelector("#copy-hash");
searxng.on(copyHashButton, 'click', (e) => { searxng.on(copyHashButton, 'click', (e) => {
e.preventDefault(); e.preventDefault();

View File

@ -185,6 +185,11 @@ table {
} }
} }
#toggle-all-engines-container {
width: max-content;
margin-left: auto;
}
div.selectable_url { div.selectable_url {
pre { pre {
width: 100%; width: 100%;

View File

@ -10,6 +10,12 @@
{{- ' ' -}}<a href="{{ url_for('info', pagename='search-syntax') }}">&#9432;</a> {{- ' ' -}}<a href="{{ url_for('info', pagename='search-syntax') }}">&#9432;</a>
</p> </p>
{%- endif -%} {%- endif -%}
<div class="hide_if_nojs" id="toggle-all-engines-container">
<button type="button" class="button enable-all-engines">{{ _("Enable all") }}</button>
<button type="button" class="button disable-all-engines">{{ _("Disable all") }}</button>
</div>
<div class="scrollx">{{- '' -}} <div class="scrollx">{{- '' -}}
<table class="striped table_engines">{{- '' -}} <table class="striped table_engines">{{- '' -}}