mirror of
https://github.com/ankitects/anki.git
synced 2025-11-06 12:47:11 -05:00
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
// Copyright: Ankitects Pty Ltd and contributors
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
import "../base.scss";
|
|
import "../../reviewer/reviewer.scss";
|
|
import { enableNightMode } from "../reviewer/reviewer";
|
|
|
|
const style = document.createElement("style");
|
|
document.head.appendChild(style);
|
|
|
|
addEventListener("message", (e) => {
|
|
switch (e.data.type) {
|
|
case "html": {
|
|
document.body.innerHTML = e.data.value;
|
|
if (e.data.css) {
|
|
style.innerHTML = e.data.css;
|
|
}
|
|
break;
|
|
}
|
|
default: {
|
|
console.warn(`Unknown message type: ${e.data.type}`);
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
|
|
const base = document.createElement("base");
|
|
base.href = "/";
|
|
document.head.appendChild(base);
|
|
|
|
function pycmd(cmd: string) {
|
|
window.parent.postMessage({ type: "pycmd", value: cmd }, "*");
|
|
}
|
|
globalThis.pycmd = pycmd;
|
|
|
|
const params = new URLSearchParams(location.search);
|
|
const theme = params.get("nightMode");
|
|
if (theme !== null) {
|
|
enableNightMode();
|
|
}
|
|
document.documentElement.classList.add("card");
|