-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
40 lines (32 loc) · 996 Bytes
/
script.js
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
let theme = "light";
const sheet = document.getElementById("esriStyle");
const checkbox = document.getElementById("checkbox")
checkbox.addEventListener("change", toggleEsriTheme)
function toggleEsriTheme() {
document.body.classList.toggle("dark")
if (theme === "light") {
sheet.href = "https://js.arcgis.com/4.22/esri/themes/dark/main.css";
theme = "dark";
} else if (theme === "dark") {
sheet.href = "https://js.arcgis.com/4.22/esri/themes/light/main.css";
theme = "light";
}
}
function toggleEsriThemebyTime() {
var date = new Date();
var hour = date.getHours();
// var body = document.body;
if (hour >= 19 || hour < 6) {
if (theme === "light") {
toggleEsriTheme();
checkbox.checked = true;
} else {
if (theme === "dark") {
toggleEsriTheme();
checkbox.checked = false;
}
}
}
}
// Llama a la función setMode al cargar la página para establecer el modo inicial.
window.onload = toggleEsriThemebyTime;