2021-04-14 15:19:52 +00:00
|
|
|
function setDarkMode() {
|
2021-04-22 10:03:54 +00:00
|
|
|
if (window.document.body.getAttribute("data-theme")) {
|
2021-04-14 15:19:52 +00:00
|
|
|
window.localStorage.setItem('theme', window.document.body.getAttribute("data-theme"));
|
|
|
|
}
|
|
|
|
if (window.document.body.getAttribute("data-theme") == "dark") {
|
2021-04-22 08:43:53 +00:00
|
|
|
window.document.querySelector("#darkMode i").innerHTML = "brightness_high";
|
|
|
|
window.document.querySelector("#darkMode p").innerHTML = "Light Mode";
|
2021-04-14 15:19:52 +00:00
|
|
|
} else {
|
2021-04-22 08:43:53 +00:00
|
|
|
window.document.querySelector("#darkMode i").innerHTML = "brightness_low";
|
|
|
|
window.document.querySelector("#darkMode p").innerHTML = "Dark Mode";
|
2021-04-14 15:19:52 +00:00
|
|
|
}
|
|
|
|
}
|
2021-04-14 15:26:55 +00:00
|
|
|
|
2021-04-14 15:19:52 +00:00
|
|
|
if (window.localStorage.getItem('theme')) {
|
|
|
|
window.document.body.setAttribute("data-theme", window.localStorage.getItem("theme"));
|
|
|
|
}
|
2021-04-22 10:03:54 +00:00
|
|
|
|
|
|
|
setDarkMode();
|
|
|
|
document.getElementById("darkMode").addEventListener("click", function () {
|
|
|
|
if (window.document.body.getAttribute("data-theme") != "dark") {
|
|
|
|
window.document.body.setAttribute("data-theme", "dark");
|
|
|
|
} else {
|
|
|
|
window.document.body.setAttribute("data-theme", "light");
|
|
|
|
}
|
2021-04-14 15:19:52 +00:00
|
|
|
setDarkMode();
|
2021-04-14 12:38:23 +00:00
|
|
|
});
|