logo

searx

My custom branche(s) on searx, a meta-search engine git clone https://hacktivis.me/git/searx.git

searx.js (1188B)


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