From 7211d003d80093c2221a20a41f8c902e4201eb82 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20H=C3=A4nsel?= Date: Tue, 20 Feb 2018 14:24:44 +0100 Subject: [PATCH] [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. --- interface/js/app/history.js | 32 +++++++++++++++++++++++++++----- 1 file 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 = '' + 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 { -- 2.39.5