diff options
author | André Hänsel <haensel@creations.de> | 2018-02-20 14:24:44 +0100 |
---|---|---|
committer | André Hänsel <haensel@creations.de> | 2018-02-20 14:55:35 +0100 |
commit | 7211d003d80093c2221a20a41f8c902e4201eb82 (patch) | |
tree | 968a8a973e2478207f4178754c413e3d201fad8e /interface/js | |
parent | cdb9a9ad60ee2d1494ca3e0236d3debd7aca919e (diff) | |
download | rspamd-7211d003d80093c2221a20a41f8c902e4201eb82.tar.gz rspamd-7211d003d80093c2221a20a41f8c902e4201eb82.zip |
[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.
Diffstat (limited to 'interface/js')
-rw-r--r-- | interface/js/app/history.js | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/interface/js/app/history.js b/interface/js/app/history.js index 422b8aa3b..e0b7aa22b 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 = '<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 { |