1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
"use strict"
$('.tutorial').click(function(){});
var key="#47989379";
$('.save').click(function(){
var d = {"nodes":[], "links":[]};
console.log(nodes);
for(var i = 0 ; i < nodes.length ; i++){
var node = nodes[i];
d['nodes'].push({
"id":node.id,
"type":node.type,
"state":"perm",
"start":node.start,
"end":node.end,
"status": node.status
});
}
for(var j=0 ; j < links.length ; j++){
var link = links[j];
d['links'].push({
"source":link.source.id,
"target":link.target.id,
"name":link.name
});
}
console.log(JSON.stringify(d));
localStorage.setItem(key, JSON.stringify(d));
});
$('.load').click(function(){
var acceptLoad=true;
if (nodes.length>0){
acceptLoad = confirm('All unsaved changes will be deleted, are you sure?');
}
if(acceptLoad){
links=[];
nodes=[];
var data = JSON.parse(localStorage.getItem(key));
console.log(data);
for(var i=0; i<data["nodes"].length; i++){
var node=data.nodes[i];
graph.addNodeComplete(node.id,node.type,"perm",new Date(node.start),new Date(node.end),node.status);
}
for(var j=0; j<data["links"].length; j++){
var link=data.links[j];
graph.addLink(link.source,link.target,link.name,"perm");
}
graph.recenterZoom();
graph.update();
}
});
$('.deliverabletest').click(function(){
deliverableTest();
});
function fetchNode(id){
for( x in nodes){
if(x.id===id){
console.log("found");
return x;
}
}
return null;
}
|