on master help sign in
[mod] the search text input gets the focus automatically
commit4e8b75a0fbddb64e079dfd88658f344fa624f27c authordalf <alex@al-f.net> dateTue 31 Dec 2013, 13:33 (13 years ago) parent04727a2
2 files changed+28
searx/static/js/searx.js+27 searx/templates/base.html+1
searx/static/js/searx.jsnew file+27
@@ -0,0 +1,27 @@
1+(function (w, d) {
2+ 'use strict';
3+ function addListener(el, type, fn) {
4+ if (el.addEventListener) {
5+ el.addEventListener(type, fn, false);
6+ } else {
7+ el.attachEvent('on' + type, fn);
8+ }
9+ }
10+
11+ function placeCursorAtEnd() {
12+ if (this.setSelectionRange) {
13+ var len = this.value.length * 2;
14+ this.setSelectionRange(len, len);
15+ }
16+ }
17+
18+ addListener(w, 'load', function () {
19+ var qinput = d.getElementById('q');
20+ if (qinput !== null) {
21+ addListener(qinput, 'focus', placeCursorAtEnd);
22+ qinput.focus();
23+ }
24+ });
25+
26+})(window, document);
27+
searx/templates/base.html+1
@@ -18,6 +18,7 @@
1818<div id="container">
1919{% block content %}
2020{% endblock %}
21+<script src="/static/js/searx.js" ></script>
2122</div>
2223</body>
2324</html>