From cc3d591bd02b1169f222f4200670d86cb85a530a Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Tue, 7 Jul 2015 01:00:30 +0200 Subject: [PATCH] infobox/node: move status to attributes table --- lib/infobox/node.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/infobox/node.js b/lib/infobox/node.js index 4c46c2f..54dd801 100644 --- a/lib/infobox/node.js +++ b/lib/infobox/node.js @@ -36,6 +36,13 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"], } } + function showStatus(d) { + return function (el) { + el.classList.add(d.flags.online ? "online" : "offline") + el.textContent = d.flags.online ? "online" : "offline, " + d.lastseen.fromNow(true) + } + } + function showFirmware(d) { var release = dictGet(d.nodeinfo, ["software", "firmware", "release"]) var base = dictGet(d.nodeinfo, ["software", "firmware", "base"]) @@ -169,15 +176,12 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"], return function(config, el, router, d) { var h2 = document.createElement("h2") h2.textContent = d.nodeinfo.hostname - var span = document.createElement("span") - span.classList.add(d.flags.online ? "online" : "offline") - span.textContent = " (" + (d.flags.online ? "online" : "offline, " + d.lastseen.fromNow(true)) + ")" - h2.appendChild(span) el.appendChild(h2) var attributes = document.createElement("table") attributes.classList.add("attributes") + attributeEntry(attributes, "Status", showStatus(d)) attributeEntry(attributes, "Gateway", d.flags.gateway ? "ja" : null) attributeEntry(attributes, "Koordinaten", showGeoURI(d))