Implemented darkmode, without UI. Resolved #3.
This commit is contained in:
parent
a427b7a211
commit
b5013b5817
@ -1,5 +1,21 @@
|
|||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
if (window.location.search.indexOf("darkmode=true") > -1) {
|
if (window.location.search.indexOf("darkmode=false") > -1) {
|
||||||
document.getElementById("content").classList.add("dark-mode");
|
document.cookie = "darkmode=false; path=/";
|
||||||
|
try {
|
||||||
|
document.getElementById("content").classList.remove("dark-mode");
|
||||||
|
} catch (error) {
|
||||||
|
if (error.message !== "document.getElementById(...) is null") {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (window.location.search.indexOf("darkmode=true") > -1 || document.cookie.indexOf("darkmode=true") > -1) {
|
||||||
|
document.cookie = "darkmode=true; path=/";
|
||||||
|
try {
|
||||||
|
document.getElementById("content").classList.add("dark-mode");
|
||||||
|
} catch (error) {
|
||||||
|
if (error.message !== "document.getElementById(...) is null") {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user