diff --git a/assets/theme-v2/js/gamefoundry-partials.js b/assets/theme-v2/js/gamefoundry-partials.js index 6945db507..681d7874c 100644 --- a/assets/theme-v2/js/gamefoundry-partials.js +++ b/assets/theme-v2/js/gamefoundry-partials.js @@ -93,13 +93,15 @@ "owner-notes": "owner/notes.html", "owner-site-settings": "owner/site-settings.html", "owner-themes": "owner/themes.html", - "community-guidelines": "legal/community-guidelines.html", + "legal-overview": "legal/index.html", + "terms-of-service": "legal/terms-of-service.html", + "terms-legal": "legal/terms.html", + "privacy-policy": "legal/privacy-policy.html", + "cookie-policy": "legal/cookie-policy.html", "cookies-policy": "legal/cookies-policy.html", + "community-guidelines": "legal/community-guidelines.html", "copyright-policy": "legal/copyright-policy.html", - disclaimer: "legal/disclaimer.html", "dmca-policy": "legal/dmca-policy.html", - "privacy-policy": "legal/privacy-policy.html", - "terms-legal": "legal/terms.html", account: "account/index.html", "account-achievements": "account/achievements.html", "account-ai-credits": "account/ai-credits.html", diff --git a/assets/theme-v2/js/legal-document-page.js b/assets/theme-v2/js/legal-document-page.js deleted file mode 100644 index c5f6165f6..000000000 --- a/assets/theme-v2/js/legal-document-page.js +++ /dev/null @@ -1,103 +0,0 @@ -import { readPublishedLegalDocument } from "../../../src/api/legal-api-client.js"; - -function target(root, selector) { - return root.querySelector(selector); -} - -function text(value, fallback = "") { - const normalized = String(value || "").trim(); - return normalized || fallback; -} - -function setStatus(root, status, message) { - const statusTarget = target(root, "[data-legal-document-status]"); - if (statusTarget) { - statusTarget.textContent = `${status}: ${message}`; - } -} - -function effectiveDate(value) { - const date = new Date(value || ""); - if (Number.isNaN(date.getTime())) { - return "Effective date unavailable."; - } - return `Effective ${new Intl.DateTimeFormat("en-US", { - day: "numeric", - month: "long", - timeZone: "UTC", - year: "numeric", - }).format(date)}.`; -} - -function unavailableMessage(title) { - const label = text(title, "legal document"); - if (label === "Terms of Service") { - return "Published Terms are unavailable."; - } - return `Published ${label} is unavailable.`; -} - -function renderBody(root, bodyMarkdown) { - const body = target(root, "[data-legal-document-body]"); - if (!body) { - return; - } - body.replaceChildren(); - text(bodyMarkdown).split(/\n{2,}/).map((block) => block.trim()).filter(Boolean).forEach((block) => { - const paragraph = document.createElement("p"); - paragraph.textContent = block.replace(/^#+\s*/, ""); - body.append(paragraph); - }); -} - -function renderUnavailable(root, payload) { - const title = target(root, "[data-legal-document-title]"); - const effective = target(root, "[data-legal-document-effective]"); - const body = target(root, "[data-legal-document-body]"); - const titleText = text(payload.title, title?.textContent || "legal document"); - if (title) { - title.textContent = titleText; - } - if (effective) { - effective.textContent = unavailableMessage(titleText); - } - if (body) { - body.replaceChildren(); - } - setStatus(root, payload.status || "WARN", text(payload.diagnostic, "Published legal content is unavailable.")); -} - -function renderPublished(root, payload) { - const title = target(root, "[data-legal-document-title]"); - const effective = target(root, "[data-legal-document-effective]"); - if (title) { - title.textContent = text(payload.title, title.textContent); - } - if (effective) { - effective.textContent = effectiveDate(payload.effectiveAt); - } - renderBody(root, payload.bodyMarkdown); - setStatus(root, "PASS", text(payload.diagnostic, "Loaded published legal content.")); -} - -document.addEventListener("DOMContentLoaded", () => { - const root = document.querySelector("[data-legal-document-page]"); - if (!root) { - return; - } - try { - const documentType = root.dataset.legalDocumentType || ""; - const payload = readPublishedLegalDocument(documentType); - if (payload.available === true) { - renderPublished(root, payload); - return; - } - renderUnavailable(root, payload); - } catch (error) { - renderUnavailable(root, { - diagnostic: error instanceof Error ? error.message : "Legal document is unavailable.", - status: "FAIL", - title: target(root, "[data-legal-document-title]")?.textContent || "Legal Document", - }); - } -}); diff --git a/assets/theme-v2/partials/footer.html b/assets/theme-v2/partials/footer.html index 2b800c198..e2eab66d5 100644 --- a/assets/theme-v2/partials/footer.html +++ b/assets/theme-v2/partials/footer.html @@ -41,12 +41,13 @@