diff options
| author | Alon Levy <alon@pobox.com> | 2014-08-19 16:53:16 +0300 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-08-19 16:53:16 +0300 |
| commit | a7169d96cd230aefebc29655331504e5c8a91019 (patch) | |
| tree | 5405af8ba0dcdab9b27c3333a1c44e2746438faf | |
| parent | 5ba7262ffbb3dd52f07d01aad5295c514b2cdf30 (diff) | |
add editNewNode helper
| -rw-r--r-- | scripts/rhizicore.js | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/scripts/rhizicore.js b/scripts/rhizicore.js index d0ba46dc..595b733d 100644 --- a/scripts/rhizicore.js +++ b/scripts/rhizicore.js @@ -28,6 +28,19 @@ function myGraph(el) { update(); } + function makeNewNode(spec) { + return { + 'id': spec.id, + 'text': spec.text, + 'type': spec.type, + 'state': spec.state, + 'start': spec.start, + 'end': spec.end, + 'status': spec.status, + 'url': spec.url + }; + } + ///FUNCTIONS this.addNode = function(id, type, state) { var start = 0, @@ -40,7 +53,7 @@ function myGraph(el) { console.log('addNode: node of same id exists: ' + id); //graph.editState(id, null, "temp"); } else { - var new_node = { + var new_node = makeNewNode({ "id": id, "text": text, "type": type, @@ -48,7 +61,7 @@ function myGraph(el) { "start": start, "end": end, "status": status - }; + }); nodes.push(new_node); if (this.history !== undefined) { this.history.record_nodes([new_node]); @@ -64,7 +77,7 @@ function myGraph(el) { if (node !== undefined) { graph.editState(id, null, "temp"); } else { - nodes.push({ + nodes.push(makeNewNode({ "id": id, "text": text, "type": type, @@ -72,7 +85,7 @@ function myGraph(el) { "start": start, "end": end, "status": status - }); + })); } |
