-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
143 lines (129 loc) · 3.31 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Just Time</title>
<meta name="description" content="See current time in HH:MM:SS format." />
<link rel="shortcut icon" href="icon/favicon.svg" />
<link rel="manifest" href="webmanifest.json" />
<meta name="seznam-wmt" content="t1fNoyYS5yrVtkmk9Wv3J6pFCRGTzsGw" />
<meta
name="google-site-verification"
content="xKuZK5r0mbfP_kagMbILsy5Vw8sYY1pQ7QZSTYHHTz0"
/>
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta property="og:image" content="https://just-time.eu/og-image.jpg" />
<meta name="color-scheme" content="light dark" />
<meta
name="theme-color"
media="(prefers-color-scheme: light)"
content="white"
/>
<meta
name="theme-color"
media="(prefers-color-scheme: dark)"
content="black"
/>
<link
href="https://fonts.googleapis.com/css2?family=Open+Sans&display=block&text=0123456789:"
rel="stylesheet"
/>
<style>
body {
color: black;
background-color: white;
font-size: 20vw;
}
@media (min-aspect-ratio: 12/5) {
body {
font-size: 48vh;
}
}
@media (prefers-color-scheme: dark) {
body {
color: white;
background-color: black;
}
}
.time {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
justify-content: center;
align-items: center;
font-variant-numeric: tabular-nums;
font-family: 'Open Sans', sans-serif;
font-size: 1em;
}
.time.view-hideSeconds {
font-size: 1.5em;
}
</style>
</head>
<body>
<time class="time">…</time>
<script>
;(function () {
const $time = document.querySelector('.time')
const hideSeconds =
new URLSearchParams(window.location.search).get('hideSeconds') !==
null
if (hideSeconds) {
$time.classList.add('view-hideSeconds')
}
function twoDigits(input) {
return input.toString().padStart(2, '0')
}
function updateTime() {
const isUserSelecting = !document.getSelection().isCollapsed
if (isUserSelecting) {
return
}
const now = new Date()
$time.innerText = `${twoDigits(now.getHours())}:${twoDigits(
now.getMinutes(),
)}${hideSeconds ? '' : `:${twoDigits(now.getSeconds())}`}`
}
function loop() {
updateTime()
const now = new Date()
const nextTick = Math.max(1, 1000 - (now.getTime() % 1000))
setTimeout(loop, nextTick)
}
loop()
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('serviceWorker.js')
}
async function runWakeLock() {
let wakeLock = null
async function requestWakeLock() {
try {
wakeLock = await navigator.wakeLock.request('screen')
} catch (error) {
console.error(error)
}
if (wakeLock) {
wakeLock.addEventListener('release', () => {
wakeLock = null
})
}
}
await requestWakeLock()
document.addEventListener('visibilitychange', async () => {
if (wakeLock === null && document.visibilityState === 'visible') {
await requestWakeLock()
}
})
}
if ('wakeLock' in navigator) {
runWakeLock()
}
})()
</script>
</body>
</html>