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
+196
View File
@@ -0,0 +1,196 @@
import { useEffect, useMemo, useRef, useState } from 'react'
import { createPortal } from 'react-dom'
import { useNavigate } from 'react-router-dom'
// The site's global stylesheet is imported here so it only loads on site routes.
import './styles.css'
// Raw markup of the original site <body> (everything except the trailing <script>).
import siteHtml from './siteMarkup.txt?raw'
// Ported vanilla controller (navigation, modal, live feed, count-up).
import { configureForms, initSite, setSiteNavigator, showPage, teardownSite } from './siteController'
// Live threat-detection demos, embedded in the Mobile SDK hero (same slider
// — all scenarios, autoplaying with tabs/arrows — used at /threat-demos).
import ThreatDemosSlider from '../demo/threats/ThreatDemosSlider'
import NewsGrid from './blog/NewsGrid'
import ArticlePage from './blog/ArticlePage'
import DemoSection from './demos/DemoSection'
import DemoPlayer from './demos/DemoPlayer'
import { applyContent, useContent } from '../cms/store'
import { pageById } from '../cms/pages'
import { applyJsonLd, applyMeta, organisationJsonLd } from '../cms/seo'
import { submitLead } from '../cms/api'
import type { SiteContent } from '../cms/types'
// React islands rendered into the legacy markup. Portals (rather than extra
// roots) keep them inside this tree, so they share the router and CMS content.
const ISLANDS = [
'mobile-sdk-demo-mount',
'news-grid-mount',
'home-news-mount',
'demos-p2-mount',
'demo-halo-retina-mount',
'demo-halo-angel-mount',
'pg-article',
] as const
export interface SiteAppProps {
/** Page to show (p1…p12). Ignored when `articleSlug` is set. */
pageId?: string
/** Renders the article view at /blog/<slug>. */
articleSlug?: string
/** Admin preview: content comes from the editor's draft, not the published doc. */
previewContent?: SiteContent
/** Suppress meta/JSON-LD writes (the admin owns the document head). */
suppressMeta?: boolean
}
export default function SiteApp({ pageId = 'p1', articleSlug, previewContent, suppressMeta = false }: SiteAppProps) {
const navigate = useNavigate()
const wrapRef = useRef<HTMLDivElement>(null)
const publishedContent = useContent()
const content = previewContent || publishedContent
const [mounts, setMounts] = useState<Partial<Record<(typeof ISLANDS)[number], HTMLElement>>>({})
// ── One-time DOM setup ──────────────────────────────────────────────────────
useEffect(() => {
const wrap = wrapRef.current
if (wrap) {
// The source export nests a duplicated Contact page, leaving #pg-p9 unclosed —
// which swallows the modal and the policy pages. Hoist them back to the top
// level so the fixed-position modal and page navigation work correctly.
;['modal-ov', 'pg-p11', 'pg-p12', 'pg-article'].forEach((id) => {
const el = document.getElementById(id)
if (el && el.parentElement !== wrap) wrap.appendChild(el)
})
}
// Wire the Mobile SDK page's "live demos" callout to the threat-demo slider.
const feedCta = document.getElementById('feed-live-cta')
if (feedCta) (feedCta as HTMLElement).onclick = () => navigate('/threat-demos')
// Resolve the island containers now that the markup is in the DOM.
const found: Partial<Record<(typeof ISLANDS)[number], HTMLElement>> = {}
for (const id of ISLANDS) {
const el = document.getElementById(id)
if (el) found[id] = el
}
setMounts(found)
// Boot the ported controller and hand it the router.
setSiteNavigator((path: string) => navigate(path))
initSite(articleSlug ? 'article' : pageId)
// Reliably wire the "Talk to us" CTAs to open the Request-a-demonstration
// modal (in case the inline onclick handler doesn't bind in some contexts).
const openDemo = () => {
const fn = (window as { showDemo?: () => void }).showDemo
if (typeof fn === 'function') fn()
}
document.querySelectorAll('.bd-nav-cta').forEach((b) => {
;(b as HTMLElement).onclick = openDemo
})
document.querySelectorAll('.bd-mob-cta').forEach((b) => {
;(b as HTMLElement).onclick = () => {
const m = document.getElementById('mob-nav')
if (m) m.style.display = 'none'
openDemo()
}
})
return () => {
teardownSite()
setSiteNavigator(null)
}
// Deliberately once: the markup is static, and page switching is handled below.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
// ── Enquiry routing: mailto/external contact links open the form ─────────────
useEffect(() => {
configureForms({
formRecipient: content.settings.formRecipient,
formCc: content.settings.formCc,
onLead: (lead: Record<string, string>) => {
// Best effort: a durable record even if the visitor's mail client fails.
submitLead(lead).catch(() => {})
},
})
}, [content.settings.formRecipient, content.settings.formCc])
useEffect(() => {
const onClick = (e: MouseEvent) => {
const link = (e.target as HTMLElement | null)?.closest?.('a[href^="mailto:"]')
if (!link) return
// Every route to a human goes through the enquiry form so the visitor's
// details are captured rather than lost in a mail client.
e.preventDefault()
;(window as { showDemo?: () => void }).showDemo?.()
}
document.addEventListener('click', onClick)
return () => document.removeEventListener('click', onClick)
}, [])
// ── Apply CMS content to the markup ─────────────────────────────────────────
useEffect(() => {
if (wrapRef.current) applyContent(document, content)
}, [content])
// ── Route → page ────────────────────────────────────────────────────────────
useEffect(() => {
if (articleSlug) showPage('article', 'p7')
else showPage(pageId)
}, [pageId, articleSlug])
// ── Metadata ────────────────────────────────────────────────────────────────
const seo = useMemo(() => content.seo[pageId], [content, pageId])
useEffect(() => {
if (suppressMeta || articleSlug) return // ArticlePage owns article metadata
const page = pageById(pageId)
if (!page || !seo) return
applyMeta({
title: seo.title,
description: seo.description,
path: page.path,
image: seo.ogImage,
siteUrl: content.settings.siteUrl,
robots: page.indexable ? 'index, follow' : 'noindex, follow',
})
applyJsonLd(pageId === 'p1' ? organisationJsonLd(content.settings.siteUrl) : null)
}, [pageId, seo, articleSlug, suppressMeta, content.settings.siteUrl])
return (
<>
<div ref={wrapRef} dangerouslySetInnerHTML={{ __html: siteHtml }} />
{mounts['mobile-sdk-demo-mount'] && createPortal(<ThreatDemosSlider embedded />, mounts['mobile-sdk-demo-mount'])}
{mounts['news-grid-mount'] && createPortal(<NewsGrid />, mounts['news-grid-mount'])}
{mounts['home-news-mount'] &&
createPortal(
<NewsGrid limit={3} showFilters={false} heading="Latest news and insights" />,
mounts['home-news-mount'],
)}
{mounts['demos-p2-mount'] &&
createPortal(
<DemoSection
page="p2"
eyebrow="SEE IT IN ACTION"
heading="Five detections, as the subscriber experiences them."
blurb="Short walkthroughs of the signals the SDK reads and the action it recommends — scam calls and VOIP, scam SMS, SIM swap, per-device DNS analytics on iOS and Android, and risky app permissions."
/>,
mounts['demos-p2-mount'],
)}
{mounts['demo-halo-retina-mount'] &&
createPortal(<DemoPlayer slot={content.demos['halo-retina']} />, mounts['demo-halo-retina-mount'])}
{mounts['demo-halo-angel-mount'] &&
createPortal(<DemoPlayer slot={content.demos['halo-angel']} />, mounts['demo-halo-angel-mount'])}
{articleSlug &&
mounts['pg-article'] &&
createPortal(<ArticlePage slug={articleSlug} suppressMeta={suppressMeta} />, mounts['pg-article'])}
</>
)
}
+176
View File
@@ -0,0 +1,176 @@
import { useEffect, useMemo } from 'react'
import { useNavigate } from 'react-router-dom'
import { formatPostDate, publishedPosts, useContent } from '../../cms/store'
import { applyJsonLd, applyMeta, articleJsonLd } from '../../cms/seo'
import { categoryMeta, splitAuthor } from './NewsGrid'
import type { Post } from '../../cms/types'
/**
* A single article at /blog/<slug>. Rendered into the #pg-article container inside
* the site markup, so it inherits the real nav, footer and enquiry modal — and the
* white-section rule that makes the body copy readable.
*/
export default function ArticlePage({ slug, suppressMeta = false }: { slug: string; suppressMeta?: boolean }) {
const content = useContent()
const navigate = useNavigate()
// Drafts are reachable by direct link so they can be reviewed before going live,
// but they never appear in listings or the sitemap.
const post = useMemo(() => content.posts.find((p) => p.slug === slug), [content, slug])
const related = useMemo(() => {
const others = publishedPosts(content).filter((p) => p.slug !== slug)
const sameCategory = others.filter((p) => p.category === post?.category)
return [...sameCategory, ...others.filter((p) => p.category !== post?.category)].slice(0, 3)
}, [content, post, slug])
useEffect(() => {
if (suppressMeta) return // the admin preview leaves the document head alone
if (!post) {
applyMeta({
title: 'Article not found | BlackDice Cyber',
description: 'The article you are looking for is no longer available.',
path: `/blog/${slug}`,
siteUrl: content.settings.siteUrl,
robots: 'noindex, follow',
})
applyJsonLd(null)
return
}
applyMeta({
title: post.metaTitle || `${post.title} | BlackDice Cyber`,
description: post.metaDescription || post.excerpt,
path: `/blog/${post.slug}`,
image: post.hero || undefined,
type: 'article',
siteUrl: content.settings.siteUrl,
robots: post.status === 'draft' ? 'noindex, nofollow' : 'index, follow',
})
applyJsonLd(post.status === 'draft' ? null : articleJsonLd(post, content.settings.siteUrl))
}, [post, slug, content.settings.siteUrl, suppressMeta])
if (!post) {
return (
<section className="bd-sect t">
<div className="bd-si" style={{ maxWidth: 720 }}>
<span className="ey">NEWSROOM</span>
<h1 className="h1" style={{ fontSize: 'clamp(28px,3vw,40px)', marginBottom: 16 }}>
That article has moved.
</h1>
<p style={{ color: 'var(--t2)', fontSize: 16, marginBottom: 24 }}>
We could not find an article at <code>/blog/{slug}</code>. It may have been renamed or unpublished.
</p>
<button className="btn-p" onClick={() => navigate('/news')}>
Back to the newsroom
</button>
</div>
</section>
)
}
const cat = categoryMeta(post.category)
const { name, credit } = splitAuthor(post.author)
return (
<>
<section className="bd-hero-sh bd-article-hero">
<div className="bd-hero-gl" />
<div className="bd-si" style={{ position: 'relative', zIndex: 1 }}>
<button className="bd-article-back" onClick={() => navigate('/news')}>
← Newsroom
</button>
<span className={`news-tag ${cat.cls}`} style={{ marginBottom: 16, display: 'inline-block' }}>
{cat.label.toUpperCase()}
</span>
{post.status === 'draft' ? <span className="bd-news-draft" style={{ marginLeft: 8 }}>DRAFT — NOT PUBLISHED</span> : null}
<h1 className="h1 bd-article-title">{post.title}</h1>
<p className="bd-article-meta">
{formatPostDate(post.date)}
{name ? ` · ${name}` : ''}
</p>
</div>
</section>
<section className="bd-sect t">
<div className="bd-si bd-article-wrap">
{post.hero ? (
<figure className="bd-article-hero-img">
<img src={post.hero} alt={post.title} />
{credit ? <figcaption>{credit}</figcaption> : null}
</figure>
) : null}
<div className="bd-article-body" dangerouslySetInnerHTML={{ __html: post.body }} />
<ArticleShare post={post} siteUrl={content.settings.siteUrl} />
</div>
</section>
<section className="bd-sect t">
<div className="bd-si">
<div className="sect-hd">
<span className="ey">KEEP READING</span>
<h2 className="h2">More from BlackDice</h2>
</div>
<div className="news-grid">
{related.map((other) => (
<article key={other.id} className="news-card bd-news-card" onClick={() => navigate(`/blog/${other.slug}`)}>
<span className={`news-tag ${categoryMeta(other.category).cls}`}>
{categoryMeta(other.category).label.toUpperCase()}
</span>
<h3>{other.title}</h3>
<p className="bd-news-meta">{formatPostDate(other.date)}</p>
<p>{other.excerpt}</p>
<span className="bd-news-more">Read more →</span>
</article>
))}
</div>
</div>
</section>
<div className="cta-band">
<div className="cta-band-in">
<div>
<h2 className="h2">
Want to see this working on your network? <em>Talk to us.</em>
</h2>
</div>
<div>
<p>
Tell us about your subscriber base and we will show you the intelligence BlackDice surfaces from within
your own infrastructure.
</p>
<div className="btn-row">
<button className="btn-p" onClick={() => (window as { showDemo?: () => void }).showDemo?.()}>
Request a demonstration
</button>
</div>
</div>
</div>
</div>
</>
)
}
function ArticleShare({ post, siteUrl }: { post: Post; siteUrl: string }) {
const url = `${siteUrl.replace(/\/+$/, '')}/blog/${post.slug}`
const share = [
{ label: 'LinkedIn', href: `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(url)}` },
{ label: 'X', href: `https://twitter.com/intent/tweet?url=${encodeURIComponent(url)}&text=${encodeURIComponent(post.title)}` },
]
return (
<div className="bd-article-share">
<span className="ey">SHARE THIS ARTICLE</span>
<div>
{share.map((s) => (
<a key={s.label} href={s.href} target="_blank" rel="noopener">
{s.label}
</a>
))}
<button
onClick={() => {
navigator.clipboard?.writeText(url)
}}>
Copy link
</button>
</div>
</div>
)
}
+114
View File
@@ -0,0 +1,114 @@
import { useMemo, useState } from 'react'
import { useNavigate } from 'react-router-dom'
import { POST_CATEGORIES, type Post, type PostCategory } from '../../cms/types'
import { formatPostDate, publishedPosts, useContent } from '../../cms/store'
export const categoryMeta = (id: string) => POST_CATEGORIES.find((c) => c.id === id) || POST_CATEGORIES[0]
/** Authors are stored as "Paul Hague (Image by … on Unsplash)" — split the credit out. */
export function splitAuthor(author: string) {
const match = /^(.*?)\s*\(([^)]*)\)\s*$/.exec(author || '')
return match ? { name: match[1].trim(), credit: match[2].trim() } : { name: (author || '').trim(), credit: '' }
}
function Card({ post, onOpen }: { post: Post; onOpen: (post: Post) => void }) {
const cat = categoryMeta(post.category)
const { name } = splitAuthor(post.author)
return (
<article
className="news-card bd-news-card"
role="link"
tabIndex={0}
onClick={() => onOpen(post)}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault()
onOpen(post)
}
}}>
{post.hero ? (
<div className="bd-news-thumb">
<img src={post.hero} alt="" loading="lazy" />
</div>
) : null}
<span className={`news-tag ${cat.cls}`}>{cat.label.toUpperCase()}</span>
{post.status === 'draft' ? <span className="bd-news-draft">DRAFT</span> : null}
<h3>{post.title}</h3>
<p className="bd-news-meta">
{formatPostDate(post.date)}
{name ? ` · ${name}` : ''}
</p>
<p>{post.excerpt}</p>
<span className="bd-news-more">Read more →</span>
</article>
)
}
/**
* The newsroom grid (/news) and the home page's latest-three strip. Both read the
* same CMS post library, so publishing an article puts it everywhere it belongs.
*/
export default function NewsGrid({ limit, showFilters = true, heading }: { limit?: number; showFilters?: boolean; heading?: string }) {
const content = useContent()
const navigate = useNavigate()
const [filter, setFilter] = useState<PostCategory | 'all'>('all')
const all = useMemo(() => publishedPosts(content), [content])
const counts = useMemo(() => {
const out: Record<string, number> = { all: all.length }
for (const post of all) out[post.category] = (out[post.category] || 0) + 1
return out
}, [all])
const posts = useMemo(() => {
const filtered = filter === 'all' ? all : all.filter((p) => p.category === filter)
return limit ? filtered.slice(0, limit) : filtered
}, [all, filter, limit])
const open = (post: Post) => navigate(`/blog/${post.slug}`)
if (!all.length) {
return (
<p style={{ color: 'var(--t2)', fontSize: 15 }}>
No articles have been published yet.
</p>
)
}
return (
<>
{heading ? (
<div className="sect-hd bd-news-head">
<div>
<span className="ey">FROM THE NEWSROOM</span>
<h2 className="h2">{heading}</h2>
</div>
<button className="bd-news-all" onClick={() => navigate('/news')}>
View all articles →
</button>
</div>
) : null}
{showFilters ? (
<div className="bd-news-filters">
{[{ id: 'all', label: 'All' }, ...POST_CATEGORIES].map((cat) => (
<button
key={cat.id}
className={`bd-news-chip${filter === cat.id ? ' on' : ''}`}
onClick={() => setFilter(cat.id as PostCategory | 'all')}
disabled={!counts[cat.id]}>
{cat.label}
<span>{counts[cat.id] || 0}</span>
</button>
))}
</div>
) : null}
<div className="news-grid">
{posts.map((post) => (
<Card key={post.id} post={post} onOpen={open} />
))}
</div>
</>
)
}
+30
View File
@@ -0,0 +1,30 @@
import type { DemoSlot } from '../../cms/types'
/**
* A CMS-configured demo clip. Renders nothing until a video has been uploaded in
* /admin → Demos, so a page never shows an empty player.
*/
export default function DemoPlayer({ slot, compact = false }: { slot?: DemoSlot; compact?: boolean }) {
if (!slot || !slot.enabled || !slot.video) return null
return (
<figure className={`bd-demo-clip${compact ? ' compact' : ''}`}>
<div className="dash-frame bd-demo-frame">
<video
controls
playsInline
preload="none"
poster={slot.poster || undefined}
style={{ display: 'block', width: '100%', height: 'auto', background: '#010e14' }}>
<source src={slot.video} />
Your browser cannot play this clip.
</video>
</div>
{slot.title || slot.caption ? (
<figcaption>
{slot.title ? <strong>{slot.title}</strong> : null}
{slot.caption ? <span>{slot.caption}</span> : null}
</figcaption>
) : null}
</figure>
)
}
+74
View File
@@ -0,0 +1,74 @@
import { useState } from 'react'
import { useNavigate } from 'react-router-dom'
import { demoSlotsForPage } from '../../cms/pages'
import { useContent } from '../../cms/store'
import { THREAT_SCENARIOS } from '../../demo/threats/scenarios'
import { ThreatCinematic } from '../../demo/threats/ThreatDemo'
import DemoPlayer from './DemoPlayer'
/**
* "See it in action" for a product page: one tab per demo. A tab plays the clip
* uploaded in the CMS if there is one, and otherwise falls back to the live
* interactive demo built into this project — so the section is never empty and
* clips can be swapped in later without touching code.
*/
export default function DemoSection({ page, eyebrow, heading, blurb }: { page: string; eyebrow: string; heading: string; blurb: string }) {
const content = useContent()
const navigate = useNavigate()
const slots = demoSlotsForPage(page).filter((def) => {
const slot = content.demos[def.key]
if (slot && !slot.enabled) return false
// Keep a tab if it has either a clip or an interactive fallback.
return Boolean(def.scenario || slot?.video)
})
const [active, setActive] = useState(0)
if (!slots.length) return null
const current = slots[Math.min(active, slots.length - 1)]
const slot = content.demos[current.key] || current.defaults
const scenario = current.scenario ? THREAT_SCENARIOS.find((s) => s.id === current.scenario) : undefined
return (
<>
<div className="sect-hd">
<span className="ey">{eyebrow}</span>
<h2 className="h2">{heading}</h2>
<p>{blurb}</p>
</div>
<div className="bd-demo-tabstrip">
{slots.map((def, i) => {
const label = (content.demos[def.key] || def.defaults).title
return (
<button key={def.key} className={`bd-demo-tab${i === active ? ' on' : ''}`} onClick={() => setActive(i)}>
{label}
</button>
)
})}
</div>
<div className={`bd-demo-stage${slot.video ? '' : ' bare'}`}>
{slot.video ? (
<DemoPlayer slot={slot} />
) : scenario ? (
// No frame, no backdrop: the phone mockup sits straight on the page,
// the same way the hero demo reads.
<div className="bd-demo-interactive">
<ThreatCinematic key={scenario.id} scenario={scenario} bare />
</div>
) : null}
<p className="bd-demo-caption">{slot.caption}</p>
</div>
<div className="btn-row" style={{ marginTop: 24 }}>
<button className="btn-g" onClick={() => navigate('/threat-demos')}>
Open the full demo player →
</button>
<button className="btn-p" onClick={() => (window as { showDemo?: () => void }).showDemo?.()}>
Request a demonstration
</button>
</div>
</>
)
}
+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; }
}
File diff suppressed because it is too large Load Diff
+2447
View File
File diff suppressed because it is too large Load Diff