From a28cfd4887813ec4343516c57376574a3f6b7427 Mon Sep 17 00:00:00 2001 From: Thomas LEBEAU Date: Mon, 18 Aug 2014 10:44:46 +0200 Subject: [new] theme courgette --- searx/static/courgette/js/searx.js | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 searx/static/courgette/js/searx.js (limited to 'searx/static/courgette/js/searx.js') diff --git a/searx/static/courgette/js/searx.js b/searx/static/courgette/js/searx.js new file mode 100644 index 000000000..47dc722da --- /dev/null +++ b/searx/static/courgette/js/searx.js @@ -0,0 +1,45 @@ +if(searx.autocompleter) { + window.addEvent('domready', function() { + new Autocompleter.Request.JSON('q', '/autocompleter', { + postVar:'q', + postData:{ + 'format': 'json' + }, + ajaxOptions:{ + timeout: 5 // Correct option? + }, + 'minLength': 4, + // 'selectMode': 'type-ahead', + cache: true, + delay: 300 + }); + }); +} + +(function (w, d) { + 'use strict'; + function addListener(el, type, fn) { + if (el.addEventListener) { + el.addEventListener(type, fn, false); + } else { + el.attachEvent('on' + type, fn); + } + } + + function placeCursorAtEnd() { + if (this.setSelectionRange) { + var len = this.value.length * 2; + this.setSelectionRange(len, len); + } + } + + addListener(w, 'load', function () { + var qinput = d.getElementById('q'); + if (qinput !== null && qinput.value === "") { + addListener(qinput, 'focus', placeCursorAtEnd); + qinput.focus(); + } + }); + +})(window, document); + -- cgit v1.2.3