wip: local portal changes (backup before disk cleanup)

This commit is contained in:
Ondřej Glaser
2026-07-07 13:16:26 +02:00
parent 48cef99257
commit 79b17be817
774 changed files with 8592 additions and 245 deletions

View File

@@ -64,7 +64,7 @@
const fd = new FormData();
fd.append("original", state.origFile);
fd.append("new", state.newFile);
const r = await fetch("/api/compare", { method: "POST", body: fd });
const r = await fetch("api/compare", { method: "POST", body: fd });
if (!r.ok) throw new Error((await r.json()).detail || r.statusText);
const json = await r.json();
state.jobId = json.job_id;
@@ -110,7 +110,7 @@
}
$("download-btn").addEventListener("click", () => {
if (state.jobId) window.location.href = `/api/report/${state.jobId}`;
if (state.jobId) window.location.href = `api/report/${state.jobId}`;
});
$("restart-btn").addEventListener("click", () => {
state = { jobId: null, result: null, origFile: null, newFile: null };

View File

@@ -4,36 +4,77 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Porovnání VV | Colsys AI</title>
<base href="/apps/porovnani-vv/">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&display=swap">
<link rel="stylesheet" href="/static/styles.css">
<link rel="stylesheet" href="/static/extra.css">
<link rel="stylesheet" href="static/styles.css">
<link rel="stylesheet" href="static/extra.css">
<script>
// Theme bootstrap — read source-of-truth in this order:
// ?theme= URL → portal_theme cookie → app_theme localStorage → OS
// The cookie is set by the portal landing on every resolvedTheme change,
// so it always reflects the portal's current state.
(function () {
var t = null;
try { var p = new URL(window.location.href).searchParams.get("theme");
if (p === "dark" || p === "light") t = p; } catch (e) {}
try {
var p = new URL(window.location.href).searchParams.get("theme");
if (p === "dark" || p === "light") t = p;
} catch (e) {}
if (!t) {
var m = document.cookie.match(/(?:^|;\s*)portal_theme=([^;]+)/);
if (m) t = decodeURIComponent(m[1]);
}
if (!t) { try { t = localStorage.getItem("app_theme"); } catch (e) {} }
if (!t) { var m = document.cookie.match(/(?:^|;\s*)portal_theme=([^;]+)/);
if (m) t = decodeURIComponent(m[1]); }
if (!t && typeof matchMedia !== "undefined") {
try {
t = matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
} catch (e) {}
}
if (t === "dark" || t === "light") {
document.documentElement.classList.add(t);
try { localStorage.setItem("app_theme", t); } catch (e) {}
}
})();
// bfcache rehydration — re-sync the class when the page is restored
// (e.g. user toggled theme on the portal, then hit Back).
// Same as pageshow, but fires when the user switches tabs.
// Covers: portal tab toggles theme → user comes back to app tab.
document.addEventListener("visibilitychange", function () {
if (document.visibilityState !== "visible") return;
var m = document.cookie.match(/(?:^|;\s*)portal_theme=([^;]+)/);
if (!m) return;
var t = decodeURIComponent(m[1]);
if (t !== "dark" && t !== "light") return;
var cls = document.documentElement.classList;
if (cls.contains(t)) return;
cls.remove(t === "dark" ? "light" : "dark");
cls.add(t);
try { localStorage.setItem("app_theme", t); } catch (e) {}
});
window.addEventListener("pageshow", function () {
var m = document.cookie.match(/(?:^|;\s*)portal_theme=([^;]+)/);
if (!m) return;
var t = decodeURIComponent(m[1]);
if (t !== "dark" && t !== "light") return;
var cls = document.documentElement.classList;
if (cls.contains(t)) return;
cls.remove(t === "dark" ? "light" : "dark");
cls.add(t);
try { localStorage.setItem("app_theme", t); } catch (e) {}
});
</script>
</head>
<body>
<header class="header">
<div class="header-inner">
<a href="https://ai.klas.chat" class="brand">
<a href="/" class="brand">
<span class="brand-icon">C</span>
<span class="brand-name">Colsys <span class="brand-ai">AI</span></span>
</a>
<span class="header-crumb">Porovnání VV</span>
<a href="https://ai.klas.chat" class="back-link" title="Zpět na portál">
<a href="/" class="back-link" title="Zpět na portál">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="m15 18-6-6 6-6"/>
</svg>
@@ -126,6 +167,6 @@
</main>
<script src="/static/app.js"></script>
<script src="static/app.js"></script>
</body>
</html>