diff options
author | Bnyro <bnyro@tutanota.com> | 2024-12-15 12:44:25 +0100 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarIT.de> | 2024-12-16 08:36:48 +0100 |
commit | c8e932647be1e6930caa312301f2ec99dc7f4ff4 (patch) | |
tree | 98f922b770967c94d71f034da2095a53717abbed | |
parent | 8d2c01e4ce8d64b477d538c4bd7409e3524a376d (diff) | |
download | searxng-c8e932647be1e6930caa312301f2ec99dc7f4ff4.tar.gz searxng-c8e932647be1e6930caa312301f2ec99dc7f4ff4.zip |
[fix] settings: javascript crash when entering due to missing search form
-rw-r--r-- | searx/static/themes/simple/src/js/main/search.js | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/searx/static/themes/simple/src/js/main/search.js b/searx/static/themes/simple/src/js/main/search.js index af34b4867..68f77c86a 100644 --- a/searx/static/themes/simple/src/js/main/search.js +++ b/searx/static/themes/simple/src/js/main/search.js @@ -186,20 +186,22 @@ // override form submit action to update the actually selected categories const form = d.querySelector("#search"); - searxng.on(form, 'submit', (event) => { - event.preventDefault(); - const categoryValuesInput = d.querySelector("#selected-categories"); - if (categoryValuesInput) { - let categoryValues = []; - for (let categoryButton of categoryButtons) { - if (categoryButton.classList.contains("selected")) { - categoryValues.push(categoryButton.name.replace("category_", "")); + if (form != null) { + searxng.on(form, 'submit', (event) => { + event.preventDefault(); + const categoryValuesInput = d.querySelector("#selected-categories"); + if (categoryValuesInput) { + let categoryValues = []; + for (let categoryButton of categoryButtons) { + if (categoryButton.classList.contains("selected")) { + categoryValues.push(categoryButton.name.replace("category_", "")); + } } + categoryValuesInput.value = categoryValues.join(","); } - categoryValuesInput.value = categoryValues.join(","); - } - form.submit(); - }); + form.submit(); + }); + } }); })(window, document, window.searxng); |