diff --git a/lib/infobox/link.js b/lib/infobox/link.js index a019d94..cd8f01d 100644 --- a/lib/infobox/link.js +++ b/lib/infobox/link.js @@ -3,13 +3,14 @@ define(['helper', 'snabbdom'], function (helper, V) { V = V.default; function showStatImg(o, d, time) { - var subst = {}; - subst['{SOURCE_ID}'] = d.source.node_id; - subst['{SOURCE_NAME}'] = d.source.hostname.replace(/[^a-z0-9\-]/ig, '_'); - subst['{TARGET_ID}'] = d.target.node_id; - subst['{TARGET_NAME}'] = d.target.hostname.replace(/[^a-z0-9\-]/ig, '_'); - subst['{TIME}'] = time; - subst['{LOCALE}'] = _.locale(); + var subst = { + '{SOURCE_ID}': d.source.node_id, + '{SOURCE_NAME}': d.source.hostname.replace(/[^a-z0-9\-]/ig, '_'), + '{TARGET_ID}': d.target.node_id, + '{TARGET_NAME}': d.target.hostname.replace(/[^a-z0-9\-]/ig, '_'), + '{TIME}': time, + '{LOCALE}': _.locale() + }; return helper.showStat(V, o, subst); } diff --git a/lib/infobox/node.js b/lib/infobox/node.js index bc5ac69..c11c50c 100644 --- a/lib/infobox/node.js +++ b/lib/infobox/node.js @@ -4,11 +4,12 @@ define(['sorttable', 'snabbdom', 'd3-interpolate', 'moment', 'helper', 'utils/no V = V.default; function showStatImg(o, d) { - var subst = {}; - subst['{NODE_ID}'] = d.node_id; - subst['{NODE_NAME}'] = d.hostname.replace(/[^a-z0-9\-]/ig, '_'); - subst['{TIME}'] = d.lastseen.format('DDMMYYYYHmmss'); - subst['{LOCALE}'] = _.locale(); + var subst = { + '{NODE_ID}': d.node_id, + '{NODE_NAME}': d.hostname.replace(/[^a-z0-9\-]/ig, '_'), + '{TIME}': d.lastseen.format('DDMMYYYYHmmss'), + '{LOCALE}': _.locale() + }; return helper.showStat(V, o, subst); } @@ -138,7 +139,6 @@ define(['sorttable', 'snabbdom', 'd3-interpolate', 'moment', 'helper', 'utils/no } }); - children.push(V.h('tr', [ V.h('th', _.t('node.gateway')), showGateway(d) diff --git a/lib/proportions.js b/lib/proportions.js index 847ba0e..8c1d637 100644 --- a/lib/proportions.js +++ b/lib/proportions.js @@ -6,6 +6,7 @@ define(['d3-interpolate', 'snabbdom', 'filters/genericnode', 'helper'], return function (filterManager) { var self = this; var scale = d3Interpolate.interpolate(config.forceGraph.tqFrom, config.forceGraph.tqTo); + var time; var statusTable; var fwTable; @@ -78,6 +79,7 @@ define(['d3-interpolate', 'snabbdom', 'filters/genericnode', 'helper'], self.setData = function setData(data) { var onlineNodes = data.nodes.online; var nodes = onlineNodes.concat(data.nodes.lost); + time = data.timestamp; function hostnameOfNodeID(nodeid) { var gateway = data.nodeDict[nodeid]; @@ -163,9 +165,13 @@ define(['d3-interpolate', 'snabbdom', 'filters/genericnode', 'helper'], var images = document.createElement('div'); el.appendChild(images); var img = []; + var subst = { + '{TIME}': time, + '{LOCALE}': _.locale() + }; config.globalInfos.forEach(function (globalInfo) { img.push(V.h('h2', globalInfo.name)); - img.push(helper.showStat(V, globalInfo)); + img.push(helper.showStat(V, globalInfo, subst)); }); V.patch(images, V.h('div', img)); } diff --git a/lib/utils/helper.js b/lib/utils/helper.js index bd83b45..6371721 100644 --- a/lib/utils/helper.js +++ b/lib/utils/helper.js @@ -117,10 +117,7 @@ define({ } }, showStat: function showStat(V, o, subst) { - var content; - subst = typeof subst !== 'undefined' ? subst : {}; - - content = V.h('img', { attrs: { src: require('helper').listReplace(o.image, subst) } }); + var content = V.h('img', { attrs: { src: require('helper').listReplace(o.image, subst) } }); if (o.href) { return V.h('p', V.h('a', {