CI / build (push) Canceled after 0s
- Homepage hero CTA now reads "ROI Calculator" and links straight to /roi-calculator; dropped the second "Explore platform" button. - Tightened nav link/dropdown/CTA padding; fixed .bd-hero padding on mobile (was inheriting 90px from desktop, now 15px). - ROI calculator page hero: added a live-badge next to the eyebrow (matching the homepage's "NETWORK INTELLIGENCE LIVE" styling) and renamed it from "FOR OPERATORS" to "ROI CALCULATOR"; tidied the hero subcopy punctuation. - Cleared the dead wp-content hero image on the South-east Asia blog post (the old WordPress asset no longer exists) so it degrades gracefully instead of showing a broken image icon. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
553 lines
17 KiB
JavaScript
553 lines
17 KiB
JavaScript
// BlackDice site controller — ported from the original vanilla js/main.js.
|
|
// The legacy markup no longer carries onclick="" attributes (a CSP with
|
|
// script-src 'unsafe-inline' removed would otherwise let injected inline
|
|
// script or event handlers run too) — clicks are handled by the single
|
|
// delegated listener below, keyed off data-page/data-action. Functions are
|
|
// still exposed on window because SiteApp.tsx reads window.showDemo for the
|
|
// mailto-link and "Talk to us" wiring it does independently.
|
|
/* 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",
|
|
p13: "ROI Calculator",
|
|
};
|
|
|
|
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",
|
|
p13: "/roi-calculator",
|
|
};
|
|
|
|
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";
|
|
document.body.setAttribute("data-active-page", id);
|
|
|
|
// 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 (News/p7 moved out to its own top-level nav item)
|
|
var co = ["p6", "p8", "p9"].indexOf(active) >= 0;
|
|
var coBtn = document.getElementById("nav-co");
|
|
if (coBtn) {
|
|
if (co) coBtn.classList.add("on");
|
|
else coBtn.classList.remove("on");
|
|
}
|
|
|
|
// For Operators dropdown parent (Overview + ROI Calculator)
|
|
var fo = ["p4", "p13"].indexOf(active) >= 0;
|
|
var foBtn = document.getElementById("nav-fo");
|
|
if (foBtn) {
|
|
if (fo) foBtn.classList.add("on");
|
|
else foBtn.classList.remove("on");
|
|
}
|
|
|
|
// Platform dropdown parent (Mobile SDK, DNS Protect, Halo CPE)
|
|
var pf = ["p2", "p10", "p3"].indexOf(active) >= 0;
|
|
var pfBtn = document.getElementById("nav-pf");
|
|
if (pfBtn) {
|
|
if (pf) pfBtn.classList.add("on");
|
|
else pfBtn.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;
|
|
var opening = mob.style.display === "none";
|
|
mob.style.display = opening ? "block" : "none";
|
|
var ham = document.querySelector(".bd-ham");
|
|
if (ham) ham.setAttribute("aria-expanded", opening ? "true" : "false");
|
|
}
|
|
|
|
// ── Scroll ─────────────────────────────────────────────────────────────────
|
|
|
|
function onScroll() {
|
|
var nav = document.getElementById("bd-nav");
|
|
if (!nav) return;
|
|
if (window.scrollY > 50) {
|
|
nav.style.borderBottomColor = "rgba(255,255,255,.07)";
|
|
} else {
|
|
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 ─────────────────────────────────────────────────────────────
|
|
// A modal needs to trap focus and close on Escape to be usable by keyboard
|
|
// and screen-reader visitors — otherwise Tab can walk out into the hidden
|
|
// page behind it, with no keyboard way back in or out.
|
|
|
|
var __bdModalLastFocus = null;
|
|
|
|
function __bdModalFocusables() {
|
|
var box = document.querySelector("#modal-ov .modal-box");
|
|
if (!box) return [];
|
|
return Array.prototype.filter.call(
|
|
box.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),
|
|
function (el) { return !el.disabled && el.offsetParent !== null; },
|
|
);
|
|
}
|
|
|
|
function __bdModalKeydown(e) {
|
|
if (e.key === "Escape" || e.key === "Esc") {
|
|
e.preventDefault();
|
|
closeDemo();
|
|
return;
|
|
}
|
|
if (e.key !== "Tab") return;
|
|
var focusables = __bdModalFocusables();
|
|
if (!focusables.length) return;
|
|
var first = focusables[0];
|
|
var last = focusables[focusables.length - 1];
|
|
if (e.shiftKey && document.activeElement === first) {
|
|
e.preventDefault();
|
|
last.focus();
|
|
} else if (!e.shiftKey && document.activeElement === last) {
|
|
e.preventDefault();
|
|
first.focus();
|
|
}
|
|
}
|
|
|
|
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";
|
|
|
|
__bdModalLastFocus = document.activeElement;
|
|
document.addEventListener("keydown", __bdModalKeydown, true);
|
|
var focusables = __bdModalFocusables();
|
|
if (focusables.length) focusables[0].focus();
|
|
}
|
|
|
|
function closeDemo() {
|
|
var ov = document.getElementById("modal-ov");
|
|
if (ov) ov.style.display = "none";
|
|
document.removeEventListener("keydown", __bdModalKeydown, true);
|
|
if (__bdModalLastFocus && typeof __bdModalLastFocus.focus === "function") __bdModalLastFocus.focus();
|
|
__bdModalLastFocus = null;
|
|
}
|
|
|
|
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);
|
|
});
|
|
}
|
|
|
|
// ── Click delegation ─────────────────────────────────────────────────────────
|
|
// Replaces the onclick="" attributes the legacy markup used to carry. A single
|
|
// document-level listener means none of this depends on script-src 'unsafe-inline'.
|
|
var ACTIONS = {
|
|
"close-demo": function () { closeDemo(); },
|
|
"close-demo-p9": function () { closeDemo(); go("p9"); },
|
|
"show-demo": function () { showDemo(); },
|
|
"toggle-mob": function () { toggleMob(); },
|
|
"submit-demo": function () { submitDemo(); },
|
|
"submit-contact": function () { submitContact(); },
|
|
"scroll-down": function () { scrollDown(); },
|
|
"go-home": function () { goHome(); },
|
|
// Mirrors the original onclick="closeBg(event)" on the overlay itself: only
|
|
// fires when the click landed on the overlay, not a descendant (the modal box).
|
|
"close-bg": function (e, el) { if (e.target === el) closeDemo(); },
|
|
};
|
|
|
|
function handleSiteClick(e) {
|
|
goPage(e);
|
|
var el = e.target.closest("[data-action]");
|
|
if (!el) return;
|
|
var run = ACTIONS[el.dataset.action];
|
|
if (run) run(e, el);
|
|
}
|
|
|
|
// ── Init ───────────────────────────────────────────────────────────────────
|
|
|
|
// window.showDemo is the one function SiteApp.tsx still reaches for directly
|
|
// (mailto-link interception, and the "Talk to us" CTAs it wires independently).
|
|
var __w = /** @type {any} */ (window);
|
|
__w.showDemo = showDemo;
|
|
|
|
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 });
|
|
document.addEventListener('click', handleSiteClick);
|
|
if (__bdFeedTimer) clearInterval(__bdFeedTimer);
|
|
__bdFeedTimer = setInterval(cycleFeed, 3400);
|
|
initCountUp();
|
|
}
|
|
|
|
export function teardownSite() {
|
|
window.removeEventListener('scroll', onScroll);
|
|
document.removeEventListener('click', handleSiteClick);
|
|
if (__bdFeedTimer) { clearInterval(__bdFeedTimer); __bdFeedTimer = null; }
|
|
document.removeEventListener('keydown', __bdModalKeydown, true);
|
|
}
|