-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
41 lines (36 loc) · 1.29 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
<!DOCTYPE html>
<html>
<head>
<title>Path of DnD</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<object data="graph.svg" type="image/svg+xml" id="graph" width="900" height="900" ></object>
<div class = "footer">
<p>You have: <br><span id="counter"></span> Nodes</p>
</div>
<script type="text/javascript">
var graph = document.getElementById("graph");
var numNodes = 0;
document.getElementById("counter").innerHTML = numNodes;
graph.onload = function(){
var svgDoc = graph.contentDocument;
console.log(svgDoc);
allNodes = svgDoc.querySelectorAll('g.node');
console.log(allNodes);
allNodes.forEach(function(node) {
node.addEventListener("click", function() {
if(node.classList.contains("selected")){
numNodes--;
node.classList.remove("selected");
}else{
numNodes++;
node.classList.add("selected");
}
document.getElementById("counter").innerHTML = numNodes;
});
});
}
</script>
</body>
</html>