-
Notifications
You must be signed in to change notification settings - Fork 0
/
index
79 lines (68 loc) · 2.15 KB
/
index
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
<html>
<head>
<title>MathCanvas</title>
<link rel="stylesheet" type="text/css" href="./marthy/marthy.css">
<script type="text/javascript" src="./marthy/marthy.js"></script>
<style>
.tools {
position: absolute;
bottom: 5px;
left: 0;
right: 0;
text-align: center;
pointer-events: none;
}
.tools .tool {
display: inline-block;
width: 48px;
height: 48px;
margin: 5px;
cursor: pointer;
pointer-events: all;
}
.tool.hand { background-image: url('./marthy/img/hand.svg') }
.tool.point { background-image: url('./marthy/img/point.svg') }
.tool.segment { background-image: url('./marthy/img/segment.svg') }
.tool.circle { background-image: url('./marthy/img/circle.svg') }
.tool:hover {
background-position: 0 96px;
}
.tool.active, .tool.active:hover {
background-position: 0 48px;
cursor: default;
}
</style>
</head>
<body>
<div id="main"></div>
<div id="ui">
<div class="tools">
<div data-tool="hand" class="tool hand"></div>
<div data-tool="point" class="tool point active"></div>
<div data-tool="segment" class="tool segment"></div>
<div data-tool="circle" class="tool circle"></div>
</div>
</div>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function(event) {
let opts = {}
let marthy = new Marthy(document.getElementById('main'), opts)
// Handle some code here (To generate personal UI)
let tools = Array.prototype.slice.call(document.getElementsByClassName('tool'))
tools.forEach(tool => {
tool.onclick = function() {
if (marthy.setTool(tool.getAttribute('data-tool'))) {
// Un-active all
let actives = Array.prototype.slice.call(document.getElementsByClassName('tool active'))
actives.forEach(active => {
active.classList.remove('active')
})
// Active this
this.classList.add('active')
}
}
})
});
</script>
</body>
</html>