From e762be0be3b94ae221b85e4073043434e75331e4 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Thu, 14 Feb 2013 21:58:55 -0500 Subject: [PATCH] implemented clear canvas too... sort of --- app/assets/javascripts/Jit/find.js | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/Jit/find.js b/app/assets/javascripts/Jit/find.js index e17a3073..01cbb242 100644 --- a/app/assets/javascripts/Jit/find.js +++ b/app/assets/javascripts/Jit/find.js @@ -163,14 +163,34 @@ function onCanvasSearch(name,mapID,mapperID) { }); } - function clearCanvas() { - Mconsole.graph.eachNode( function(n) { Mconsole.graph.removeNode(n.id); Mconsole.labels.disposeLabel(n.id); }); - Mconsole.plot(); + Mconsole.graph.eachNode(function(n) { + Mconsole.graph.removeNode(n.id); + Mconsole.labels.disposeLabel(n.id); + }); + Mconsole.plot(); +} + +function clearCanvasExceptRoot() { + var ids = new Array(); + Mconsole.graph.eachNode(function(n) { + ids.push(n.id); + }); + + var root = Mconsole.graph.nodes[Mconsole.root]; + ids.forEach(function(id, index) { + if (id != root.id) { + Mconsole.graph.removeNode(id); + //OK I feel bad about this, but not too bad + //TODO: this leaves labels hidden on the map + Mconsole.labels.hideLabel(id); + } + }); + fetchRelatives(root); //also runs Mconsole.plot() } function clearFoundData() { - Mconsole.graph.eachNode( function(n) { + Mconsole.graph.eachNode( function(n) { if (n.getData('inCommons') === true) { Mconsole.graph.removeNode(n.id); Mconsole.labels.disposeLabel(n.id); @@ -557,4 +577,4 @@ function closeFind() { width: '45px', height: '32px' }, 100); -} \ No newline at end of file +}