From a7169d96cd230aefebc29655331504e5c8a91019 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Tue, 19 Aug 2014 16:53:16 +0300 Subject: add editNewNode helper --- scripts/rhizicore.js | 21 +++++++++++++++++---- 1 file 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 - }); + })); } -- cgit v1.3.1