-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
49 lines (40 loc) · 1.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dark Mode Toggle</title>
<meta charset="utf-8">
<meta name="description" content="Dark Mode Toggle Example">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Loading manifest -->
<link rel="manifest" href="../manifest.json">
<!-- Loading third party fonts -->
<link rel="stylesheet" href="css/css.css">
</head>
<body>
<script>
var app = document.getElementsByTagName("BODY")[0];
if (localStorage.lightMode == "dark") {
app.setAttribute("light-mode", "dark");
}
</script>
<script>
function toggle_light_mode() {
var app = document.getElementsByTagName("BODY")[0];
if (localStorage.lightMode == "dark") {
localStorage.lightMode = "light";
app.setAttribute("light-mode", "light");
} else {
localStorage.lightMode = "dark";
app.setAttribute("light-mode", "dark");
}
}
window.addEventListener("storage", function () {
if (localStorage.lightMode == "dark") {
app.setAttribute("light-mode", "dark");
} else {
app.setAttribute("light-mode", "light");
}
}, false);
</script>
</body>
</html>