From 8e518a3a85a45744604a5790643e0735e186bfde Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Thu, 13 Sep 2012 03:40:14 +0200 Subject: [PATCH] add refresh button --- html/force.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/html/force.js b/html/force.js index 50e7f68..1d9b0ec 100644 --- a/html/force.js +++ b/html/force.js @@ -183,19 +183,31 @@ function highlight(b) {   } } +function goto_node(d) { + show_node_info(d) +} + function show_node_info(d) { d3.selectAll("#nodeinfo").remove() nodeinfo = d3.select("#chart") .append("div") .attr("id", "nodeinfo") + nodeinfo.append("button") .attr("class", "close") .text("x") - .on("click", function(d) { + .on("click", function() { nodeinfo.remove() }) + nodeinfo.append("button") + .attr("class", "refresh") + .text("refresh") + .on("click", function() { + goto_node(d) + }) + nodeinfo.append("h1") .text(d.name + " / " + d.id) @@ -210,7 +222,7 @@ function show_node_info(d) { .data(d.vpns) .enter().append("li") .append("a") - .on("click", show_node_info) + .on("click", goto_node) .attr("href", "#") .text(function(d) { return d.name || d.macs @@ -558,7 +570,7 @@ function update() { .attr("class", "node") .on("mouseover", highlight(true)) .on("mouseout", highlight(false)) - .on("click", show_node_info) + .on("click", goto_node) .call(node_drag) nodeEnter.append("ellipse")