preferences.js 1.1 KB

123456789101112131415161718192021222324252627282930
  1. /**
  2. * @license
  3. * (C) Copyright Contributors to the SearXNG project.
  4. * (C) Copyright Contributors to the searx project (2014 - 2021).
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. $(document).ready(function(){
  8. let engine_descriptions = null;
  9. function load_engine_descriptions() {
  10. if (engine_descriptions == null) {
  11. $.ajax("engine_descriptions.json", dataType="json").done(function(data) {
  12. engine_descriptions = data;
  13. for (const [engine_name, description] of Object.entries(data)) {
  14. let elements = $('[data-engine-name="' + engine_name + '"] .description');
  15. for(const element of elements) {
  16. let source = ' (<i>' + searxng.translations.Source + ':&nbsp;' + description[1] + '</i>)';
  17. element.innerHTML = description[0] + source;
  18. }
  19. }
  20. });
  21. }
  22. }
  23. if (document.querySelector('body[class="preferences_endpoint"]')) {
  24. $('[data-engine-name]').hover(function() {
  25. load_engine_descriptions();
  26. });
  27. }
  28. });