logo

searx

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

autocompleter.js (1341B)


  1. /**
  2. * searx is free software: you can redistribute it and/or modify
  3. * it under the terms of the GNU Affero General Public License as published by
  4. * the Free Software Foundation, either version 3 of the License, or
  5. * (at your option) any later version.
  6. *
  7. * searx is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU Affero General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU Affero General Public License
  13. * along with searx. If not, see < http://www.gnu.org/licenses/ >.
  14. *
  15. * (C) 2014 by Thomas Pointhuber, <thomas.pointhuber@gmx.at>
  16. */
  17. if(searx.autocompleter) {
  18. searx.searchResults = new Bloodhound({
  19. datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
  20. queryTokenizer: Bloodhound.tokenizers.whitespace,
  21. remote: './autocompleter?q=%QUERY'
  22. });
  23. searx.searchResults.initialize();
  24. }
  25. $(document).ready(function(){
  26. if(searx.autocompleter) {
  27. $('#q').typeahead(null, {
  28. name: 'search-results',
  29. displayKey: function(result) {
  30. return result;
  31. },
  32. source: searx.searchResults.ttAdapter()
  33. });
  34. }
  35. });