-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.html
95 lines (83 loc) · 2.7 KB
/
main.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
<!DOCTYPE html>
<html
window-frame="transparent"
window-width="280dip"
window-height="280dip"
theme="dark">
<head>
<meta charset="utf-8">
<title>Clock</title>
<meta name="application-name" content="Clock">
<style>
body {
overflow: hidden;
min-height: 100%;
}
html {
height: 100%;
}
#clockface {
height: 96vh;
}
/* Window decoration */
html:theme(light) {
background: transparent;
}
html:theme(dark) {
background: transparent;
}
</style>
<script type="text/javascript">
// Set to be always top most
Window.this.isTopmost = true;
// Clock code
document.addEventListener('DOMContentLoaded', function () {
setInterval(tick, 50);
}, false);
var tick = function () {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var time = Math.min(60000, 1.025 * (1000 * now.getSeconds() + now.getMilliseconds()));
var seconds = Math.floor(time / 1000);
var millis = time % 1000;
rotate('hourHand', hours * 30 + minutes * 0.5);
rotate('minuteHand', minutes * 6);
rotate('secondHand', 6 * seconds + 3 * (1 + Math.cos(Math.PI + Math.PI * (0.001 * millis))));
};
function rotate(id, angle) {
var element = document.getElementById(id);
if (element) {
element.setAttribute('transform', 'rotate(' + angle + ', 100, 100)');
}
}
</script>
</head>
<body>
<div id="clockface" role="window-caption">
<svg xmlns="http://www.w3.org/2000/svg" style="background-color: transparent" width="100%" height="100%"
viewBox="0 0 200 200" >
<g id="faceplate">
<circle id="faceplateCircle" cx="100" cy="100" r="98"
style="fill: rgb(179, 179, 179); stroke: black; stroke-width: 3.0" />
</g>
<g id="faceplate">
<circle id="faceplateInnerCircle" cx="100" cy="100" r="70"
style="fill: black; stroke: black; stroke-width: 3.0" />
</g>
<g id="hourHand">
<line x1="100" y1="100" x2="100" y2="48" style="stroke: white; stroke-width: 5" />
</g>
<g id="minuteHand">
<line x1="100" y1="100" x2="100" y2="33" style="stroke: white; stroke-width: 3" />
</g>
<g id="secondHand">
<line x1="100" y1="100" x2="100" y2="7" style="stroke: rgb(255, 140, 0); stroke-width: 2" />
</g>
<g id="axisCover">
<circle id="axisCoverCircle" cx="100" cy="100" r="4" style="fill: black; stroke: white; stroke-width: 2.0" />
</g>
</svg>
</div>
</body>
</html>