logo

searx

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

searx_results.js (2396B)


  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) 2017 by Alexandre Flament, <alex@al-f.net>
  16. */
  17. (function(w, d, searx) {
  18. 'use strict';
  19. searx.ready(function() {
  20. searx.image_thumbnail_layout = new searx.ImageLayout('#urls', '#urls .result-images', 'img.image_thumbnail', 200);
  21. searx.image_thumbnail_layout.watch();
  22. searx.on('.btn-collapse', 'click', function(event) {
  23. var btnLabelCollapsed = this.getAttribute('data-btn-text-collapsed');
  24. var btnLabelNotCollapsed = this.getAttribute('data-btn-text-not-collapsed');
  25. var target = this.getAttribute('data-target');
  26. var targetElement = d.querySelector(target);
  27. var html = this.innerHTML;
  28. if (this.classList.contains('collapsed')) {
  29. html = html.replace(btnLabelCollapsed, btnLabelNotCollapsed);
  30. } else {
  31. html = html.replace(btnLabelNotCollapsed, btnLabelCollapsed);
  32. }
  33. this.innerHTML = html;
  34. this.classList.toggle('collapsed');
  35. targetElement.classList.toggle('invisible');
  36. });
  37. searx.on('.media-loader', 'click', function(event) {
  38. var target = this.getAttribute('data-target');
  39. var iframe_load = d.querySelector(target + ' > iframe');
  40. var srctest = iframe_load.getAttribute('src');
  41. if (srctest === null || srctest === undefined || srctest === false) {
  42. iframe_load.setAttribute('src', iframe_load.getAttribute('data-src'));
  43. }
  44. });
  45. w.addEventListener('scroll', function() {
  46. var e = d.getElementById('backToTop'),
  47. scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
  48. if (e !== null) {
  49. if (scrollTop >= 200) {
  50. e.style.opacity = 1;
  51. } else {
  52. e.style.opacity = 0;
  53. }
  54. }
  55. });
  56. });
  57. })(window, document, window.searx);