summaryrefslogtreecommitdiff
path: root/scripts/buttons.js
diff options
context:
space:
mode:
authorOwen <despito@MacBook-Pro-de-Despito.local>2014-07-14 19:06:42 +0300
committerOwen <despito@MacBook-Pro-de-Despito.local>2014-07-14 19:06:42 +0300
commit335af0bbf19ef4e6454233c9b4d212ee5aaa9d0d (patch)
tree7433f0c265acf863db5a6615eab6f601c94e0dad /scripts/buttons.js
parent2d98eaaf727834c128fdd2513d43d677d97fe8d7 (diff)
Target and adjacent nodes are highlighted when clicked
Background click remove editing boxes and highlights Deliverables test button adds 140 random tasks and dates Links between nodes have two colors: blue and green for dependencies
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;
+}
+
+
+
+
+