Initial commit: BlackDice site rebuild with integrated CMS

Rebuilds content management around a single admin route (/admin —
"BlackDice Studio"), replacing blackdice-studio.html. Publishing writes
one JSON content document instead of regenerating HTML files, so it can
no longer overwrite hand-made site changes the way the old tool did.

- /admin: click-to-edit copy/images, article CRUD with a Word-safe rich
  text editor, demo clip management, per-page SEO, enquiry log, publish
  history with rollback
- Real per-page URLs for all pages and articles, each with its own
  meta/canonical/OG/JSON-LD
- Newsroom + article pages driven by the CMS post library, seeded from
  the old studio's export (17 articles) plus a drafted GSMA Open Gateway
  press release awaiting approval
- Demo sections on Mobile SDK and Halo CPE, interactive by default and
  upgradable to an uploaded clip per slot
- Dependency-free Node API server (auth, publish, uploads, snapshots,
  leads, live sitemap)
- Deployment configs for Node/nginx/IIS, Vercel and Netlify

See docs/ARCHITECTURE.md, docs/PROJECT-STRUCTURE.md, docs/CMS-GUIDE.md
and docs/DEPLOYMENT.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-12 23:52:44 +05:00
co-authored by Claude Sonnet 5
commit 63a36e0dca
77 changed files with 19487 additions and 0 deletions
+460
View File
@@ -0,0 +1,460 @@
// BlackDice site controller — ported from the original vanilla js/main.js.
// Function declarations are exposed on window so the inline onclick handlers in the
// legacy markup (goPage(event), showDemo(), etc.) continue to resolve.
/* eslint-disable */
"use strict";
var PAGE_NAMES = {
p1: "Home",
p2: "Mobile SDK",
p3: "Halo CPE",
p4: "For Operators",
p5: "Financial Services",
p6: "Why BlackDice?",
p7: "News",
p8: "Investors",
p9: "Contact",
p10: "DNS Protect",
p11: "Cookie Policy",
p12: "Privacy Policy",
};
var PAGE_PATHS = {
p1: "/",
p2: "/mobile-sdk",
p3: "/halo-cpe",
p4: "/for-operators",
p5: "/financial-services",
p6: "/why-blackdice",
p7: "/news",
p8: "/investors",
p9: "/contact",
p10: "/dns-protect",
p11: "/cookie-policy",
p12: "/privacy-policy",
};
var FEED_EVENTS = [
{
lbl: "DNS exfiltration, IoT device, Subscriber #4471821",
risk: "HIGH",
cls: "h",
bdg: "blocked",
btxt: "BLOCKED",
},
{
lbl: "Behavioural anomaly new device, 3am traffic spike",
risk: "MED",
cls: "m",
bdg: "mon",
btxt: "MONITORING",
},
{
lbl: "C2 callback attempt, ZeroDay variant detected",
risk: "HIGH",
cls: "h",
bdg: "blocked",
btxt: "NEUTRALISED",
},
{
lbl: "Remote access app active during banking session",
risk: "HIGH",
cls: "h",
bdg: "blocked",
btxt: "BLOCKED",
},
{
lbl: "Phishing domain blocked — lookalike banking site",
risk: "HIGH",
cls: "h",
bdg: "blocked",
btxt: "BLOCKED",
},
{
lbl: "Botnet C2 lookup — smart TV IoT cluster",
risk: "HIGH",
cls: "h",
bdg: "blocked",
btxt: "BLOCKED",
},
{
lbl: "Newly registered domain flagged for analysis",
risk: "MED",
cls: "m",
bdg: "mon",
btxt: "MONITORING",
},
{
lbl: "Device rooted pre-login, session terminated",
risk: "HIGH",
cls: "h",
bdg: "blocked",
btxt: "BLOCKED",
},
{
lbl: "Scam call detected during active banking session",
risk: "HIGH",
cls: "h",
bdg: "flag",
btxt: "FLAGGED",
},
{
lbl: "Standard session, device integrity clear",
risk: "LOW",
cls: "l",
bdg: "clear",
btxt: "CLEAR",
},
{
lbl: "Incoming call — known scam number pattern",
risk: "HIGH",
cls: "h",
bdg: "flag",
btxt: "FLAGGED",
},
{
lbl: "Network switch: Wi-Fi \u2192 cellular (rogue AP adjacent)",
risk: "MED",
cls: "m",
bdg: "mon",
btxt: "MONITORING",
},
];
var feedIdx = 0;
// ── Navigation ─────────────────────────────────────────────────────────────
// Pages are real URLs (/mobile-sdk, /halo-cpe, …). The router owns the URL: the
// legacy inline handlers call go(), which navigates, and the route change calls
// showPage() to do the DOM work. That keeps back/forward, deep links and shared
// links working without duplicating page-switching logic.
// Injected by SiteApp; falls back to direct rendering if the router is absent.
var __navigate = null;
function setSiteNavigator(fn) {
__navigate = fn;
}
function go(id) {
var path = PAGE_PATHS[id];
if (__navigate && path) {
__navigate(path);
return;
}
showPage(id);
}
/** Renders a page in the DOM. `navId` highlights a different nav item (articles → News). */
function showPage(id, navId) {
var active = navId || id;
// Hide all pages
document.querySelectorAll(".pg").forEach(function (el) {
el.style.display = "none";
});
// Show target page
var pg = document.getElementById("pg-" + id);
if (pg) pg.style.display = "block";
// Update nav active states
document.querySelectorAll("[data-nav]").forEach(function (btn) {
btn.classList.remove("on");
});
document.querySelectorAll('[data-nav="' + active + '"]').forEach(function (btn) {
btn.classList.add("on");
});
// Company dropdown parent
var co = ["p6", "p7", "p8", "p9"].indexOf(active) >= 0;
var coBtn = document.getElementById("nav-co");
if (coBtn) {
if (co) coBtn.classList.add("on");
else coBtn.classList.remove("on");
}
// Close mobile nav
var mob = document.getElementById("mob-nav");
if (mob) mob.style.display = "none";
// Scroll to top instantly
window.scrollTo(0, 0);
// HubSpot page view tracking
var hsq = (window._hsq = window._hsq || []);
hsq.push(["setPath", PAGE_PATHS[id] || window.location.pathname]);
hsq.push(["trackPageView"]);
setTimeout(initCountUp, 200);
}
function goPage(e) {
var btn = e.target.closest("[data-page]");
if (btn) go(btn.dataset.page);
}
function goHome() {
go("p1");
}
function toggleMob() {
var mob = document.getElementById("mob-nav");
if (!mob) return;
mob.style.display = mob.style.display === "none" ? "block" : "none";
}
// ── Scroll ─────────────────────────────────────────────────────────────────
function onScroll() {
var nav = document.getElementById("bd-nav");
if (!nav) return;
if (window.scrollY > 50) {
nav.style.background = "rgba(1,59,73,.97)";
nav.style.borderBottomColor = "rgba(255,255,255,.07)";
} else {
nav.style.background = "rgba(1,59,73,.4)";
nav.style.borderBottomColor = "transparent";
}
}
function scrollDown() {
var hint = document.getElementById("scroll-hint-btn");
if (hint) hint.classList.remove("vis");
window.scrollBy({ top: window.innerHeight * 0.85, behavior: "smooth" });
}
// ── Demo modal ─────────────────────────────────────────────────────────────
function showDemo() {
var ov = document.getElementById("modal-ov");
var form = document.getElementById("modal-form");
var sent = document.getElementById("modal-sent");
var err = document.getElementById("modal-err");
if (ov) ov.style.display = "flex";
if (form) form.style.display = "block";
if (sent) sent.style.display = "none";
if (err) err.style.display = "none";
}
function closeDemo() {
var ov = document.getElementById("modal-ov");
if (ov) ov.style.display = "none";
}
function closeBg(e) {
if (e.target === e.currentTarget) closeDemo();
}
// \u2500\u2500 Enquiry forms \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
// Every route to a human \u2014 "Talk to us", "Book a demonstration", the contact page
// and any mailto: link \u2014 funnels through these forms so the visitor's details are
// captured. Recipients come from the CMS (settings.formRecipient), so they can be
// changed without a code release; onLead records the submission server-side.
var FORM_CONFIG = {
formRecipient: "campbell.ferrier@blackdice.ai",
formCc: "",
onLead: null,
};
function configureForms(config) {
FORM_CONFIG.formRecipient = config.formRecipient || FORM_CONFIG.formRecipient;
FORM_CONFIG.formCc = config.formCc || "";
FORM_CONFIG.onLead = config.onLead || null;
}
function fieldValue(id) {
var el = document.getElementById(id);
return el ? el.value.trim() : "";
}
function sendEnquiry(form, fields, subject, intro) {
if (typeof FORM_CONFIG.onLead === "function") {
FORM_CONFIG.onLead({
form: form,
name: (fields.fname + " " + fields.lname).trim(),
email: fields.email,
company: fields.company,
phone: fields.phone || "",
message: fields.message || intro,
page: window.location.pathname,
});
}
var enc = encodeURIComponent;
var lines = [
"Name: " + fields.fname + " " + fields.lname,
"Email: " + fields.email,
fields.phone ? "Mobile: " + fields.phone : "",
"Company: " + fields.company,
"Page: " + window.location.href,
"",
fields.message || intro,
].filter(Boolean);
var cc = FORM_CONFIG.formCc ? "&cc=" + enc(FORM_CONFIG.formCc) : "";
var a = document.createElement("a");
a.href =
"mailto:" +
FORM_CONFIG.formRecipient +
"?subject=" +
enc(subject) +
cc +
"&body=" +
enc(lines.join("\n"));
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
function submitDemo() {
var fields = {
fname: fieldValue("df-fname"),
lname: fieldValue("df-lname"),
email: fieldValue("df-email"),
phone: fieldValue("df-mobile"),
company: fieldValue("df-company"),
message: "",
};
if (!fields.fname || !fields.email || !fields.company) {
var err = document.getElementById("modal-err");
if (err) err.style.display = "block";
return;
}
try {
localStorage.setItem("bd_demo_prefill", JSON.stringify(fields));
} catch (ex) {}
sendEnquiry(
"demo-request",
fields,
"Demo Request \u2014 " + fields.fname + " " + fields.lname + ", " + fields.company,
"Please send information about a BlackDice platform demonstration.",
);
var form = document.getElementById("modal-form");
var sent = document.getElementById("modal-sent");
if (form) form.style.display = "none";
if (sent) sent.style.display = "block";
}
function submitContact() {
var fields = {
fname: fieldValue("cf-fname"),
lname: fieldValue("cf-lname"),
email: fieldValue("cf-email"),
phone: fieldValue("cf-mobile"),
company: fieldValue("cf-company"),
message: fieldValue("cf-msg"),
};
if (!fields.fname || !fields.email) {
var cerr = document.getElementById("contact-err");
if (cerr) cerr.style.display = "block";
return;
}
sendEnquiry(
"contact",
fields,
"Enquiry \u2014 " + fields.fname + " " + fields.lname + ", " + fields.company,
"Enquiry from the BlackDice website.",
);
var cform = document.getElementById("contact-form");
var csent = document.getElementById("contact-sent");
if (cform && csent) {
cform.style.display = "none";
csent.style.display = "block";
}
}
// ── Live feed cycling ──────────────────────────────────────────────────────
function cycleFeed() {
feedIdx = (feedIdx + 1) % FEED_EVENTS.length;
var item = FEED_EVENTS[feedIdx];
document.querySelectorAll(".feed-body").forEach(function (feed) {
var rows = feed.querySelectorAll(".feed-row");
if (!rows.length) return;
var row = rows[rows.length - 1];
var lbl = row.querySelector(".feed-lbl");
var risk = row.querySelector(".feed-risk");
var bdg = row.querySelector(".feed-bdg");
if (lbl) lbl.textContent = item.lbl;
if (risk) {
risk.textContent = item.risk;
risk.className = "feed-risk " + item.cls;
}
if (bdg) {
bdg.textContent = item.btxt;
bdg.className = "feed-bdg " + item.bdg;
}
feed.insertBefore(row, rows[0]);
row.style.animation = "none";
void row.offsetHeight; // force reflow
row.style.animation = "bd-slide .4s ease";
});
}
// ── Count-up animation ─────────────────────────────────────────────────────
function initCountUp() {
if (!("IntersectionObserver" in window)) return;
var obs = new IntersectionObserver(
function (entries) {
entries.forEach(function (en) {
if (!en.isIntersecting) return;
var el = en.target;
if (el._countDone) return;
el._countDone = true;
var target = parseFloat(el.dataset.count);
var suffix = el.dataset.suffix || "";
var isInt = Number.isInteger(target);
var dur = 1500;
var t0 = performance.now();
function tick(now) {
var p = Math.min((now - t0) / dur, 1);
var ease = 1 - Math.pow(1 - p, 3);
el.textContent =
(isInt ? Math.round(target * ease) : (target * ease).toFixed(1)) +
suffix;
if (p < 1) requestAnimationFrame(tick);
}
requestAnimationFrame(tick);
obs.unobserve(el);
});
},
{ threshold: 0.5 },
);
document.querySelectorAll("[data-count]").forEach(function (el) {
el._countDone = false;
obs.observe(el);
});
}
// ── Init ───────────────────────────────────────────────────────────────────
// ── Expose globals for inline handlers ─────────────────────────────────────
var __w = /** @type {any} */ (window);
__w.go = go; __w.goPage = goPage; __w.goHome = goHome; __w.toggleMob = toggleMob;
__w.scrollDown = scrollDown; __w.showDemo = showDemo; __w.closeDemo = closeDemo;
__w.closeBg = closeBg; __w.submitDemo = submitDemo; __w.submitContact = submitContact;
var __bdFeedTimer = null;
export { showPage, setSiteNavigator, configureForms, initCountUp, PAGE_NAMES, PAGE_PATHS };
export function initSite(startPage) {
showPage(startPage || 'p1');
var hint = document.getElementById('scroll-hint-btn');
if (hint) {
hint.classList.add('vis');
var hideHint = function () { hint.classList.remove('vis'); window.removeEventListener('scroll', hideHint); };
window.addEventListener('scroll', hideHint);
}
window.addEventListener('scroll', onScroll, { passive: true });
if (__bdFeedTimer) clearInterval(__bdFeedTimer);
__bdFeedTimer = setInterval(cycleFeed, 3400);
initCountUp();
}
export function teardownSite() {
window.removeEventListener('scroll', onScroll);
if (__bdFeedTimer) { clearInterval(__bdFeedTimer); __bdFeedTimer = null; }
}