diff options
| author | Alon Levy <alon@pobox.com> | 2014-11-11 17:10:10 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-11-11 19:48:25 +0200 |
| commit | 99e7b4ebf7caeb91f2df538f1b85d9748655269d (patch) | |
| tree | e7ba0496b17884a5382ede1e47726c4434a07009 | |
| parent | cfb104ceac200cb338385c0f20017038050faf02 (diff) | |
graph: add removeLink function (not used yet)
| -rw-r--r-- | scripts/model/graph.js | 20 |
1 files changed, 20 insertions, 0 deletions
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); |
