From 50c5955564be41a567dee79d688807f7f575b1f2 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Sat, 21 Mar 2015 10:40:58 +0100 Subject: [PATCH] history: add simple mesh statistics --- history.html | 4 ++++ history.js | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/history.html b/history.html index e956de2..2172a5c 100644 --- a/history.html +++ b/history.html @@ -176,6 +176,10 @@ Funktioniert nur in wirklich modernen Browsern.

+

Meshdaten

+

+

+

Neue Knoten

diff --git a/history.js b/history.js index 48ba062..940eb66 100644 --- a/history.js +++ b/history.js @@ -158,6 +158,8 @@ function handle_data(config, map) { addToList(document.getElementById("newnodes"), config.showContact, "firstseen", markers, newnodes) addToList(document.getElementById("lostnodes"), config.showContact, "lastseen", markers, lostnodes) addToLongLinksList(document.getElementById("longlinks"), markers, longlinks) + + showMeshstats(document.getElementById("meshstats"), nodes) } } @@ -336,3 +338,33 @@ function addToList(el, showContact, tf, markers, list) { el.appendChild(row) }) } + +function sum(a) { + return a.reduce( function (a, b) { + return a + b + }, 0) +} + +function one() { + return 1 +} + +function showMeshstats(el, nodes) { + var totalNodes = sum(nodes.filter(online).map(one)) + + var totalClients = sum(nodes.filter(online).map( function (d) { + return d.statistics.clients + })) + + var totalGateways = sum(nodes.filter(online).filter( function (d) { + return d.flags.gateway + }).map(one)) + + el.textContent = totalNodes + " Knoten (online), " + + totalClients + " Clients, " + + totalGateways + " Gateways" +} + +function showNodeinfo(d) { + var object = document.getElementById("nodeinfo") +}