-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththeme.js
More file actions
28 lines (27 loc) · 708 Bytes
/
theme.js
File metadata and controls
28 lines (27 loc) · 708 Bytes
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
var d = new Date();
var h = d.getHours();
var theme;
var next;
if (h >= 2 && h < 6) {
theme = 'night';
next = "6 am";
} else if (h >= 6 && h < 10) {
theme = 'sunrise';
next = "10 am";
} else if (h >= 10 && h < 14) {
theme = 'midday';
next = "2 pm";
} else if (h >= 14 && h < 18) {
theme = 'light';
next = "6 pm";
} else if (h >= 18 && h < 22) {
theme = 'sunset';
next = "10 pm";
} else if (h >= 22 || h < 2) {
theme = 'moonlight';
next = "2 am";
}
document.getElementById("theme-display").innerHTML = theme;
theme = theme.toLowerCase();
document.getElementById("theme").classList.add(theme + '-theme');
document.getElementById("next-theme").innerHTML = next;