searx.js 997 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. window.addEvent('domready', function() {
  2. new Autocompleter.Request.JSON('q', '/', {
  3. postVar:'q',
  4. postData:{
  5. 'autocompleter': 1,
  6. 'format': 'json'
  7. },
  8. ajaxOptions:{
  9. timeout: 5 // Correct option?
  10. },
  11. 'minLength': 4,
  12. 'selectMode': 'type-ahead',
  13. cache: true,
  14. delay: 300
  15. });
  16. });
  17. (function (w, d) {
  18. 'use strict';
  19. function addListener(el, type, fn) {
  20. if (el.addEventListener) {
  21. el.addEventListener(type, fn, false);
  22. } else {
  23. el.attachEvent('on' + type, fn);
  24. }
  25. }
  26. function placeCursorAtEnd() {
  27. if (this.setSelectionRange) {
  28. var len = this.value.length * 2;
  29. this.setSelectionRange(len, len);
  30. }
  31. }
  32. addListener(w, 'load', function () {
  33. var qinput = d.getElementById('q');
  34. if (qinput !== null && qinput.value === "") {
  35. addListener(qinput, 'focus', placeCursorAtEnd);
  36. qinput.focus();
  37. }
  38. });
  39. })(window, document);