main: filter duplicate nodes from different data sources

* add jquery

* filter duplicate nodes by online state

* remove old stuff

* remove debug output

* remove curly braces
This commit is contained in:
Johannes Rudolph 2016-06-05 22:55:26 +02:00 committed by PetaByteBoy // Milan Pässler
parent 2da97bca16
commit 2bbdd1e077

View file

@ -4,12 +4,14 @@ function (moment, Router, L, GUI, numeral) {
function handleData(data) { function handleData(data) {
var dataNodes = {} var dataNodes = {}
dataNodes.nodes = [] dataNodes.nodes = []
dataNodes.nodeIds = []
var dataGraph = {} var dataGraph = {}
dataGraph.batadv = {} dataGraph.batadv = {}
dataGraph.batadv.nodes = [] dataGraph.batadv.nodes = []
dataGraph.batadv.links = [] dataGraph.batadv.links = []
function rearrangeLinks(d) { function rearrangeLinks(d) {
d.source += dataGraph.batadv.nodes.length d.source += dataGraph.batadv.nodes.length
d.target += dataGraph.batadv.nodes.length d.target += dataGraph.batadv.nodes.length
@ -32,11 +34,22 @@ function (moment, Router, L, GUI, numeral) {
vererr = "Unsupported nodes version: " + data[i].version vererr = "Unsupported nodes version: " + data[i].version
console.log(vererr) //silent fail console.log(vererr) //silent fail
} else { } else {
dataNodes.nodes = dataNodes.nodes.concat(data[i].nodes) data[i].nodes.forEach(fillData)
dataNodes.timestamp = data[i].timestamp dataNodes.timestamp = data[i].timestamp
} }
} }
function fillData (node) {
var position = dataNodes.nodeIds.indexOf(node.nodeinfo.node_id)
if(position === -1){
dataNodes.nodes.push(node)
dataNodes.nodeIds.push(node.nodeinfo.node_id)
}
else
if(node.flags.online === true)
dataNodes.nodes[position] = node
}
var nodes = dataNodes.nodes.filter( function (d) { var nodes = dataNodes.nodes.filter( function (d) {
return "firstseen" in d && "lastseen" in d return "firstseen" in d && "lastseen" in d
}) })