summaryrefslogtreecommitdiff
path: root/searx/static
diff options
context:
space:
mode:
authorasciimoo <asciimoo@gmail.com>2014-01-01 20:56:50 +0100
committerasciimoo <asciimoo@gmail.com>2014-01-01 20:56:50 +0100
commit11fdd8e8ac2021d6c72cd82217f1b999f1b788ca (patch)
treee831d52ff724f89ccc967904d5250ad0cc872e5c /searx/static
parent41dea8ab5388a68a12661f1c8482911840a109aa (diff)
parent2006a1df1c271349462d3ed7be40d3e59340dae5 (diff)
Merge remote-tracking branch 'dalf/master'
Diffstat (limited to 'searx/static')
-rw-r--r--searx/static/js/searx.js27
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);
+