summaryrefslogtreecommitdiff
path: root/searx/static/default/js/searx.js
diff options
context:
space:
mode:
authorMatej Cotman <cotman.matej@gmail.com>2014-04-24 23:46:40 +0000
committerMatej Cotman <cotman.matej@gmail.com>2014-06-05 13:18:22 +0200
commit08eaffe245303818069df3332eece11f41a0bd8e (patch)
tree9a111cc283b644de9f9df306c531644e8421e283 /searx/static/default/js/searx.js
parent3386e21cdf30bf0accb84e2dcc4dea0076af1b90 (diff)
add multi theming support
Diffstat (limited to 'searx/static/default/js/searx.js')
-rw-r--r--searx/static/default/js/searx.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/searx/static/default/js/searx.js b/searx/static/default/js/searx.js
new file mode 100644
index 000000000..47dc722da
--- /dev/null
+++ b/searx/static/default/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);
+