Build a cross-locale hreflang parity dashboard: reciprocal checks, cluster parity, and…
- User
Build a cross-locale hreflang parity dashboard: reciprocal checks, cluster parity, and escalations.
Assistant
Build a cross-locale hreflang parity dashboard: reciprocal checks, cluster parity, and escalations.
The user wants me to build a cross-locale hreflang parity dashboard. This is a specialized SEO tool for international websites that checks:
This is a complex data visualization dashboard, so I need to think about:
Let me design this with:
Key features to implement:
Color scheme - I'll go with a dark technical theme:
Typography:
Let me build this properly with all the checks and visualizations. This is a specialized SEO tool for international sites. I'll build a comprehensive dashboard with hreflang relationship analysis, cluster visualization, and issue escalation tracking.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hreflang Parity Dashboard</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<style>
:root {
--bg: #0a0e14;
--bg-elevated: #111820;
--bg-card: #161d27;
--fg: #e6edf3;
--fg-muted: #7d8590;
--border: #2d3640;
--accent: #00d4aa;
--accent-dim: rgba(0, 212, 170, 0.15);
--warning: #f0a020;
--warning-dim: rgba(240, 160, 32, 0.15);
--error: #f85149;
--error-dim: rgba(248, 81, 73, 0.15);
--info: #58a6ff;
}
* {
box-sizing: border-box;
}
body {
font-family: 'Space Grotesk', sans-serif;
background: var(--bg);
color: var(--fg);
min-height: 100vh;
}
.mono {
font-family: 'JetBrains Mono', monospace;
}
.bg-grid {
background-image:
linear-gradient(rgba(0, 212, 170, 0.03) 1px, transparent 1px),
linear-gradient(90deg, rgba(0, 212, 170, 0.03) 1px, transparent 1px);
background-size: 40px 40px;
}
.glow-accent {
box-shadow: 0 0 40px rgba(0, 212, 170, 0.2);
}
.status-pulse {
animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
@keyframes slideIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes countUp {
from { opacity: 0; transform: scale(0.8); }
to { opacity: 1; transform: scale(1); }
}
.animate-slide {
animation: slideIn 0.5s ease-out forwards;
}
.animate-count {
animation: countUp 0.3s ease-out forwards;
}
.cluster-node {
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.cluster-node:hover {
transform: scale(1.1);
filter: brightness(1.2);
}
.edge-line {
stroke-dasharray: 5, 5;
animation: dashMove 1s linear infinite;
}
@keyframes dashMove {
to { stroke-dashoffset: -10; }
}
.tab-active {
background: var(--accent-dim);
border-color: var(--accent);
color: var(--accent);
}
.scrollbar-thin::-webkit-scrollbar {
width: 6px;
height: 6px;
}
.scrollbar-thin::-webkit-scrollbar-track {
background: var(--bg);
}
.scrollbar-thin::-webkit-scrollbar-thumb {
background: var(--border);
border-radius: 3px;
}
.issue-row {
transition: background 0.2s ease;
}
.issue-row:hover {
background: var(--bg-elevated);
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}
.progress-ring {
transition: stroke-dashoffset 1s ease-out;
}
</style>
</head>
<body class="bg-grid">
<div class="min-h-screen">
<!-- Header -->
<header class="border-b border-[var(--border)] bg-[var(--bg-elevated)]">
<div class="max-w-[1600px] mx-auto px-4 sm:px-6 lg:px-8 py-4">
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
<div class="flex items-center gap-3">
<div class="w-10 h-10 rounded-lg bg-[var(--accent-dim)] flex items-center justify-center">
<svg class="w-6 h-6 text-[var(--accent)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"/>
</svg>
</div>
<div>
<h1 class="text-xl font-bold">Hreflang Parity Dashboard</h1>
<p class="text-sm text-[var(--fg-muted)]">Cross-locale validation and cluster analysis</p>
</div>
</div>
<div class="flex items-center gap-3">
<div class="flex items-center gap-2 px-3 py-2 bg-[var(--bg-card)] rounded-lg border border-[var(--border)]">
<div class="w-2 h-2 rounded-full bg-[var(--accent)] status-pulse"></div>
<span class="text-sm text-[var(--fg-muted)]">Last scan: <span class="text-[var(--fg)] mono">2 min ago</span></span>
</div>
<button id="refreshBtn" class="px-4 py-2 bg-[var(--accent)] text-[var(--bg)] rounded-lg font-medium hover:brightness-110 transition flex items-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
</svg>
Refresh
</button>
</div>
</div>
</div>
</header>
<main class="max-w-[1600px] mx-auto px-4 sm:px-6 lg:px-8 py-6">
<!-- Summary Cards -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-6" id="summaryCards">
<!-- Cards injected by JS -->
</div>
<!-- Main Content Grid -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- Left Column: Cluster Visualization + Issues -->
<div class="lg:col-span-2 space-y-6">
<!-- Cluster Visualization -->
<div class="bg-[var(--bg-card)] rounded-xl border border-[var(--border)] overflow-hidden">
<div class="px-5 py-4 border-b border-[var(--border)] flex items-center justify-between">
<div>
<h2 class="font-semibold text-lg">Cluster Visualization</h2>
<p class="text-sm text-[var(--fg-muted)]">Hreflang relationship graph</p>
</div>
<div class="flex items-center gap-2">
<button id="clusterPrev" class="p-2 rounded-lg border border-[var(--border)] hover:bg-[var(--bg-elevated)] transition" aria-label="Previous cluster">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/>
</svg>
</button>
<span class="mono text-sm px-3 py-1 bg-[var(--bg)] rounded-lg border border-[var(--border)]">
<span id="clusterIndex">1</span> / <span id="clusterTotal">8</span>
</span>
<button id="clusterNext" class="p-2 rounded-lg border border-[var(--border)] hover:bg-[var(--bg-elevated)] transition" aria-label="Next cluster">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
</svg>
</button>
</div>
</div>
<div class="p-5">
<div class="relative">
<svg id="clusterGraph" viewBox="0 0 600 300" class="w-full h-auto">
<!-- Graph rendered by JS -->
</svg>
</div>
<!-- Legend -->
<div class="flex flex-wrap items-center gap-4 mt-4 pt-4 border-t border-[var(--border)]">
<div class="flex items-center gap-2">
<div class="w-3 h-3 rounded-full bg-[var(--accent)]"></div>
<span class="text-xs text-[var(--fg-muted)]">Valid reciprocal</span>
</div>
<div class="flex items-center gap-2">
<div class="w-3 h-3 rounded-full bg-[var(--warning)]"></div>
<span class="text-xs text-[var(--fg-muted)]">Missing return</span>
</div>
<div class="flex items-center gap-2">
<div class="w-3 h-3 rounded-full bg-[var(--error)]"></div>
<span class="text-xs text-[var(--fg-muted)]">Broken link</span>
</div>
<div class="flex items-center gap-2">
<div class="w-3 h-0.5 bg-[var(--fg-muted)]"></div>
<span class="text-xs text-[var(--fg-muted)]">hreflang reference</span>
</div>
</div>
</div>
</div>
<!-- Issues Table -->
<div class="bg-[var(--bg-card)] rounded-xl border border-[var(--border)] overflow-hidden">
<div class="px-5 py-4 border-b border-[var(--border)]">
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
<div>
<h2 class="font-semibold text-lg">Detected Issues</h2>
<p class="text-sm text-[var(--fg-muted)]">Reciprocal and parity failures</p>
</div>
<div class="flex items-center gap-2">
<!-- Filter Tabs -->
<div class="flex bg-[var(--bg)] rounded-lg p-1 border border-[var(--border)]">
<button class="filter-tab px-3 py-1.5 text-sm rounded-md transition tab-active" data-filter="all">All</button>
<button class="filter-tab px-3 py-1.5 text-sm rounded-md transition" data-filter="reciprocal">Reciprocal</button>
<button class="filter-tab px-3 py-1.5 text-sm rounded-md transition" data-filter="parity">Parity</button>
<button class="filter-tab px-3 py-1.5 text-sm rounded-md transition" data-filter="broken">Broken</button>
</div>
</div>
</div>
</div>
<div class="overflow-x-auto scrollbar-thin">
<table class="w-full">
<thead class="bg-[var(--bg-elevated)]">
<tr class="text-left text-xs text-[var(--fg-muted)] uppercase tracking-wider">
<th class="px-5 py-3 font-medium">Severity</th>
<th class="px-5 py-3 font-medium">Type</th>
<th class="px-5 py-3 font-medium">Source URL</th>
<th class="px-5 py-3 font-medium">Target Locale</th>
<th class="px-5 py-3 font-medium">Issue</th>
<th class="px-5 py-3 font-medium">Action</th>
</tr>
</thead>
<tbody id="issuesTable" class="divide-y divide-[var(--border)]">
<!-- Rows injected by JS -->
</tbody>
</table>
</div>
</div>
</div>
<!-- Right Column: Stats + Escalations -->
<div class="space-y-6">
<!-- Parity Score -->
<div class="bg-[var(--bg-card)] rounded-xl border border-[var(--border)] p-5">
<h2 class="font-semibold text-lg mb-4">Overall Parity Score</h2>
<div class="flex items-center justify-center">
<div class="relative">
<svg class="w-40 h-40 transform -rotate-90">
<circle cx="80" cy="80" r="70" stroke="var(--border)" stroke-width="8" fill="none"/>
<circle id="parityRing" cx="80" cy="80" r="70" stroke="var(--accent)" stroke-width="8" fill="none"
stroke-linecap="round" stroke-dasharray="439.8" stroke-dashoffset="439.8" class="progress-ring"/>
</svg>
<div class="absolute inset-0 flex flex-col items-center justify-center">
<span id="parityScore" class="text-4xl font-bold">0</span>
<span class="text-sm text-[var(--fg-muted)]">parity score</span>
</div>
</div>
</div>
<div class="mt-5 grid grid-cols-3 gap-3 text-center">
<div class="p-3 bg-[var(--accent-dim)] rounded-lg">
<div id="validCount" class="text-xl font-bold text-[var(--accent)]">0</div>
<div class="text-xs text-[var(--fg-muted)]">Valid</div>
</div>
<div class="p-3 bg-[var(--warning-dim)] rounded-lg">
<div id="warningCount" class="text-xl font-bold text-[var(--warning)]">0</div>
<div class="text-xs text-[var(--fg-muted)]">Warnings</div>
</div>
<div class="p-3 bg-[var(--error-dim)] rounded-lg">
<div id="errorCount" class="text-xl font-bold text-[var(--error)]">0</div>
<div class="text-xs text-[var(--fg-muted)]">Errors</div>
</div>
</div>
</div>
<!-- Locale Coverage -->
<div class="bg-[var(--bg-card)] rounded-xl border border-[var(--border)] p-5">
<h2 class="font-semibold text-lg mb-4">Locale Coverage</h2>
<div id="localeCoverage" class="space-y-3">
<!-- Injected by JS -->
</div>
</div>
<!-- Escalations -->
<div class="bg-[var(--bg-card)] rounded-xl border border-[var(--border)] overflow-hidden">
<div class="px-5 py-4 border-b border-[var(--border)] bg-[var(--error-dim)]">
<div class="flex items-center gap-2">
<svg class="w-5 h-5 text-[var(--error)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
</svg>
<h2 class="font-semibold text-lg text-[var(--error)]">Escalations Required</h2>
</div>
<p class="text-sm text-[var(--fg-muted)] mt-1">Critical issues needing immediate attention</p>
</div>
<div id="escalationsList" class="divide-y divide-[var(--border)] max-h-[400px] overflow-y-auto scrollbar-thin">
<!-- Injected by JS -->
</div>
</div>
<!-- Quick Actions -->
<div class="bg-[var(--bg-card)] rounded-xl border border-[var(--border)] p-5">
<h2 class="font-semibold text-lg mb-4">Quick Actions</h2>
<div class="space-y-2">
<button id="exportBtn" class="w-full px-4 py-3 bg-[var(--bg-elevated)] border border-[var(--border)] rounded-lg text-left hover:border-[var(--accent)] transition flex items-center gap-3 group">
<svg class="w-5 h-5 text-[var(--fg-muted)] group-hover:text-[var(--accent)] transition" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
</svg>
<div>
<div class="font-medium">Export Report</div>
<div class="text-xs text-[var(--fg-muted)]">Download CSV with all issues</div>
</div>
</button>
<button id="validateBtn" class="w-full px-4 py-3 bg-[var(--bg-elevated)] border border-[var(--border)] rounded-lg text-left hover:border-[var(--accent)] transition flex items-center gap-3 group">
<svg class="w-5 h-5 text-[var(--fg-muted)] group-hover:text-[var(--accent)] transition" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
<div>
<div class="font-medium">Re-validate All</div>
<div class="text-xs text-[var(--fg-muted)]">Full site recrawl</div>
</div>
</button>
<button id="slackBtn" class="w-full px-4 py-3 bg-[var(--bg-elevated)] border border-[var(--border)] rounded-lg text-left hover:border-[var(--accent)] transition flex items-center gap-3 group">
<svg class="w-5 h-5 text-[var(--fg-muted)] group-hover:text-[var(--accent)] transition" fill="currentColor" viewBox="0 0 24 24">
<path d="M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zM6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313zM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zM8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312zM18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834zM17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312zM15.165 18.956a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zM15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z"/>
</svg>
<div>
<div class="font-medium">Send to Slack</div>
<div class="text-xs text-[var(--fg-muted)]">Alert engineering team</div>
</div>
</button>
</div>
</div>
</div>
</div>
</main>
</div>
<!-- Toast Notification -->
<div id="toast" class="fixed bottom-6 right-6 px-4 py-3 bg-[var(--bg-card)] border border-[var(--border)] rounded-lg shadow-xl transform translate-y-20 opacity-0 transition-all duration-300 flex items-center gap-3 z-50">
<svg id="toastIcon" class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>
</svg>
<span id="toastMessage">Action completed</span>
</div>
<script>
// ========== DATA ==========
const localeData = {
'en-US': { name: 'English (US)', pages: 1240, color: '#00d4aa' },
'en-GB': { name: 'English (UK)', pages: 1180, color: '#00b894' },
'de-DE': { name: 'German', pages: 890, color: '#58a6ff' },
'fr-FR': { name: 'French', pages: 756, color: '#a371f7' },
'es-ES': { name: 'Spanish', pages: 702, color: '#f0a020' },
'ja-JP': { name: 'Japanese', pages: 534, color: '#f85149' },
'zh-CN': { name: 'Chinese (Simplified)', pages: 489, color: '#ff7b72' },
'pt-BR': { name: 'Portuguese (BR)', pages: 412, color: '#79c0ff' }
};
const clusters = [
{
id: 'homepage',
name: 'Homepage Cluster',
nodes: [
{ locale: 'en-US', url: '/en-us/', x: 300, y: 50, status: 'valid' },
{ locale: 'en-GB', url: '/en-gb/', x: 150, y: 120, status: 'valid' },
{ locale: 'de-DE', url: '/de-de/', x: 450, y: 120, status: 'warning' },
{ locale: 'fr-FR', url: '/fr-fr/', x: 100, y: 220, status: 'valid' },
{ locale: 'es-ES', url: '/es-es/', x: 250, y: 250, status: 'error' },
{ locale: 'ja-JP', url: '/ja-jp/', x: 400, y: 220, status: 'valid' },
{ locale: 'zh-CN', url: '/zh-cn/', x: 500, y: 250, status: 'warning' }
],
edges: [
{ from: 'en-US', to: 'en-GB', status: 'valid' },
{ from: 'en-US', to: 'de-DE', status: 'valid' },
{ from: 'en-US', to: 'fr-FR', status: 'valid' },
{ from: 'en-US', to: 'es-ES', status: 'valid' },
{ from: 'en-US', to: 'ja-JP', status: 'valid' },
{ from: 'en-US', to: 'zh-CN', status: 'valid' },
{ from: 'en-GB', to: 'en-US', status: 'valid' },
{ from: 'de-DE', to: 'en-US', status: 'missing' },
{ from: 'fr-FR', to: 'en-US', status: 'valid' },
{ from: 'es-ES', to: 'en-US', status: 'broken' },
{ from: 'ja-JP', to: 'en-US', status: 'valid' },
{ from: 'zh-CN', to: 'en-US', status: 'missing' }
]
},
{
id: 'products',
name: 'Products Page Cluster',
nodes: [
{ locale: 'en-US', url: '/en-us/products/', x: 300, y: 50, status: 'valid' },
{ locale: 'en-GB', url: '/en-gb/products/', x: 150, y: 120, status: 'valid' },
{ locale: 'de-DE', url: '/de-de/produkte/', x: 450, y: 120, status: 'valid' },
{ locale: 'fr-FR', url: '/fr-fr/produits/', x: 100, y: 220, status: 'warning' },
{ locale: 'es-ES', url: '/es-es/productos/', x: 350, y: 220, status: 'valid' },
{ locale: 'ja-JP', url: '/ja-jp/products/', x: 500, y: 180, status: 'valid' }
],
edges: [
{ from: 'en-US', to: 'en-GB', status: 'valid' },
{ from: 'en-US', to: 'de-DE', status: 'valid' },
{ from: 'en-US', to: 'fr-FR', status: 'valid' },
{ from: 'en-US', to: 'es-ES', status: 'valid' },
{ from: 'en-US', to: 'ja-JP', status: 'valid' },
{ from: 'en-GB', to: 'en-US', status: 'valid' },
{ from: 'de-DE', to: 'en-US', status: 'valid' },
{ from: 'fr-FR', to: 'en-US', status: 'missing' },
{ from: 'es-ES', to: 'en-US', status: 'valid' },
{ from: 'ja-JP', to: 'en-US', status: 'valid' }
]
},
{
id: 'pricing',
name: 'Pricing Cluster',
nodes: [
{ locale: 'en-US', url: '/en-us/pricing/', x: 300, y: 80, status: 'valid' },
{ locale: 'en-GB', url: '/en-gb/pricing/', x: 150, y: 150, status: 'error' },
{ locale: 'de-DE', url: '/de-de/preise/', x: 450, y: 150, status: 'valid' },
{ locale: 'fr-FR', url: '/fr-fr/tarifs/', x: 200, y: 250, status: 'valid' },
{ locale: 'es-ES', url: '/es-es/precios/', x: 400, y: 250, status: 'valid' }
],
edges: [
{ from: 'en-US', to: 'en-GB', status: 'valid' },
{ from: 'en-US', to: 'de-DE', status: 'valid' },
{ from: 'en-US', to: 'fr-FR', status: 'valid' },
{ from: 'en-US', to: 'es-ES', status: 'valid' },
{ from: 'en-GB', to: 'en-US', status: 'broken' },
{ from: 'de-DE', to: 'en-US', status: 'valid' },
{ from: 'fr-FR', to: 'en-US', status: 'valid' },
{ from: 'es-ES', to: 'en-US', status: 'valid' }
]
}
];
const issues = [
{ id: 1, severity: 'error', type: 'reciprocal', source: '/es-es/', sourceLocale: 'es-ES', targetLocale: 'en-US', issue: 'Missing return link to en-US', url: 'https://example.com/es-es/' },
{ id: 2, severity: 'error', type: 'broken', source: '/es-es/', sourceLocale: 'es-ES', targetLocale: 'en-US', issue: 'hreflang points to 404 page', url: 'https://example.com/es-es/' },
{ id: 3, severity: 'warning', type: 'reciprocal', source: '/de-de/', sourceLocale: 'de-DE', targetLocale: 'en-US', issue: 'Missing return link to en-US', url: 'https://example.com/de-de/' },
{ id: 4, severity: 'warning', type: 'parity', source: '/de-de/', sourceLocale: 'de-DE', targetLocale: 'fr-FR', issue: 'Cluster has 6 locales, page only references 4', url: 'https://example.com/de-de/' },
{ id: 5, severity: 'warning', type: 'reciprocal', source: '/zh-cn/', sourceLocale: 'zh-CN', targetLocale: 'en-US', issue: 'Missing return link to en-US', url: 'https://example.com/zh-cn/' },
{ id: 6, severity: 'error', type: 'broken', source: '/en-gb/pricing/', sourceLocale: 'en-GB', targetLocale: 'en-US', issue: 'hreflang URL returns 404', url: 'https://example.com/en-gb/pricing/' },
{ id: 7, severity: 'warning', type: 'parity', source: '/fr-fr/produits/', sourceLocale: 'fr-FR', targetLocale: 'de-DE', issue: 'Missing reference that exists in cluster', url: 'https://example.com/fr-fr/produits/' },
{ id: 8, severity: 'error', type: 'reciprocal', source: '/pt-br/', sourceLocale: 'pt-BR', targetLocale: 'es-ES', issue: 'es-ES links to pt-BR but not reciprocal', url: 'https://example.com/pt-br/' },
{ id: 9, severity: 'warning', type: 'parity', source: '/ja-jp/about/', sourceLocale: 'ja-JP', targetLocale: 'zh-CN', issue: 'Missing zh-CN alternate', url: 'https://example.com/ja-jp/about/' },
{ id: 10, severity: 'error', type: 'broken', source: '/fr-fr/contact/', sourceLocale: 'fr-FR', targetLocale: 'de-DE', issue: 'German URL returns 500 error', url: 'https://example.com/fr-fr/contact/' }
];
const escalations = [
{ id: 1, priority: 'critical', title: 'Spanish locale completely broken', description: 'es-ES has 15 pages with broken hreflang chains affecting SEO indexing', affected: 15, reportedBy: 'Auto-detection', time: '2 hours ago' },
{ id: 2, priority: 'critical', title: 'Pricing page reciprocal failure', description: 'en-GB pricing page creates redirect loop with en-US version', affected: 1, reportedBy: 'User report', time: '45 min ago' },
{ id: 3, priority: 'high', title: 'German locale missing 23 return links', description: 'de-DE pages not properly referencing back to source locales', affected: 23, reportedBy: 'Scheduled scan', time: '3 hours ago' },
{ id: 4, priority: 'high', title: 'Chinese simplified parity gap', description: 'zh-CN pages missing alternates for 4 locales in cluster', affected: 12, reportedBy: 'Auto-detection', time: '1 day ago' }
];
// ========== STATE ==========
let currentCluster = 0;
let currentFilter = 'all';
// ========== INITIALIZATION ==========
document.addEventListener('DOMContentLoaded', () => {
renderSummaryCards();
renderClusterGraph();
renderIssuesTable();
renderLocaleCoverage();
renderEscalations();
animateParityScore();
setupEventListeners();
staggerAnimations();
});
// ========== RENDER FUNCTIONS ==========
function renderSummaryCards() {
const stats = calculateStats();
const container = document.getElementById('summaryCards');
const cards = [
{ label: 'Total Pages Scanned', value: stats.totalPages.toLocaleString(), icon: 'document', trend: '+12 this week', color: 'accent' },
{ label: 'Valid Hreflang Pairs', value: stats.validPairs.toLocaleString(), icon: 'check', trend: `${stats.validPercent}% valid`, color: 'accent' },
{ label: 'Missing Reciprocals', value: stats.missingReciprocals, icon: 'warning', trend: 'Needs attention', color: 'warning' },
{ label: 'Broken Links', value: stats.brokenLinks, icon: 'error', trend: 'Critical', color: 'error' }
];
container.innerHTML = cards.map((card, i) => `
<div class="bg-[var(--bg-card)] rounded-xl border border-[var(--border)] p-5 animate-slide" style="animation-delay: ${i * 100}ms">
<div class="flex items-start justify-between">
<div>
<p class="text-sm text-[var(--fg-muted)]">${card.label}</p>
<p class="text-3xl font-bold mt-1 animate-count" style="animation-delay: ${i * 100 + 200}ms">${card.value}</p>
<p class="text-xs text-[var(--${card.color})] mt-2">${card.trend}</p>
</div>
<div class="w-10 h-10 rounded-lg bg-[var(--${card.color}-dim)] flex items-center justify-center">
${getIcon(card.icon, card.color)}
</div>
</div>
</div>
`).join('');
}
function renderClusterGraph() {
const svg = document.getElementById('clusterGraph');
const cluster = clusters[currentCluster];
document.getElementById('clusterIndex').textContent = currentCluster + 1;
document.getElementById('clusterTotal').textContent = clusters.length;
let html = `
<defs>
<filter id="glow">
<feGaussianBlur stdDeviation="3" result="coloredBlur"/>
<feMerge>
<feMergeNode in="coloredBlur"/>
<feMergeNode in="SourceGraphic"/>
</feMerge>
</filter>
</defs>
<text x="300" y="20" text-anchor="middle" fill="var(--fg-muted)" font-size="12">${cluster.name}</text>
`;
// Draw edges first (behind nodes)
cluster.edges.forEach(edge => {
const fromNode = cluster.nodes.find(n => n.locale === edge.from);
const toNode = cluster.nodes.find(n => n.locale === edge.to);
if (fromNode && toNode) {
const color = edge.status === 'valid' ? 'var(--accent)' :
edge.status === 'missing' ? 'var(--warning)' : 'var(--error)';
const dashClass = edge.status !== 'valid' ? 'edge-line' : '';
html += `
<line x1="${fromNode.x}" y1="${fromNode.y}" x2="${toNode.x}" y2="${toNode.y}"
stroke="${color}" stroke-width="2" opacity="0.6" class="${dashClass}"/>
<polygon points="${getArrowHead(fromNode.x, fromNode.y, toNode.x, toNode.y)}"
fill="${color}" opacity="0.6"/>
`;
}
});
// Draw nodes
cluster.nodes.forEach(node => {
const localeInfo = localeData[node.locale];
const color = node.status === 'valid' ? 'var(--accent)' :
node.status === 'warning' ? 'var(--warning)' : 'var(--error)';
const glowFilter = node.status !== 'valid' ? 'url(#glow)' : '';
html += `
<g class="cluster-node" style="cursor: pointer" data-locale="${node.locale}">
<circle cx="${node.x}" cy="${node.y}" r="28" fill="var(--bg-card)" stroke="${color}" stroke-width="3" filter="${glowFilter}"/>
<text x="${node.x}" y="${node.y - 5}" text-anchor="middle" fill="var(--fg)" font-size="10" font-weight="600">${node.locale.split('-')[0]}</text>
<text x="${node.x}" y="${node.y + 8}" text-anchor="middle" fill="${color}" font-size="8">${node.status.toUpperCase()}</text>
</g>
`;
});
svg.innerHTML = html;
// Add node click handlers
svg.querySelectorAll('.cluster-node').forEach(node => {
node.addEventListener('click', () => {
const locale = node.dataset.locale;
showToast(`Viewing ${locale} page details`, 'info');
});
});
}
function renderIssuesTable() {
const tbody = document.getElementById('issuesTable');
const filtered = currentFilter === 'all' ? issues :
issues.filter(i => i.type === currentFilter);
tbody.innerHTML = filtered.map((issue, i) => `
<tr class="issue-row animate-slide" style="animation-delay: ${i * 50}ms">
<td class="px-5 py-3">
<span class="inline-flex items-center gap-1.5 px-2 py-1 rounded-md text-xs font-medium
${issue.severity === 'error' ? 'bg-[var(--error-dim)] text-[var(--error)]' : 'bg-[var(--warning-dim)] text-[var(--warning)]'}">
${issue.severity === 'error' ? 'Error' : 'Warning'}
</span>
</td>
<td class="px-5 py-3">
<span class="text-xs mono text-[var(--fg-muted)] uppercase">${issue.type}</span>
</td>
<td class="px-5 py-3">
<div class="flex items-center gap-2">
<span class="text-xs px-1.5 py-0.5 rounded bg-[var(--bg)] border border-[var(--border)] mono">${issue.sourceLocale}</span>
<span class="mono text-sm truncate max-w-[180px]" title="${issue.source}">${issue.source}</span>
</div>
</td>
<td class="px-5 py-3">
<span class="text-xs px-1.5 py-0.5 rounded bg-[var(--bg)] border border-[var(--border)] mono">${issue.targetLocale}</span>
</td>
<td class="px-5 py-3">
<span class="text-sm text-[var(--fg-muted)]">${issue.issue}</span>
</td>
<td class="px-5 py-3">
<button class="px-3 py-1.5 text-xs font-medium bg-[var(--accent-dim)] text-[var(--accent)] rounded-lg hover:bg-[var(--accent)] hover:text-[var(--bg)] transition"
onclick="showToast('Opening URL: ${issue.url}', 'info')">
View
</button>
</td>
</tr>
`).join('');
}
function renderLocaleCoverage() {
const container = document.getElementById('localeCoverage');
const entries = Object.entries(localeData);
container.innerHTML = entries.map(([code, data]) => {
const coverage = Math.floor(70 + Math.random() * 30);
return `
<div class="group">
<div class="flex items-center justify-between mb-1">
<div class="flex items-center gap-2">
<div class="w-3 h-3 rounded" style="background: ${data.color}"></div>
<span class="text-sm">${data.name}</span>
</div>
<span class="text-xs mono text-[var(--fg-muted)]">${data.pages} pages</span>
</div>
<div class="h-1.5 bg-[var(--bg)] rounded-full overflow-hidden">
<div class="h-full rounded-full transition-all duration-1000 group-hover:brightness-125"
style="width: ${coverage}%; background: ${data.color}"></div>
</div>
</div>
`;
}).join('');
}
function renderEscalations() {
const container = document.getElementById('escalationsList');
container.innerHTML = escalations.map((esc, i) => `
<div class="p-4 hover:bg-[var(--bg-elevated)] transition cursor-pointer animate-slide" style="animation-delay: ${i * 100}ms"
onclick="showToast('Opening escalation #${esc.id}', 'info')">
<div class="flex items-start justify-between gap-3">
<div class="flex-1">
<div class="flex items-center gap-2 mb-1">
<span class="px-2 py-0.5 text-xs font-medium rounded
${esc.priority === 'critical' ? 'bg-[var(--error-dim)] text-[var(--error)]' : 'bg-[var(--warning-dim)] text-[var(--warning)]'}">
${esc.priority.toUpperCase()}
</span>
<span class="text-xs text-[var(--fg-muted)]">${esc.time}</span>
</div>
<h4 class="font-medium text-sm">${esc.title}</h4>
<p class="text-xs text-[var(--fg-muted)] mt-1">${esc.description}</p>
<div class="flex items-center gap-3 mt-2">
<span class="text-xs text-[var(--fg-muted)]">${esc.affected} pages affected</span>
<span class="text-xs text-[var(--fg-muted)]">via ${esc.reportedBy}</span>
</div>
</div>
<svg class="w-4 h-4 text-[var(--fg-muted)] flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
</svg>
</div>
</div>
`).join('');
}
function animateParityScore() {
const score = 87;
const circumference = 2 * Math.PI * 70;
const offset = circumference - (score / 100) * circumference;
setTimeout(() => {
document.getElementById('parityRing').style.strokeDashoffset = offset;
// Animate count
const scoreEl = document.getElementById('parityScore');
let current = 0;
const increment = score / 30;
const timer = setInterval(() => {
current += increment;
if (current >= score) {
current = score;
clearInterval(timer);
}
scoreEl.textContent = Math.round(current);
}, 30);
// Update stats
document.getElementById('validCount').textContent = '5,847';
document.getElementById('warningCount').textContent = '156';
document.getElementById('errorCount').textContent = '23';
}, 500);
}
// ========== EVENT HANDLERS ==========
function setupEventListeners() {
// Cluster navigation
document.getElementById('clusterPrev').addEventListener('click', () => {
currentCluster = (currentCluster - 1 + clusters.length) % clusters.length;
renderClusterGraph();
});
document.getElementById('clusterNext').addEventListener('click', () => {
currentCluster = (currentCluster + 1) % clusters.length;
renderClusterGraph();
});
// Filter tabs
document.querySelectorAll('.filter-tab').forEach(tab => {
tab.addEventListener('click', () => {
document.querySelectorAll('.filter-tab').forEach(t => t.classList.remove('tab-active'));
tab.classList.add('tab-active');
currentFilter = tab.dataset.filter;
renderIssuesTable();
});
});
// Action buttons
document.getElementById('refreshBtn').addEventListener('click', () => {
showToast('Initiating fresh scan...', 'info');
document.getElementById('refreshBtn').disabled = true;
setTimeout(() => {
document.getElementById('refreshBtn').disabled = false;
showToast('Scan complete! No new issues found.', 'success');
}, 2000);
});
document.getElementById('exportBtn').addEventListener('click', () => {
showToast('Generating CSV report...', 'info');
setTimeout(() => {
showToast('Report downloaded: hreflang-report.csv', 'success');
}, 1000);
});
document.getElementById('validateBtn').addEventListener('click', () => {
showToast('Full site validation queued. ETA: 15 minutes.', 'info');
});
document.getElementById('slackBtn').addEventListener('click', () => {
showToast('Alert sent to #engineering-seo channel', 'success');
});
// Keyboard navigation
document.addEventListener('keydown', (e) => {
if (e.key === 'ArrowLeft') {
document.getElementById('clusterPrev').click();
} else if (e.key === 'ArrowRight') {
document.getElementById('clusterNext').click();
}
});
}
// ========== UTILITIES ==========
function calculateStats() {
return {
totalPages: 6203,
validPairs: 5847,
validPercent: 94,
missingReciprocals: issues.filter(i => i.type === 'reciprocal').length,
brokenLinks: issues.filter(i => i.type === 'broken').length
};
}
function getIcon(type, color) {
const icons = {
document: `<svg class="w-5 h-5 text-[var(--${color})]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
</svg>`,
check: `<svg class="w-5 h-5 text-[var(--${color})]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>`,
warning: `<svg class="w-5 h-5 text-[var(--${color})]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
</svg>`,
error: `<svg class="w-5 h-5 text-[var(--${color})]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>`
};
return icons[type] || icons.document;
}
function getArrowHead(x1, y1, x2, y2) {
const angle = Math.atan2(y2 - y1, x2 - x1);
const arrowLength = 8;
// Offset the arrow slightly before the target
const nodeRadius = 28;
const offsetX = x2 - Math.cos(angle) * nodeRadius;
const offsetY = y2 - Math.sin(angle) * nodeRadius;
const p1x = offsetX - arrowLength * Math.cos(angle - Math.PI / 6);
const p1y = offsetY - arrowLength * Math.sin(angle - Math.PI / 6);
const p2x = offsetX - arrowLength * Math.cos(angle + Math.PI / 6);
const p2y = offsetY - arrowLength * Math.sin(angle + Math.PI / 6);
return `${offsetX},${offsetY} ${p1x},${p1y} ${p2x},${p2y}`;
}
function showToast(message, type = 'success') {
const toast = document.getElementById('toast');
const icon = document.getElementById('toastIcon');
const msg = document.getElementById('toastMessage');
msg.textContent = message;
const icons = {
success: `<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>`,
info: `<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>`,
error: `<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"/>`
};
icon.innerHTML = icons[type] || icons.info;
icon.style.color = type === 'error' ? 'var(--error)' : type === 'success' ? 'var(--accent)' : 'var(--info)';
toast.style.transform = 'translateY(0)';
toast.style.opacity = '1';
setTimeout(() => {
toast.style.transform = 'translateY(20px)';
toast.style.opacity = '0';
}, 3000);
}
function staggerAnimations() {
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animate-slide');
}
});
}, { threshold: 0.1 });
document.querySelectorAll('.issue-row, [class*="animate"]').forEach(el => {
observer.observe(el);
});
}
</script>
</body>
</html>