-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
51 lines (46 loc) · 1.27 KB
/
Copy pathindex.html
File metadata and controls
51 lines (46 loc) · 1.27 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>obs - time</title>
<style>
#time {
display: inline;
}
</style>
</head>
<body>
<div id="time">时间加载中...</div>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/date-fns/1.30.1/date_fns.min.js"
integrity="sha512-F+u8eWHrfY8Xw9BLzZ8rG/0wIvs0y+JyRJrXjp3VjtFPylAEEGwKbua5Ip/oiVhaTDaDs4eU2Xtsxjs/9ag2bQ=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<script>
const run = () => {
const t = document.getElementById("time");
function* updateTime() {
while (true) {
yield (t.innerText = window.dateFns.format(
new Date(),
"YYYY-MM-DD HH:mm:ss"
));
}
}
const g = updateTime();
let start = performance.now();
return function next() {
while (performance.now() - start > 1000) {
start = performance.now();
g.next();
}
setTimeout(next);
};
};
run()();
</script>
</body>
</html>