From a7756c44e83a606c761d6f4bf5502fccce8c5a4a Mon Sep 17 00:00:00 2001 From: kb-light Date: Sat, 11 Feb 2017 01:21:20 +0100 Subject: [PATCH] infobox/link: linkinfos {SOURCE_NAME} and {TARGET_NAME} support (#82) --- lib/infobox/link.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/infobox/link.js b/lib/infobox/link.js index 794753a..82b2d9f 100644 --- a/lib/infobox/link.js +++ b/lib/infobox/link.js @@ -1,8 +1,10 @@ define(function () { - function showStatImg(o, source, target) { + function showStatImg(o, d) { var subst = {} - subst["{SOURCE}"] = source - subst["{TARGET}"] = target + subst["{SOURCE}"] = d.source.node_id + subst["{SOURCE_NAME}"] = d.source.node.nodeinfo.hostname ? d.source.node.nodeinfo.hostname : "unknown" + subst["{TARGET}"] = d.target.node_id + subst["{TARGET_NAME}"] = d.target.node.nodeinfo.hostname ? d.target.node.nodeinfo.hostname : "unknown" return showStat(o, subst) } @@ -35,15 +37,12 @@ define(function () { attributeEntry(attributes, "Hardware", (hw1 != null ? hw1 : "unbekannt") + " – " + (hw2 != null ? hw2 : "unbekannt")) el.appendChild(attributes) - if (config.linkInfos) { - var source = d.source.node_id - var target = d.target.node_id + if (config.linkInfos) config.linkInfos.forEach( function (linkInfo) { var h4 = document.createElement("h4") h4.textContent = linkInfo.name el.appendChild(h4) - el.appendChild(showStatImg(linkInfo, source, target)) + el.appendChild(showStatImg(linkInfo, d)) }) - } } })