mirror of
https://github.com/ankitects/anki.git
synced 2025-11-06 12:47:11 -05:00
31 lines
No EOL
1.1 KiB
TypeScript
31 lines
No EOL
1.1 KiB
TypeScript
import "../base.scss"
|
|
import "../../reviewer/reviewer.scss"
|
|
|
|
addEventListener("message", (e) => {
|
|
switch (e.data.type) {
|
|
case "html":
|
|
document.body.innerHTML = e.data.value;
|
|
break;
|
|
case "nightMode":
|
|
// This method currently "Flashbangs" the user if they have nightmode on and is a placeholder
|
|
// I will probably use #night-mode in the url.
|
|
const root = document.querySelector("html")!;
|
|
const nightMode = e.data.value;
|
|
if (e.data.value) {
|
|
root.classList.add("night-mode");
|
|
} else {
|
|
root.classList.remove("night-mode");
|
|
}
|
|
document.body.className = nightMode ? "nightMode card" : "card";
|
|
root.className = nightMode ? "night-mode" : "";
|
|
root.setAttribute("data-bs-theme", nightMode ? "dark" : "light");
|
|
break;
|
|
default:
|
|
console.warn(`Unknown message type: ${e.data.type}`);
|
|
break;
|
|
}
|
|
});
|
|
|
|
const base = document.createElement('base')
|
|
base.href = '/'
|
|
document.head.appendChild(base); |