summaryrefslogtreecommitdiff
path: root/searx/static
diff options
context:
space:
mode:
authorBnyro <bnyro@tutanota.com>2023-10-11 20:30:37 +0200
committerMarkus Heiser <markus.heiser@darmarIT.de>2023-10-13 12:56:29 +0200
commitdf2e41c150aad368b8013419a912c56cdf08f58c (patch)
tree6a03d99c8a08788473fffa311fe22ee0750ebe45 /searx/static
parent70521339d9368477a64b6d1751ad773236b16af3 (diff)
downloadsearxng-df2e41c150aad368b8013419a912c56cdf08f58c.tar.gz
searxng-df2e41c150aad368b8013419a912c56cdf08f58c.zip
[fix] search.js: crash on homepage when setting form listeners
Diffstat (limited to 'searx/static')
-rw-r--r--searx/static/themes/simple/src/js/main/search.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/searx/static/themes/simple/src/js/main/search.js b/searx/static/themes/simple/src/js/main/search.js
index 2ad8e48c5..ac1ece535 100644
--- a/searx/static/themes/simple/src/js/main/search.js
+++ b/searx/static/themes/simple/src/js/main/search.js
@@ -150,8 +150,17 @@
}
}
- // vanilla js version of search_on_category_select.js
- if (qinput !== null && searxng.settings.search_on_category_select) {
+ // Additionally to searching when selecting a new category, we also
+ // automatically start a new search request when the user changes a search
+ // filter (safesearch, time range or language) (this requires JavaScript
+ // though)
+ if (
+ qinput !== null
+ && searxng.settings.search_on_category_select
+ // If .search_filters is undefined (invisible) we are on the homepage and
+ // hence don't have to set any listeners
+ && d.querySelector(".search_filters") != null
+ ) {
searxng.on(d.getElementById('safesearch'), 'change', submitIfQuery);
searxng.on(d.getElementById('time_range'), 'change', submitIfQuery);
searxng.on(d.getElementById('language'), 'change', submitIfQuery);