meshstats.js 1.1 KB

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