searx.js 691 B

123456789101112131415161718192021222324252627
  1. (function (w, d) {
  2. 'use strict';
  3. function addListener(el, type, fn) {
  4. if (el.addEventListener) {
  5. el.addEventListener(type, fn, false);
  6. } else {
  7. el.attachEvent('on' + type, fn);
  8. }
  9. }
  10. function placeCursorAtEnd() {
  11. if (this.setSelectionRange) {
  12. var len = this.value.length * 2;
  13. this.setSelectionRange(len, len);
  14. }
  15. }
  16. addListener(w, 'load', function () {
  17. var qinput = d.getElementById('q');
  18. if (qinput !== null && qinput.value === "") {
  19. addListener(qinput, 'focus', placeCursorAtEnd);
  20. qinput.focus();
  21. }
  22. });
  23. })(window, document);