28 lines
1.4 KiB
JavaScript
28 lines
1.4 KiB
JavaScript
(() => {
|
|
const key = document.body.dataset.document;
|
|
const target = document.getElementById("legal-document");
|
|
const escapeHtml = (value) => String(value).replace(/[&<>"']/g, (character) => ({
|
|
"&": "&", "<": "<", ">": ">", '"': """, "'": "'"
|
|
})[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>'; });
|
|
})();
|