]> source.dussan.org Git - rspamd.git/commitdiff
[WebUI] Show symbol descriptions as tooltips in history 2027/head
authorAndré Hänsel <haensel@creations.de>
Tue, 20 Feb 2018 13:24:44 +0000 (14:24 +0100)
committerAndré Hänsel <haensel@creations.de>
Tue, 20 Feb 2018 13:55:35 +0000 (14:55 +0100)
On the Scan tab there was already an additional explanation shown as a tooltip for each symbol. This adds the same tooltip on the History tab.

interface/js/app/history.js

index 422b8aa3b24bb03996621e4be56bf2ebbbbd5f3d..e0b7aa22b38b26eec754aab5a94bcc1986728924 100644 (file)
@@ -37,6 +37,7 @@ function($, _, Humanize) {
       '=': '&#x3D;'
     };
     var htmlEscaper = /[&<>"'\/`=]/g;
+    var symbolDescriptions = {};
 
     EscapeHTML = function(string) {
       return ('' + string).replace(htmlEscaper, function(match) {
@@ -67,7 +68,9 @@ function($, _, Humanize) {
                             sym.name = key;
                         }
                         sym.name = EscapeHTML(key);
-                        sym.description = EscapeHTML(sym.description);
+                        if (sym.description) {
+                               sym.description = EscapeHTML(sym.description);
+                        }
 
                         if (sym.options) {
                             escape_HTML_array(sym.options);
@@ -119,8 +122,15 @@ function($, _, Humanize) {
             preprocess_item(item);
             Object.keys(item.symbols).map(function(key) {
                 var sym = item.symbols[key];
-             
-                var str = '<strong>' + sym.name + '</strong>' + "(" + sym.score + ")";
+
+                if (sym.description) {
+                       var str = '<strong><abbr data-sym-key="' + key + '">' + sym.name + '</abbr></strong>' + "(" + sym.score + ")";
+
+                       // Store description for tooltip
+                       symbolDescriptions[key] = sym.description;
+                } else {
+                       var str = '<strong>' + sym.name + '</strong>' + "(" + sym.score + ")";
+                }
 
                if (sym.options) {
                    str += '[' + sym.options.join(",") + "]";
@@ -511,8 +521,20 @@ function($, _, Humanize) {
                         "sorting": {
                             "enabled": true
                         },
-                        components: {
-                            filtering: FooTable.actionFilter
+                        "components": {
+                            "filtering": FooTable.actionFilter
+                        },
+                        "on": {
+                               "ready.ft.table": function () {
+                                       // Update symbol description tooltips
+                                       $.each(symbolDescriptions, function (key, description) {
+                                               $('abbr[data-sym-key=' + key + ']').tooltip({
+                                                       "placement": "bottom",
+                                                       "html": true,
+                                                       "title": description
+                                               });
+                                       });
+                               }
                         }
                     });
                 } else {