-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
49 lines (40 loc) · 1.08 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
<!DOCTYPE html>
<html>
<head>
<style>
body {
text-align: center;
}
#clock {
margin: 10px auto auto auto;
width: 500px;
height: 500px;
resize: both;
overflow: hidden;
border: 1px solid lightgray;
}
</style>
</head>
<body>
Round: <input id="faceType" type="checkbox" />
<div id="clock"></div>
<script src="js/clock.js"></script>
<script>
const clockDiv = document.getElementById("clock")
var round = false
const clock = new Clock(clockDiv, clockDiv.offsetWidth, clockDiv.offsetHeight, round)
const checkbox = document.getElementById('faceType')
checkbox.addEventListener('change', event => {
round = event.currentTarget.checked
clock.redraw(clockDiv.offsetWidth, clockDiv.offsetHeight, round)
})
const observer = new ResizeObserver(entries => {
entries.forEach(entry => {
clock.redraw(entry.contentRect.width, entry.contentRect.height, round)
});
});
observer.observe(clockDiv);
setInterval(() => clock.setTime(new Date()), 20)
</script>
</body>
</html>