diff options
| author | Alon Levy <alon@pobox.com> | 2014-10-26 23:37:31 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-10-26 23:37:31 +0200 |
| commit | 269b643f4aad442302fe4ba17627726fb732af0c (patch) | |
| tree | 7a3443b6b99b00733fb7dcba9e020a760f9d3726 /scripts/rhizicore.js | |
| parent | b3f96efb33d7fc99500147d336ead1536b6b24e9 (diff) | |
history switch to events; using a single GRAPH_DIFF action. todo - replay; zoom in/out; clicks on nodes/edges
Diffstat (limited to 'scripts/rhizicore.js')
| -rw-r--r-- | scripts/rhizicore.js | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/scripts/rhizicore.js b/scripts/rhizicore.js index 1b4bcbb3..de823882 100644 --- a/scripts/rhizicore.js +++ b/scripts/rhizicore.js @@ -40,8 +40,9 @@ function myGraph(el) { start:0, end:0, status:"unknown"}); - if (new_node && this.history !== undefined) { - this.history.record_nodes([new_node]); + if (new_node) { + signal.signal(consts.APPLIED_GRAPH_DIFF, [{ + nodes: {add: [new_node]}}]); } } @@ -79,9 +80,7 @@ function myGraph(el) { if (index !== undefined) { nodes.splice(index, 1); } - if (this.history != undefined) { - this.history.record_nodes_removal([id]); - } + signal.signal(consts.APPLIED_GRAPH_DIFF, [{nodes: {removed: [id]}}]); } this.removeNodes = function(state) { @@ -99,8 +98,8 @@ function myGraph(el) { nodes.splice(index, 1); } } - if (ns.length > 0 && this.history !== undefined) { - this.history.record_nodes_removal(ns.map(function(n) { return n.id; })); + if (ns.length > 0) { + signal.signal(consts.APPLIED_GRAPH_DIFF, [{nodes: {removed: ns.map(function(n) { return n.id; })}}]); } } @@ -260,7 +259,7 @@ function myGraph(el) { "state": state }; links.push(link); - signal.signal(consts.RECORD_LINKS, [[link]]); + signal.signal(consts.APPLIED_GRAPH_DIFF, [{links: {add: [link]}}]); } else { found.name = name; found.state = state; @@ -1043,9 +1042,7 @@ function AddedUnique(newnode) { $('#editform').keypress(function(e) { - if (graph.history !== undefined) { - graph.history.record_keystrokes(history.KEYSTROKE_WHERE_EDIT_NODE, [e.which]); - } + signal.signal(consts.KEYSTROKES, [{where: consts.KEYSTROKE_WHERE_EDIT_NODE, keys: [e.which]}]); if (e.which == 13) { $('.editinfo').css('top', -100); $('.editinfo').css('left', 0); |
