2015-03-29 17:10:24 +00:00
|
|
|
define(function () {
|
2015-07-08 14:32:26 +00:00
|
|
|
return function (config) {
|
2015-03-25 14:33:36 +00:00
|
|
|
var self = this
|
2015-04-02 17:59:07 +00:00
|
|
|
var stats, timestamp
|
2015-03-25 14:33:36 +00:00
|
|
|
|
2015-03-29 15:48:25 +00:00
|
|
|
self.setData = function (d) {
|
2015-06-04 12:36:59 +00:00
|
|
|
var totalNodes = sum(d.nodes.all.map(one))
|
|
|
|
var totalOnlineNodes = sum(d.nodes.all.filter(online).map(one))
|
2015-03-29 15:48:25 +00:00
|
|
|
var totalClients = sum(d.nodes.all.filter(online).map( function (d) {
|
2015-03-25 14:33:36 +00:00
|
|
|
return d.statistics.clients
|
|
|
|
}))
|
2015-03-29 15:48:25 +00:00
|
|
|
var totalGateways = sum(d.nodes.all.filter(online).filter( function (d) {
|
2015-03-25 14:33:36 +00:00
|
|
|
return d.flags.gateway
|
|
|
|
}).map(one))
|
|
|
|
|
2015-06-04 12:36:59 +00:00
|
|
|
stats.textContent = "Insgesamt " + totalNodes + " Knoten, " +
|
|
|
|
"davon " + totalOnlineNodes + " online, " +
|
2015-04-02 17:59:07 +00:00
|
|
|
totalClients + " Clients, " +
|
|
|
|
totalGateways + " Gateways"
|
2015-03-25 14:33:36 +00:00
|
|
|
|
2015-04-02 17:59:07 +00:00
|
|
|
timestamp.textContent = "Diese Daten sind von " + d.timestamp.format("LLLL") + "."
|
2015-03-25 14:33:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
self.render = function (el) {
|
|
|
|
var h2 = document.createElement("h2")
|
2015-07-08 14:32:26 +00:00
|
|
|
h2.textContent = config.siteName
|
2015-03-25 14:33:36 +00:00
|
|
|
el.appendChild(h2)
|
|
|
|
|
2015-04-02 17:59:07 +00:00
|
|
|
var p = document.createElement("p")
|
2015-03-25 14:33:36 +00:00
|
|
|
el.appendChild(p)
|
2015-04-02 17:59:07 +00:00
|
|
|
stats = document.createTextNode("")
|
|
|
|
p.appendChild(stats)
|
|
|
|
p.appendChild(document.createElement("br"))
|
|
|
|
timestamp = document.createTextNode("")
|
|
|
|
p.appendChild(timestamp)
|
2015-03-25 14:33:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
})
|