cv.marc/in/script/main.js

73 lines
1.4 KiB
JavaScript
Raw Normal View History

2025-05-03 12:41:36 +02:00
// buttons
2025-04-17 11:02:37 +02:00
const buttons = ["item", "link", "swap"];
2025-03-28 21:41:36 +01:00
2025-04-17 09:55:28 +02:00
for (let button of buttons) {
document.getElementById(button).addEventListener("click", () => {
document.body.classList.toggle(button);
});
}
2025-04-16 22:04:28 +02:00
2025-05-03 12:41:36 +02:00
// theme
2025-04-28 22:50:49 +02:00
let theme;
2025-02-16 20:03:30 +01:00
2025-02-17 01:51:01 +01:00
function theme_get() {
2025-04-17 11:19:35 +02:00
theme = localStorage.getItem("theme");
if (! theme) {
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
theme = "dark";
} else {
theme = "light";
}
2025-02-17 01:51:01 +01:00
}
2025-04-28 22:50:49 +02:00
theme_set();
2025-02-17 01:51:01 +01:00
}
2025-04-17 11:19:35 +02:00
function theme_set() {
2025-02-18 00:01:39 +01:00
document.documentElement.setAttribute("data-theme", theme);
localStorage.setItem("theme", theme);
2025-02-17 01:51:01 +01:00
}
2025-02-16 20:03:30 +01:00
2025-04-17 11:19:35 +02:00
function theme_swap() {
theme = theme === "light" ? "dark" : "light";
theme_set();
}
document.getElementById("theme").addEventListener("click", () => {
theme_swap();
2025-02-16 20:03:30 +01:00
});
2025-04-28 22:50:49 +02:00
theme_get();
2025-05-03 12:31:01 +02:00
2025-05-03 12:41:36 +02:00
//
const a = (t) => atob(`${t}=`);
const ab = (t) => atob(`${t}==`);
2025-05-03 12:31:01 +02:00
const qa = document.getElementById("qa");
2025-05-03 12:41:36 +02:00
qa.style.cursor = ab("cG9pbnRlcg");
const qa0 = ab("Lg");
2025-05-03 12:31:01 +02:00
const qa1 = [
2025-05-03 12:41:36 +02:00
a("Y3Y"),
2025-05-03 12:31:01 +02:00
].join(qa0);
2025-05-03 12:41:36 +02:00
const qa2 = document.createElement(ab("c3Bhbg"));
qa2.className = a("ZmEgZmEtYXQ");
2025-05-03 12:31:01 +02:00
const qa3 = [
2025-05-03 12:41:36 +02:00
ab("bWFyYw"),
ab("YmVuaW5jYQ"),
ab("bGluaw"),
2025-05-03 12:31:01 +02:00
].join(qa0);
2025-05-03 12:41:36 +02:00
const qa4 = ab("IA")
2025-05-03 12:31:01 +02:00
for (let kg of [qa1, qa4, qa2, qa4, qa3]) {
qa.append(kg);
}
qa.addEventListener("click", () => {
window.location.href = [
atob("bWFpbHRv"),
2025-05-03 12:41:36 +02:00
[qa1, qa3].join(ab("QA")),
].join(ab("Og"));
2025-05-03 12:31:01 +02:00
});