-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
81 lines (68 loc) · 1.9 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
<html>
<head>
<meta charset="UTF-8" />
<title>Hexklokk</title>
</head>
<body id="body">
<p id="clock"></p>
<button id="button" type="button" onclick="flipRadix()">hex</button>
<input id="number" type="number" disabled />
<script>
const body = document.getElementById("body");
const clock = document.getElementById("clock");
const number = document.getElementById("number");
const button = document.getElementById("button");
number.value = 10;
button.textContent = "hex";
const flipRadix = () => {
if (number.value == 10) {
number.value = 16;
button.textContent = "dec";
} else {
number.value = 10;
button.textContent = "hex";
}
};
const format = (date, radix) =>
[date.getHours(), date.getMinutes(), date.getSeconds()]
.map((n) => n.toString(radix).padStart(2, "0"))
.join("");
const update = () => {
const hexes = "#" + format(new Date(), number.value);
clock.textContent = hexes;
body.style.backgroundColor = hexes;
window.requestAnimationFrame(update);
};
window.requestAnimationFrame(update);
</script>
<style>
body {
height: 100vh;
margin: 0;
position: relative;
}
p {
margin: 0;
position: absolute;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
color: white;
font-size: 6em;
font-family: monospace;
}
/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
/* Firefox */
input[type="number"] {
-moz-appearance: textfield;
width: 3ch;
}
</style>
</body>
</html>