diff options
| author | pw3t <romain@berthor.fr> | 2014-01-02 19:52:21 +0100 |
|---|---|---|
| committer | pw3t <romain@berthor.fr> | 2014-01-02 19:52:21 +0100 |
| commit | efb6eca39e9dd851645f76bd72ac076f61a11c09 (patch) | |
| tree | 04b571f5d56967d63c213b45d35cfda08c4d2769 /searx/static | |
| parent | 6f2b8aca5e36196f6370951d915b06356a2549db (diff) | |
| parent | d2898b08187101aad477ef48c8ea7518cee8b925 (diff) | |
Merge branch 'master' of https://github.com/asciimoo/searx
Diffstat (limited to 'searx/static')
| -rw-r--r-- | searx/static/js/searx.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/searx/static/js/searx.js b/searx/static/js/searx.js new file mode 100644 index 000000000..5eb880f65 --- /dev/null +++ b/searx/static/js/searx.js @@ -0,0 +1,27 @@ +(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) { + addListener(qinput, 'focus', placeCursorAtEnd); + qinput.focus(); + } + }); + +})(window, document); + |