58 lines
1.3 KiB
JavaScript
58 lines
1.3 KiB
JavaScript
const buttons = ["item", "link", "swap"];
|
|
|
|
for (let button of buttons) {
|
|
document.getElementById(button).addEventListener("click", () => {
|
|
document.body.classList.toggle(button);
|
|
});
|
|
}
|
|
|
|
const email = document.getElementById("email");
|
|
email.style.cursor = "pointer";
|
|
const email_ = ".";
|
|
|
|
const email_alias = [
|
|
atob("Y3Y="),
|
|
].join(email_);
|
|
const email_at = document.createElement("span");
|
|
email_at.className = "fa fa-at";
|
|
const email_domain = [
|
|
atob("bWFyYw=="),
|
|
atob("YmVuaW5jYQ=="),
|
|
atob("bGluaw=="),
|
|
].join(email_);
|
|
|
|
email.append(email_alias, " ", email_at, " ", email_domain);
|
|
email.addEventListener("click", () => {
|
|
window.location.href =
|
|
["mailto", [email_alias, email_domain].join("@")].join(":");
|
|
});
|
|
|
|
let theme;
|
|
|
|
function theme_get() {
|
|
theme = localStorage.getItem("theme");
|
|
if (! theme) {
|
|
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
theme = "dark";
|
|
} else {
|
|
theme = "light";
|
|
}
|
|
}
|
|
theme_set();
|
|
}
|
|
|
|
function theme_set() {
|
|
document.documentElement.setAttribute("data-theme", theme);
|
|
localStorage.setItem("theme", theme);
|
|
}
|
|
|
|
function theme_swap() {
|
|
theme = theme === "light" ? "dark" : "light";
|
|
theme_set();
|
|
}
|
|
|
|
document.getElementById("theme").addEventListener("click", () => {
|
|
theme_swap();
|
|
});
|
|
|
|
theme_get();
|