summaryrefslogtreecommitdiff
path: root/scripts/buttons.js
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/buttons.js')
-rw-r--r--scripts/buttons.js63
1 files changed, 62 insertions, 1 deletions
diff --git a/scripts/buttons.js b/scripts/buttons.js
index 4b3409d2..e1e39a68 100644
--- a/scripts/buttons.js
+++ b/scripts/buttons.js
@@ -17,9 +17,70 @@ function Colorize(){
$('.td5').click(function(){chosencolor="objective"});
}
-$('#textanalyser').submit(function(){return false;});
+
$('.tutorial').click(function(){});
+var key="#47989379";
+
+
+$('.save').click(function(){
+
+ var jsonsave='{"nodes":[';
+ console.log(nodes);
+ for(var i=0;i<nodes.length;i++){
+ var node=nodes[i];
+ jsonsave+='{"id":"'+node.id+'","type":"'+node.type+'","state":"'+"perm"+'","start":"'+node.start+'","end":"'+node.end+'"}';
+ if(i!==nodes.length-1)jsonsave+=',';
+ }
+ jsonsave+='],"links":[';
+
+ for(var j=0;j<links.length;j++){
+ var link=links[j];
+ jsonsave+='{"source":"'+link.source.id+'","target":"'+link.target.id+'","name":"'+link.name+'"}';
+ if(j!==links.length-1)jsonsave+=",";
+ }
+ jsonsave+=']}';
+ console.log(jsonsave);
+ localStorage.setItem(key, JSON.stringify(jsonsave));
+
+});
+
+$('.load').click(function(){
+ var data = JSON.parse(JSON.parse(localStorage.getItem(key)));
+ console.log(data);
+ for(var i=0; i<data["nodes"].length; i++){
+ var node=data.nodes[i];
+ console.log(data.nodes[i].id);
+ graph.addNodeComplete(node.id,node.type,"perm",node.start,node.end);
+ }
+
+ for(var j=0; j<data["links"].length; j++){
+ var node=data.links[j];
+
+ console.log(data.links[j].name);
+ graph.addLink(fetchNode(link.source),fetchNode(link.target),link.name);
+ }
+
+});
+
+ $('.deliverabletest').click(function(){
+ deliverableTest();
+ });
+
+function fetchNode(id){
+ for( x in nodes){
+ if(x.id===id){
+ console.log("found");
+ return x;
+ }
+ }
+ return null;
+}
+
+
+
+
+