summaryrefslogtreecommitdiff
path: root/searx/static/courgette/js/searx.js
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2014-08-18 11:37:57 +0200
committerAdam Tauber <asciimoo@gmail.com>2014-08-18 11:37:57 +0200
commitd1d55f2ca41fbaf10a66bfc66d69e0fccf673413 (patch)
tree6ef0e55b147f4b82f7970ea39e890523c23aadf5 /searx/static/courgette/js/searx.js
parentce719ac50ca79cc423046ef7a32b8792a24dfe0b (diff)
parent195ff7522eea6cfbc9deb26826d8cfc424cac397 (diff)
Merge pull request #82 from courgette/master
New theme courgette
Diffstat (limited to 'searx/static/courgette/js/searx.js')
-rw-r--r--searx/static/courgette/js/searx.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/searx/static/courgette/js/searx.js b/searx/static/courgette/js/searx.js
new file mode 100644
index 000000000..47dc722da
--- /dev/null
+++ b/searx/static/courgette/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);
+