searx.js 987 B

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