Add legal consent and reliable external redirects

This commit is contained in:
hz
2026-07-20 02:16:20 -05:00
parent 2615ab4773
commit dae3a31b71
25 changed files with 756 additions and 14 deletions
+27
View File
@@ -0,0 +1,27 @@
(() => {
const key = document.body.dataset.document;
const target = document.getElementById("legal-document");
const escapeHtml = (value) => String(value).replace(/[&<>"']/g, (character) => ({
"&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;"
})[character]);
fetch("/legal/legal_documents.json", { cache: "no-store" })
.then((response) => {
if (!response.ok) throw new Error(`status ${response.status}`);
return response.json();
})
.then((documents) => {
const documentData = documents[key];
if (!documentData) throw new Error("document not found");
document.title = `${documentData.title} | RanaZe`;
const sections = documentData.sections.map((section) => `
<section><h2>${escapeHtml(section.heading)}</h2>
${section.paragraphs.map((paragraph) => `<p>${escapeHtml(paragraph)}</p>`).join("")}</section>`).join("");
target.innerHTML = `
<header><a class="brand" href="/">RanaZe: Step 3 Trainer</a>
<h1>${escapeHtml(documentData.title)}</h1>
<div class="meta">Effective ${escapeHtml(documentData.effectiveDate)} | Version ${escapeHtml(documentData.version)}</div>
<p class="summary">${escapeHtml(documentData.summary)}</p></header>${sections}`;
})
.catch(() => { target.innerHTML = '<p class="error">This document could not be loaded. Contact [email protected].</p>'; });
})();