2021-07-03 16:08:10 +02:00
|
|
|
import obfuscates from 'js/obfuscates';
|
2021-06-12 01:58:10 +02:00
|
|
|
|
2021-07-03 16:08:10 +02:00
|
|
|
obfuscates();
|
2021-06-12 01:58:10 +02:00
|
|
|
function changeTheme() {
|
|
|
|
// https://css-tricks.com/a-complete-guide-to-dark-mode-on-the-web/#using-javascript-local-storage
|
|
|
|
const btn = document.querySelector(".btn-toggle");
|
|
|
|
const prefersDarkScheme = window.matchMedia("(prefers-color-scheme: dark)");
|
|
|
|
|
|
|
|
const currentTheme = localStorage.getItem("theme");
|
|
|
|
|
|
|
|
if (currentTheme == "dark") {
|
|
|
|
document.body.classList.toggle("dark-theme");
|
|
|
|
} else if (currentTheme == "light") {
|
|
|
|
document.body.classList.toggle("light-theme");
|
|
|
|
}
|
|
|
|
|
|
|
|
btn.addEventListener("click", function () {
|
|
|
|
if (prefersDarkScheme.matches) {
|
|
|
|
document.body.classList.toggle("light-theme");
|
|
|
|
var theme = document.body.classList.contains("light-theme")
|
|
|
|
? "light"
|
|
|
|
: "dark";
|
|
|
|
} else {
|
|
|
|
document.body.classList.toggle("dark-theme");
|
|
|
|
var theme = document.body.classList.contains("dark-theme")
|
|
|
|
? "dark"
|
|
|
|
: "light";
|
|
|
|
}
|
|
|
|
|
|
|
|
localStorage.setItem("theme", theme);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function main() {
|
2021-07-03 16:08:10 +02:00
|
|
|
obfuscates();
|
2021-06-12 01:58:10 +02:00
|
|
|
changeTheme();
|
|
|
|
}
|
|
|
|
|
|
|
|
main();
|