make meshstats, simplenodelist setData idempotent

This commit is contained in:
Nils Schneider 2015-04-02 19:59:07 +02:00
commit 7b57a2245b
4 changed files with 53 additions and 45 deletions

View file

@ -1,7 +1,7 @@
define(function () {
return function () {
var self = this
var p
var stats, timestamp
self.setData = function (d) {
var totalNodes = sum(d.nodes.all.filter(online).map(one))
@ -12,12 +12,11 @@ define(function () {
return d.flags.gateway
}).map(one))
p.textContent = totalNodes + " Knoten (online), " +
totalClients + " Clients, " +
totalGateways + " Gateways"
stats.textContent = totalNodes + " Knoten (online), " +
totalClients + " Clients, " +
totalGateways + " Gateways"
p.appendChild(document.createElement("br"))
p.appendChild(document.createTextNode("Diese Daten sind von " + d.timestamp.format("LLLL") + "."))
timestamp.textContent = "Diese Daten sind von " + d.timestamp.format("LLLL") + "."
}
self.render = function (el) {
@ -25,8 +24,13 @@ define(function () {
h2.textContent = "Übersicht"
el.appendChild(h2)
p = document.createElement("p")
var p = document.createElement("p")
el.appendChild(p)
stats = document.createTextNode("")
p.appendChild(stats)
p.appendChild(document.createElement("br"))
timestamp = document.createTextNode("")
p.appendChild(timestamp)
}
return self