diff options
| author | Alexandre Flament <alex@al-f.net> | 2021-11-05 09:51:27 +0100 |
|---|---|---|
| committer | Alexandre Flament <alex@al-f.net> | 2021-11-05 09:51:27 +0100 |
| commit | 680d70865f763aff45a9d5fea8649c6fa1725deb (patch) | |
| tree | d289e1fe5d29e51b0b7fb05fda0ed29199410e05 /searx/static/themes/simple/src/js/main/searx_search.js | |
| parent | 523b3c095222fc615dc02f27de1e94b2a7b6e270 (diff) | |
[mod] SearXNG: remove "searx" from the searx*.js file names.
Diffstat (limited to 'searx/static/themes/simple/src/js/main/searx_search.js')
| -rw-r--r-- | searx/static/themes/simple/src/js/main/searx_search.js | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/searx/static/themes/simple/src/js/main/searx_search.js b/searx/static/themes/simple/src/js/main/searx_search.js deleted file mode 100644 index d3149340a..000000000 --- a/searx/static/themes/simple/src/js/main/searx_search.js +++ /dev/null @@ -1,107 +0,0 @@ -/* SPDX-License-Identifier: AGPL-3.0-or-later */ -/* global AutoComplete */ -(function(w, d, searxng) { - 'use strict'; - - var firstFocus = true, qinput_id = "q", qinput; - - function placeCursorAtEnd(element) { - if (element.setSelectionRange) { - var len = element.value.length; - element.setSelectionRange(len, len); - } - } - - function submitIfQuery() { - if (qinput.value.length > 0) { - var search = document.getElementById('search'); - setTimeout(search.submit.bind(search), 0); - } - } - - function createClearButton(qinput) { - var cs = document.getElementById('clear_search'); - var updateClearButton = function() { - if (qinput.value.length === 0) { - cs.classList.add("empty"); - } else { - cs.classList.remove("empty"); - } - }; - - // update status, event listener - updateClearButton(); - cs.addEventListener('click', function() { - qinput.value=''; - qinput.focus(); - updateClearButton(); - }); - qinput.addEventListener('keyup', updateClearButton, false); - } - - searxng.ready(function() { - qinput = d.getElementById(qinput_id); - - function placeCursorAtEndOnce() { - if (firstFocus) { - placeCursorAtEnd(qinput); - firstFocus = false; - } else { - // e.preventDefault(); - } - } - - if (qinput !== null) { - // clear button - createClearButton(qinput); - - // autocompleter - if (searxng.autocompleter) { - searxng.autocomplete = AutoComplete.call(w, { - Url: "./autocompleter", - EmptyMessage: searxng.translations.no_item_found, - HttpMethod: searxng.method, - HttpHeaders: { - "Content-type": "application/x-www-form-urlencoded", - "X-Requested-With": "XMLHttpRequest" - }, - MinChars: 4, - Delay: 300, - }, "#" + qinput_id); - - // hack, see : https://github.com/autocompletejs/autocomplete.js/issues/37 - w.addEventListener('resize', function() { - var event = new CustomEvent("position"); - qinput.dispatchEvent(event); - }); - } - - qinput.addEventListener('focus', placeCursorAtEndOnce, false); - qinput.focus(); - } - - // vanilla js version of search_on_category_select.js - if (qinput !== null && d.querySelector('.help') != null && searxng.search_on_category_select) { - d.querySelector('.help').className='invisible'; - - searxng.on('#categories input', 'change', function() { - var i, categories = d.querySelectorAll('#categories input[type="checkbox"]'); - for(i=0; i<categories.length; i++) { - if (categories[i] !== this && categories[i].checked) { - categories[i].click(); - } - } - if (! this.checked) { - this.click(); - } - submitIfQuery(); - return false; - }); - - searxng.on(d.getElementById('time_range'), 'change', submitIfQuery); - searxng.on(d.getElementById('language'), 'change', submitIfQuery); - } - - }); - -})(window, document, window.searxng); |