-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
152 lines (120 loc) · 4.69 KB
/
index.html
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>ContentFramework Dev</title>
<meta name="viewport" content="width=device-width">
<meta name="description" content="">
<style>
#eventDiv {
position: absolute;
border: 1px black solid;
right: 10px;
top: 10px;
padding: 2px;
background-color: rgba(10, 232, 27, 0.43);
}
#eventDiv > h2 {
margin-top: 0;
text-align: right;
}
</style>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div id="nodeCanvas" class="my_element" style="height: 700px">
</div>
<div id="eventDiv">
</div>
<!-- JavaScript at the bottom for fast page loading -->
<script src="js/libs/jquery-2.1.4.min.js"></script>
<script src="js/libs/vis/vis.min.js"></script>
<script src="js/config.js"></script>
<script src="js/libs/sheetrock-1.0.0.min.js"></script>
<script src="js/importer.js"></script>
<script src="js/libs/graphlib.min.js"></script>
<script src="js/parser.js"></script>
<script>
$("#nodeCanvas").height($(document).height() -16);
function getAttributeFromDot(node, attribute){
var returnValue = undefined;
if (node.hasOwnProperty("comment")) {
var attributeField = node.comment;
var attributeArray = attributeField.split(";");
/* console.log(node);
console.log(attributeArray[0]);
if (node.label === " Tabs") debugger; */
switch (attribute) {
case "level":
returnValue = parseInt(attributeArray[0])
break;
}
}
return returnValue;
}
var gresponse = importer.loadData("https://docs.google.com/spreadsheets/d/1WuL0m_ltFu-Xeo7da2EvOEF-cfRenbhTR6jt1xWLVbM/edit#gid=0", function(data){
var dotdata = parser.parseToDOT(data);
var container = document.getElementById('nodeCanvas');
var data = vis.network.convertDot(dotdata);
if (data.nodeHash === undefined) {
var hashToBuild = {};
var oneNode;
for (var i = 0; i < data.nodes.length; i++) {
oneNode = data.nodes[i];
hashToBuild[oneNode.id] = oneNode;
hashToBuild[oneNode.id]["level"] = getAttributeFromDot(oneNode, "level");
}
data.nodeHash = hashToBuild;
}
var options = {
nodes:{
borderWidth: 1,
borderWidthSelected: undefined,
brokenImage:undefined,
color: {
highlight: {
border: '#049a21',
background: '#40eb61'
},
hover: {
border: '#2B7CE9',
background: '#D2E5FF'
}
},
shape: 'box'
},
layout: {
randomSeed: undefined,
hierarchical: {
enabled:true,
levelSeparation: 150,
direction: 'LR', // UD, DU, LR, RL
sortMethod: 'directed' // hubsize, directed
}
}
}
var network = new vis.Network(container, data, options);
network.on("click", function (params) {
if (typeof params.nodes[0] !== "undefined") {
var selectedNode = data.nodeHash[params.nodes[0]];
var nodeData = ""
for (var property in selectedNode) {
if (selectedNode.hasOwnProperty(property)) {
nodeData += '<p><b>' + property + ':</b> '+selectedNode[property].toString() + "</p>\n";
}
}
document.getElementById('eventDiv').innerHTML = '<h2>[Debug info]</h2>' +
nodeData;
}
});
});
</script>
<!-- endbuild -->
</body>
</html>