searx_preferences.js 1.2 KB

123456789101112131415161718192021222324252627
  1. (function (w, d, searx) {
  2. 'use strict';
  3. searx.ready(function() {
  4. let engine_descriptions = null;
  5. function load_engine_descriptions() {
  6. if (engine_descriptions == null) {
  7. searx.http("GET", "engine_descriptions.json").then(function(content) {
  8. engine_descriptions = JSON.parse(content);
  9. for (const [engine_name, description] of Object.entries(engine_descriptions)) {
  10. let elements = d.querySelectorAll('[data-engine-name="' + engine_name + '"] .engine-description');
  11. for(const element of elements) {
  12. let source = ' (<i>' + searx.translations['Source'] + ':&nbsp;' + description[1] + '</i>)';
  13. element.innerHTML = description[0] + source;
  14. }
  15. }
  16. });
  17. }
  18. }
  19. if (d.querySelector('body[class="preferences_endpoint"]')) {
  20. for(const el of d.querySelectorAll('[data-engine-name]')) {
  21. searx.on(el, 'mouseenter', load_engine_descriptions);
  22. }
  23. }
  24. });
  25. })(window, document, window.searx);