summaryrefslogtreecommitdiff
path: root/scripts/model
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2014-11-11 17:10:10 +0200
committerAlon Levy <alon@pobox.com>2014-11-11 19:48:25 +0200
commit99e7b4ebf7caeb91f2df538f1b85d9748655269d (patch)
treee7ba0496b17884a5382ede1e47726c4434a07009 /scripts/model
parentcfb104ceac200cb338385c0f20017038050faf02 (diff)
graph: add removeLink function (not used yet)
Diffstat (limited to 'scripts/model')
-rw-r--r--scripts/model/graph.js20
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);