diff options
| author | dalf <alex@al-f.net> | 2013-12-31 13:33:45 +0100 |
|---|---|---|
| committer | dalf <alex@al-f.net> | 2013-12-31 13:35:43 +0100 |
| commit | 4e8b75a0fbddb64e079dfd88658f344fa624f27c (patch) | |
| tree | 8f5b0517abd7633e3eb7631738159f976a591499 /searx | |
| parent | 04727a2043025597293fed47392f3b748a654a01 (diff) | |
[mod] the search text input gets the focus automatically
Diffstat (limited to 'searx')
| -rw-r--r-- | searx/static/js/searx.js | 27 | ||||
| -rw-r--r-- | searx/templates/base.html | 1 |
2 files changed, 28 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); + diff --git a/searx/templates/base.html b/searx/templates/base.html index 9aa40297e..8175836ec 100644 --- a/searx/templates/base.html +++ b/searx/templates/base.html @@ -18,6 +18,7 @@ <div id="container"> {% block content %} {% endblock %} +<script src="/static/js/searx.js" ></script> </div> </body> </html> |