fix counting of vpn links

This commit is contained in:
Nils Schneider 2012-06-12 16:16:37 +02:00
parent 8e9a08d9e1
commit a35a28cafe

View file

@ -277,29 +277,17 @@ function reload() {
if (typeof d.target == "number") d.target = json.nodes[d.target];
})
// count uplinks
// count vpn links
json.nodes.forEach(function(d) {
d.uplinks = undefined
d.vpns = 0
})
json.links.forEach(function(d) {
var node, other
if (d.source.flags.vpn) {
node = d.target
other = d.source
}
if (d.target.flags.vpn) {
node = d.source
other = d.target
}
if (node) {
if (node.uplinks === undefined)
node.uplinks = 0
node.uplinks++
if (d.type == "vpn") {
d.source.vpns++
d.target.vpns++
}
})
@ -376,9 +364,6 @@ function update() {
if (!visible.vpn && d.flags.vpn)
return false
if (!visible.vpn && d.flags.client && d.uplinks)
return false
if (!visible.clients && d.flags.client)
return false
@ -446,10 +431,7 @@ function update() {
if (!visible.vpn) {
var uplink_info = node.filter(function (d) {
if (d.uplinks !== undefined)
return d.uplinks > 0
else
return false
return d.vpns > 0
})
.append("g")
.attr("class", "uplinks")
@ -463,7 +445,7 @@ function update() {
uplink_info.append("text")
.attr("text-anchor", "middle")
.attr("y", 3 - 20)
.text(function (d) {return d.uplinks})
.text(function (d) {return d.vpns})
}
node.exit().remove()