From 99e7b4ebf7caeb91f2df538f1b85d9748655269d Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Tue, 11 Nov 2014 17:10:10 +0200 Subject: graph: add removeLink function (not used yet) --- scripts/model/graph.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'scripts/model') diff --git a/scripts/model/graph.js b/scripts/model/graph.js index 4b4b0069..b41c6bb6 100644 --- a/scripts/model/graph.js +++ b/scripts/model/graph.js @@ -385,6 +385,26 @@ function Graph(el) { } } + this.removeLink = function(link) { + var link, + i; + + for ( i = 0 ; i < links.length; ++i ) { + if (link.id !== undefined) { + if (link.id === links[i].id) { + links.splice(i, 1); + return; + } + } else { + if (link.sourceId === links[i].sourceId && link.targetId === links[i].targetId) { + links.splice(i, 1); + return; + } + } + } + console.log('bug: attempt to remove non existant link'); + } + this.removeLinks = function(state) { var id = null; var ls = findLinks(state); -- cgit v1.3.1