blob: 10d8fe1f45d42354b3101371f1c1489820366b38 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
hljs.initHighlightingOnLoad();
const listBg = document.querySelector('.list-bg');
if (listBg) {
const halfAnHour = 1000 * 60 * 30;
function setListBgStyle() {
const now = new Date();
const time = now.getHours() + now.getMinutes() / 60;
let opacity = Math.abs(time - 14);
opacity = opacity > 12 ? 10 + Math.abs(opacity - 14) : opacity;
opacity = Number((opacity / 12).toFixed(2));
listBg.setAttribute('style', `opacity: ${opacity}`);
}
requestAnimationFrame(setListBgStyle);
setInterval(() => {
requestAnimationFrame(setListBgStyle);
}, halfAnHour);
}
|