meshstats.js 974 B

12345678910111213141516171819202122232425262728293031323334
  1. define(function () {
  2. return function () {
  3. var self = this
  4. var p
  5. self.setData = function (nodes) {
  6. var totalNodes = sum(nodes.filter(online).map(one))
  7. var totalClients = sum(nodes.filter(online).map( function (d) {
  8. return d.statistics.clients
  9. }))
  10. var totalGateways = sum(nodes.filter(online).filter( function (d) {
  11. return d.flags.gateway
  12. }).map(one))
  13. p.textContent = totalNodes + " Knoten (online), " +
  14. totalClients + " Clients, " +
  15. totalGateways + " Gateways"
  16. p.appendChild(document.createElement("br"))
  17. p.appendChild(document.createTextNode("Diese Daten von " + moment(nodes.timestamp).format("LLLL") + "."))
  18. }
  19. self.render = function (el) {
  20. var h2 = document.createElement("h2")
  21. h2.textContent = "Übersicht"
  22. el.appendChild(h2)
  23. p = document.createElement("p")
  24. el.appendChild(p)
  25. }
  26. return self
  27. }
  28. })