Skip to content
Snippets Groups Projects
Select Git revision
  • 2b19266a7dce39d29f9916777349155113b51e51
  • experimental default protected
  • v2023.2.5-ffs
  • nrb/ex400-remove-wps
  • nrb/airmax-test
  • v2023.2.4-ffs
  • nrb/ar9344-reset-sequence
  • autinerd/experimental-openwrt-24.10
  • v2023.2.3-ffs
  • v2023.2.2-ffs
  • v2023.2-ffs
  • v2023.1-ffs
  • v2022.1.4-ffs
  • feature/addMikrotikwAP
  • v2022.1.3-ffs
  • v2021.1.2-ffs
  • v2022.1.1-ffs
  • master protected
  • v2021.1.1-ffs
  • nrb/gluon-master-cpe510
  • v2021.1-ffs
  • experimental-2025-07-26
  • experimental-2025-07-26-base
  • experimental-2025-07-24
  • experimental-2025-07-24-base
  • experimental-2025-07-22
  • experimental-2025-07-22-base
  • experimental-2025-07-21
  • experimental-2025-07-21-base
  • experimental-2025-07-20
  • experimental-2025-07-20-base
  • experimental-2025-07-19
  • experimental-2025-07-19-base
  • experimental-2025-07-17
  • experimental-2025-07-17-base
  • experimental-2025-07-12
  • experimental-2025-07-12-base
  • experimental-2025-07-04
  • experimental-2025-07-04-base
  • experimental-2025-07-01
  • experimental-2025-07-01-base
41 results

features.sh

Blame
  • main.js 2.93 KiB
    define(["config", "moment", "router", "leaflet", "gui", "numeral"],
    function (config, moment, Router, L, GUI, numeral) {
      return function () {
        function handleData(data) {
          var nodes = Object.keys(data[0].nodes).map(function (key) { return data[0].nodes[key] })
    
          nodes = nodes.filter( function (d) {
            return "firstseen" in d && "lastseen" in d
          })
    
          nodes.forEach( function(node) {
            node.firstseen = moment.utc(node.firstseen).local()
            node.lastseen = moment.utc(node.lastseen).local()
          })
    
          var now = moment()
          var age = moment(now).subtract(14, "days")
    
          var newnodes = limit("firstseen", age, sortByKey("firstseen", nodes).filter(online))
          var lostnodes = limit("lastseen", age, sortByKey("lastseen", nodes).filter(offline))
    
          var graph = data[1].batadv
          var graphnodes = data[0].nodes
    
          graph.nodes.forEach( function (d) {
            if (d.node_id in graphnodes)
              d.node = graphnodes[d.node_id]
          })
    
          graph.links.forEach( function (d) {
            if (graph.nodes[d.source].node)
              d.source = graph.nodes[d.source]
            else
              d.source = undefined
    
            if (graph.nodes[d.target].node)
              d.target = graph.nodes[d.target]
            else
              d.target = undefined
          })
    
          var links = graph.links.filter( function (d) {
            return d.source !== undefined && d.target !== undefined
          })
    
          links.forEach( function (d) {
            if (!("location" in d.source.node.nodeinfo && "location" in d.target.node.nodeinfo))
              return
    
            d.latlngs = []
            d.latlngs.push(L.latLng(d.source.node.nodeinfo.location.latitude, d.source.node.nodeinfo.location.longitude))
            d.latlngs.push(L.latLng(d.target.node.nodeinfo.location.latitude, d.target.node.nodeinfo.location.longitude))
    
            d.distance = d.latlngs[0].distanceTo(d.latlngs[1])
          })
    
          nodes.forEach( function (d) {
            d.neighbours = []
          })
    
          links.forEach( function (d) {
            d.source.node.neighbours.push({ node: d.target.node, link: d })
            d.target.node.neighbours.push({ node: d.source.node, link: d })
          })
    
          return { now: now,
                   timestamp: moment.utc(data[0].timestamp).local(),
                   nodes: {
                     all: nodes,
                     new: newnodes,
                     lost: lostnodes
                   },
                   graph: {
                     links: links,
                     nodes: graph.nodes
                   }
                 }
        }
    
        numeral.language("de")
        moment.locale("de")
    
        var router = new Router()
    
        var urls = [ config.dataPath + "nodes.json",
                     config.dataPath + "graph.json"
                   ]
    
        Promise.all(urls.map(getJSON))
          .then(handleData)
          .then(function (d) {
            var gui = new GUI(config, router)
            gui.setData(d)
            router.setData(d)
            router.start()
          })
          .catch(function (e) {
            console.log(e)
          })
      }
    })