summaryrefslogtreecommitdiff
path: root/src/model/graph.js
diff options
context:
space:
mode:
authorLV-426 <lv-426@taproot.org.il>2014-11-19 16:04:31 +0200
committerAlon Levy <alon@pobox.com>2014-11-19 23:24:28 +0200
commitfd3897dbb6d926dbbbce08d2a6c98fa7e0641868 (patch)
tree7c2a84a77a130d8afddd02e48f8ca76dc1b0b661 /src/model/graph.js
parentce1566f9fff4a2a85ff077da9912f5cbfaae9936 (diff)
addLink refactoring - call create_link__set_random_id()
Diffstat (limited to 'src/model/graph.js')
-rw-r--r--src/model/graph.js30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/model/graph.js b/src/model/graph.js
index 32306708..4834a172 100644
--- a/src/model/graph.js
+++ b/src/model/graph.js
@@ -245,34 +245,34 @@ function Graph() {
return {graph_same: true, old_name: changed_nodes.a_b, new_name: changed_nodes.b_a};
}
- this.addLinkByName = function(sourceName, targetName, name, state, drop_conjugator_links) {
- var source = findNodeByName(sourceName, null),
- target = findNodeByName(targetName, null),
- sourceId = source ? source.id : null,
- targetId = target ? target.id : null;
+ this.addLinkByName = function(src_name, dst_name, name, state, drop_conjugator_links) {
+ var src = findNodeByName(src_name, null),
+ dst = findNodeByName(dst_name, null),
+ src_id = src ? src.id : null,
+ dst_id = dst ? dst.id : null;
- if (sourceId === null || targetId === null) {
- console.log('error: link of missing nodes: ' + sourceName + ' (' + sourceId + ') -> '
- + targetName + ' (' + targetId + ')');
+ if (src_id === null || dst_id === null) {
+ console.log('error: link of missing nodes: ' + src_name + ' (' + src_id + ') -> '
+ + dst_name + ' (' + dst_id + ')');
return;
}
- this.addLink(sourceId, targetId, name, state, drop_conjugator_links);
+ this.addLink(src_id, dst_id, name, state, drop_conjugator_links);
}
- this.addLink = function(sourceId, targetId, name, state, drop_conjugator_links) {
- var sourceNode = findNode(sourceId, null);
- var targetNode = findNode(targetId, null);
- var found = findLink(sourceId,targetId,name);
+ this.addLink = function(src_id, dst_id, name, state, drop_conjugator_links) {
+ var src = findNode(src_id, null);
+ var dst = findNode(dst_id, null);
+ var found = findLink(src_id,dst_id,name);
if (drop_conjugator_links && name && (name.replace(/ /g,"") === "and")) {
state = "temp";
}
- if (undefined === sourceNode || undefined === targetNode) {
+ if (undefined === src || undefined === dst) {
console.log('addLink: undefined src / dst');
return;
}
if (!found) {
- var link = model_core.create_link__set_random_id(sourceNode, targetNode, { name: name, state: state });
+ var link = model_core.create_link__set_random_id(src, dst, { name: name, state: state });
links.push(link);
signal.signal(consts.APPLIED_GRAPH_DIFF, [{links: {add: [link]}}]);
} else {