From 2f1384f1989ddcdeba96d3e0f300510db235b851 Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Sat, 18 Sep 2021 11:01:39 +0200 Subject: [enh] themes: display the engine descriptions --- .../themes/simple/src/js/main/searx_preferences.js | 27 ++++++++++++++++++++++ .../static/themes/simple/src/less/preferences.less | 12 ++++++++++ 2 files changed, 39 insertions(+) create mode 100644 searx/static/themes/simple/src/js/main/searx_preferences.js (limited to 'searx/static/themes/simple') diff --git a/searx/static/themes/simple/src/js/main/searx_preferences.js b/searx/static/themes/simple/src/js/main/searx_preferences.js new file mode 100644 index 000000000..136d9f03e --- /dev/null +++ b/searx/static/themes/simple/src/js/main/searx_preferences.js @@ -0,0 +1,27 @@ +(function (w, d, searx) { + 'use strict'; + + searx.ready(function() { + let engine_descriptions = null; + function load_engine_descriptions() { + if (engine_descriptions == null) { + searx.http("GET", "engine_descriptions.json").then(function(content) { + engine_descriptions = JSON.parse(content); + for (const [engine_name, description] of Object.entries(engine_descriptions)) { + let elements = d.querySelectorAll('[data-engine-name="' + engine_name + '"] .engine-description'); + for(const element of elements) { + let source = ' (' + searx.translations['Source'] + ': ' + description[1] + ')'; + element.innerHTML = description[0] + source; + } + } + }); + } + } + + if (d.querySelector('body[class="preferences_endpoint"]')) { + for(const el of d.querySelectorAll('[data-engine-name]')) { + searx.on(el, 'mouseenter', load_engine_descriptions); + } + } + }); +})(window, document, window.searx); diff --git a/searx/static/themes/simple/src/less/preferences.less b/searx/static/themes/simple/src/less/preferences.less index 034102e66..0be6f9023 100644 --- a/searx/static/themes/simple/src/less/preferences.less +++ b/searx/static/themes/simple/src/less/preferences.less @@ -108,6 +108,18 @@ width: 100%; } } + + th.name { + .engine-tooltip { + margin-top: 1.8rem; + left: 20rem; + max-width: 40rem; + + .engine-description { + margin-top: 0.5rem; + } + } + } } @media screen and (max-width: 75em) { -- cgit v1.2.3-54-g00ecf