summaryrefslogtreecommitdiff
path: root/searx/static/themes/simple/src/js/main
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2021-09-18 11:01:39 +0200
committerAlexandre Flament <alex@al-f.net>2021-09-24 20:38:05 +0200
commit2f1384f1989ddcdeba96d3e0f300510db235b851 (patch)
tree504e6e0f457097869d5e8a92a90f8cc7afcb98bd /searx/static/themes/simple/src/js/main
parentbfd24d1226ccdd1a9c7b07ff240a2198ab4d655b (diff)
downloadsearxng-2f1384f1989ddcdeba96d3e0f300510db235b851.tar.gz
searxng-2f1384f1989ddcdeba96d3e0f300510db235b851.zip
[enh] themes: display the engine descriptions
Diffstat (limited to 'searx/static/themes/simple/src/js/main')
-rw-r--r--searx/static/themes/simple/src/js/main/searx_preferences.js27
1 files changed, 27 insertions, 0 deletions
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 = ' (<i>' + searx.translations['Source'] + ':&nbsp;' + description[1] + '</i>)';
+ 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);