From: André Hänsel Date: Tue, 20 Feb 2018 13:24:44 +0000 (+0100) Subject: [WebUI] Show symbol descriptions as tooltips in history X-Git-Tag: 1.7.0~161^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F2027%2Fhead;p=thirdparty%2Frspamd.git [WebUI] Show symbol descriptions as tooltips in history 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. --- diff --git a/interface/js/app/history.js b/interface/js/app/history.js index 422b8aa3b2..e0b7aa22b3 100644 --- a/interface/js/app/history.js +++ b/interface/js/app/history.js @@ -37,6 +37,7 @@ function($, _, Humanize) { '=': '=' }; 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 = '' + sym.name + '' + "(" + sym.score + ")"; + + if (sym.description) { + var str = '' + sym.name + '' + "(" + sym.score + ")"; + + // Store description for tooltip + symbolDescriptions[key] = sym.description; + } else { + var str = '' + sym.name + '' + "(" + 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 {