[mod] add setting: search.autocomplete_min

Minimun characters to type before autocompleter starts.

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser 2022-04-22 13:47:54 +02:00
parent ed2a4c8087
commit 444b1e70db
4 changed files with 5 additions and 1 deletions

View File

@ -18,6 +18,8 @@ search:
# "seznam", "startpage", "swisscows", "qwant", "wikipedia" - leave blank to turn it off # "seznam", "startpage", "swisscows", "qwant", "wikipedia" - leave blank to turn it off
# by default. # by default.
autocomplete: "" autocomplete: ""
# minimun characters to type before autocompleter starts
autocomplete_min: 4
# Default search language - leave blank to detect from browser information or # Default search language - leave blank to detect from browser information or
# use codes from 'languages.py' # use codes from 'languages.py'
default_lang: "" default_lang: ""

View File

@ -153,6 +153,7 @@ SCHEMA = {
'search': { 'search': {
'safe_search': SettingsValue((0, 1, 2), 0), 'safe_search': SettingsValue((0, 1, 2), 0),
'autocomplete': SettingsValue(str, ''), 'autocomplete': SettingsValue(str, ''),
'autocomplete_min': SettingsValue(int, 4),
'default_lang': SettingsValue(tuple(LANGUAGE_CODES + ['']), ''), 'default_lang': SettingsValue(tuple(LANGUAGE_CODES + ['']), ''),
'languages': SettingSublistValue(LANGUAGE_CODES, LANGUAGE_CODES), 'languages': SettingSublistValue(LANGUAGE_CODES, LANGUAGE_CODES),
'ban_time_on_fail': SettingsValue(numbers.Real, 5), 'ban_time_on_fail': SettingsValue(numbers.Real, 5),

View File

@ -68,7 +68,7 @@
"Content-type": "application/x-www-form-urlencoded", "Content-type": "application/x-www-form-urlencoded",
"X-Requested-With": "XMLHttpRequest" "X-Requested-With": "XMLHttpRequest"
}, },
MinChars: 4, MinChars: searxng.settings.autocomplete_min,
Delay: 300, Delay: 300,
_Position: function () {}, _Position: function () {},
_Open: function () { _Open: function () {

View File

@ -449,6 +449,7 @@ def get_client_settings():
req_pref = request.preferences req_pref = request.preferences
return { return {
'autocomplete_provider': req_pref.get_value('autocomplete'), 'autocomplete_provider': req_pref.get_value('autocomplete'),
'autocomplete_min' : get_setting('search.autocomplete_min'),
'http_method': req_pref.get_value('method'), 'http_method': req_pref.get_value('method'),
'infinite_scroll': req_pref.get_value('infinite_scroll'), 'infinite_scroll': req_pref.get_value('infinite_scroll'),
'translations': get_translations(), 'translations': get_translations(),