diff --git a/html/force.js b/html/force.js index a6b2f9e..90f7c9d 100644 --- a/html/force.js +++ b/html/force.js @@ -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()