← Global 10 Suite

AccessShield EU v2.6

BahaTech Software LLC · Directive (EU) 2019/882 (EAA) & WCAG 2.1 AA Engine
EU Enforcement Active · EN 301 549 v3.2.1 + BFSG + RGAA

Audit DOM Violations, Verify Luminance Contrast & Ship Legally Binding EU EAA Statements

100% client-side zero-telemetry accessibility suite. Scan raw HTML or live URLs for missing alt/ARIA/labels & heading hierarchy, compute exact WCAG 2.1 relative luminance, generate an auto-remediation JS widget, and export EAA compliance statements in EN/DE/FR/TR.

--
EAA Readiness
0
Violations Found
12.63:1
Contrast Lab
Target URL or HTML DOM Inspector
Ready — paste any HTML snippet or full page DOM below, or fetch a public URL.
0 lines · 0 elements
Line-by-Line Findings & Remediation Patches
Exact W3C WCAG 2.1 Relative Luminance Calculator
Relative Luminance L1: 0.7835
Relative Luminance L2: 0.0159
Exact Contrast Ratio (Lmax + 0.05) / (Lmin + 0.05)
12.63:1
Hue-Preserving Accessible Color Auto-Solver

Computes the mathematically closest foreground HEX keeping your original hue & saturation while meeting strict WCAG thresholds:

Live Visual Typography & UI Component Preview
Large Heading Text (24px Bold — 3.0:1 AA / 4.5:1 AAA)

Normal body copy at 16px regular weight. Under the European Accessibility Act (EN 301 549 Clause 9.1.4.3), e-commerce product descriptions, checkout labels, and legal terms must maintain at least 4.5:1 contrast against their background surface.

Interactive Button Control (3.0:1 UI)
Zero-Dependency Auto-Fix & Assistive Toolbar Configurator
Active DOM Auto-Remediation & User Controls
Generated Production Snippet (0 KB)

Drop before </body> on Shopify, WordPress, Next.js, or custom storefronts. Zero cookies, zero external requests.

Official EU EAA / EN 301 549 Legal Statement Parameters
Legal Compliance Statement Output
`; const CLEAN_SAMPLE = ` EuroStyle Accessible Checkout
EuroStyle Official Storefront Cart

Checkout Express

Billing & Shipping Information

Enter your shipping and VAT details below to complete your purchase.

`; function parseCssColor(str) { if (!str) return null; const s = str.trim().toLowerCase(); if (s.startsWith("#")) { let hex = s.slice(1); if (hex.length === 3) hex = hex.split("").map((c) => c + c).join(""); if (/^[0-9a-f]{6}$/.test(hex)) { return { r: parseInt(hex.slice(0, 2), 16), g: parseInt(hex.slice(2, 4), 16), b: parseInt(hex.slice(4, 6), 16) }; } } const m = s.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/); if (m) return { r: Math.min(255, parseInt(m[1], 10)), g: Math.min(255, parseInt(m[2], 10)), b: Math.min(255, parseInt(m[3], 10)) }; const named = { white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, b: 0 }, gray: { r: 128, g: 128, b: 128 }, grey: { r: 128, g: 128, b: 128 } }; return named[s] || null; } function rgbToHex({ r, g, b }) { return "#" + [r, g, b].map((v) => Math.max(0, Math.min(255, Math.round(v))).toString(16).padStart(2, "0")).join("").toUpperCase(); } function relativeLuminance({ r, g, b }) { const chan = (c) => { const s = c / 255; return s <= 0.04045 ? s / 12.92 : Math.pow((s + 0.055) / 1.055, 2.4); }; return 0.2126 * chan(r) + 0.7152 * chan(g) + 0.0722 * chan(b); } function contrastRatio(rgb1, rgb2) { const l1 = relativeLuminance(rgb1), l2 = relativeLuminance(rgb2); const hi = Math.max(l1, l2), lo = Math.min(l1, l2); return { ratio: (hi + 0.05) / (lo + 0.05), l1, l2, hi, lo }; } function rgbToHsl({ r, g, b }) { const rn = r / 255, gn = g / 255, bn = b / 255; const max = Math.max(rn, gn, bn), min = Math.min(rn, gn, bn); let h = 0, s = 0; const l = (max + min) / 2; if (max !== min) { const d = max - min; s = l > 0.5 ? d / (2 - max - min) : d / (max + min); switch (max) { case rn: h = (gn - bn) / d + (gn < bn ? 6 : 0); break; case gn: h = (bn - rn) / d + 2; break; case bn: h = (rn - gn) / d + 4; break; } h /= 6; } return { h, s, l }; } function hslToRgb({ h, s, l }) { if (s === 0) { const v = Math.round(l * 255); return { r: v, g: v, b: v }; } const hue2rgb = (p, q, t) => { if (t < 0) t += 1; if (t > 1) t -= 1; if (t < 1 / 6) return p + (q - p) * 6 * t; if (t < 1 / 2) return q; if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6; return p; }; const q = l < 0.5 ? l * (1 + s) : l + s - l * s; const p = 2 * l - q; return { r: Math.round(hue2rgb(p, q, h + 1 / 3) * 255), g: Math.round(hue2rgb(p, q, h) * 255), b: Math.round(hue2rgb(p, q, h - 1 / 3) * 255) }; } function solveAccessibleFg(fgRgb, bgRgb, targetRatio) { if (contrastRatio(fgRgb, bgRgb).ratio >= targetRatio) return fgRgb; const hsl = rgbToHsl(fgRgb); const goLighter = relativeLuminance(bgRgb) < 0.5; for (let step = 0; step <= 200; step++) { const testL = goLighter ? hsl.l + (1 - hsl.l) * (step / 200) : hsl.l * (1 - step / 200); const cand = hslToRgb({ h: hsl.h, s: hsl.s, l: testL }); if (contrastRatio(cand, bgRgb).ratio >= targetRatio) return cand; } return goLighter ? { r: 255, g: 255, b: 255 } : { r: 0, g: 0, b: 0 }; } let currentIssues = []; let activeFilter = "ALL"; function findLineNumber(rawHtml, needle) { if (!needle) return 1; const idx = rawHtml.indexOf(needle.slice(0, 64)); if (idx === -1) return 1; return rawHtml.slice(0, idx).split("\n").length; } function escapeHtml(s) { return String(s).replace(/&/g, "&").replace(//g, ">").replace(/"/g, """); } function outerOpeningTag(el) { const clone = el.cloneNode(false); const wrap = document.createElement("div"); wrap.appendChild(clone); const html = wrap.innerHTML; const closeIdx = html.lastIndexOf(" 0 ? html.slice(0, closeIdx) : html; } function auditHtmlSource(rawHtml) { const issues = []; const doc = new DOMParser().parseFromString(rawHtml, "text/html"); const lines = rawHtml.split("\n"); const htmlTagMatch = rawHtml.match(/]*>/i); const hasLangAttr = htmlTagMatch ? /\blang\s*=\s*["'][a-zA-Z]{2,}/i.test(htmlTagMatch[0]) : Boolean(doc.documentElement.getAttribute("lang")); if (!hasLangAttr) { issues.push({ id: "EAA-LANG-01", severity: "MAJOR", wcag: "WCAG 3.1.1 (A) · EN 301 549 9.3.1.1", line: htmlTagMatch ? findLineNumber(rawHtml, htmlTagMatch[0]) : 1, title: "Missing primary language attribute on root element", desc: "Screen readers require a valid BCP-47 lang attribute (e.g., lang=\"en\" or lang=\"de\").", before: htmlTagMatch ? htmlTagMatch[0] : "", after: ``, patchFn: (src) => src.replace(/]*\blang=)/i, ' 0) { const bodyMatch = rawHtml.match(/]*>/i); issues.push({ id: "EAA-MAIN-01", severity: "MODERATE", wcag: "WCAG 1.3.1 / 2.4.1 (A) · EN 301 549 9.2.4.1", line: bodyMatch ? findLineNumber(rawHtml, bodyMatch[0]) : 1, title: "Missing
landmark region & skip-to-content navigation", desc: "Keyboard and screen-reader users rely on
and a skip link.", before: bodyMatch ? bodyMatch[0] : "", after: `\n \n
...
`, patchFn: null }); } let imgIdx = 0; doc.querySelectorAll("img").forEach((img) => { imgIdx++; const tagStr = outerOpeningTag(img); const srcAttr = img.getAttribute("src") || ""; const line = findLineNumber(rawHtml, srcAttr ? `src="${srcAttr}"` : " s.replace(new RegExp(`(]*src=["']${srcAttr.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}["'](?![^>]*\\balt=)[^>]*)>`, "i"), `$1 alt="${inferred}">`) : null }); } }); let ctrlIdx = 0; doc.querySelectorAll("button, a[href], [role='button']").forEach((el) => { ctrlIdx++; const text = (el.textContent || "").replace(/\s+/g, " ").trim(); const ariaLabel = (el.getAttribute("aria-label") || "").trim(); const ariaLabelledby = (el.getAttribute("aria-labelledby") || "").trim(); const imgAlt = el.querySelector("img[alt]") ? (el.querySelector("img[alt]").getAttribute("alt") || "").trim() : ""; const accessibleName = text || ariaLabel || ariaLabelledby || imgAlt; const tag = el.tagName.toLowerCase(); const openTag = outerOpeningTag(el); const line = findLineNumber(rawHtml, openTag.slice(0, 32)); if (!accessibleName) { const fallbackLabel = tag === "a" ? `Navigate to ${(el.getAttribute("href") || "section").replace(/[\/#]/g, " ").trim() || "destination"}` : "Submit action"; issues.push({ id: `EAA-NAME-${ctrlIdx}`, severity: "CRITICAL", wcag: "WCAG 4.1.2 / 2.4.4 (A) · EN 301 549 9.4.1.2", line, title: `Empty <${tag}> lacks discernible accessible name or aria-label`, desc: `Screen readers announce this <${tag}> as unlabeled, blocking checkout/navigation.`, before: el.outerHTML.slice(0, 120), after: openTag.replace(new RegExp(`^<${tag}`, "i"), `<${tag} aria-label="${fallbackLabel}"`) + (el.innerHTML || "") + ``, patchFn: (s) => s.includes(el.outerHTML) ? s.replace(el.outerHTML, el.outerHTML.replace(new RegExp(`^<${tag}`, "i"), `<${tag} aria-label="${fallbackLabel}"`)) : s }); } }); let formIdx = 0; doc.querySelectorAll("input, select, textarea").forEach((input) => { const type = (input.getAttribute("type") || "text").toLowerCase(); if (["hidden", "submit", "reset", "button", "image"].includes(type)) return; formIdx++; const id = input.getAttribute("id"); const hasExplicitLabel = id ? Boolean(doc.querySelector(`label[for="${CSS.escape(id)}"]`)) : false; const hasWrappingLabel = Boolean(input.closest("label")); const hasAria = Boolean((input.getAttribute("aria-label") || "").trim() || (input.getAttribute("aria-labelledby") || "").trim()); if (!hasExplicitLabel && !hasWrappingLabel && !hasAria) { const openTag = outerOpeningTag(input); const nameHint = input.getAttribute("name") || input.getAttribute("placeholder") || `field_${formIdx}`; const generatedId = id || `eaa-field-${formIdx}`; const humanLabel = nameHint.replace(/[-_]+/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()); const fixedControl = id ? openTag : openTag.replace(/^<(input|select|textarea)/i, `<$1 id="${generatedId}"`); issues.push({ id: `EAA-FORM-${formIdx}`, severity: "CRITICAL", wcag: "WCAG 1.3.1 / 3.3.2 (A) · EN 301 549 9.1.3.1", line: findLineNumber(rawHtml, nameHint), title: `Unlabeled <${input.tagName.toLowerCase()}> form control ("${nameHint}")`, desc: "Placeholders vanish upon typing and do not satisfy WCAG 1.3.1 programmatic label rules.", before: openTag, after: `\n${fixedControl}`, patchFn: (s) => s.includes(openTag) ? s.replace(openTag, `\n ${fixedControl}`) : s }); } }); const headings = Array.from(doc.querySelectorAll("h1, h2, h3, h4, h5, h6")); if (headings.filter((h) => h.tagName === "H1").length === 0) { issues.push({ id: "EAA-H1-00", severity: "MAJOR", wcag: "WCAG 1.3.1 / 2.4.6 (AA) · EN 301 549 9.2.4.6", line: 1, title: "Page lacks a primary

heading", desc: "Start the document heading hierarchy with a top-level

.", before: headings[0] ? headings[0].outerHTML : "", after: headings[0] ? headings[0].outerHTML.replace(/^$/i, "

") : "

Main Heading

", patchFn: headings[0] ? (s) => s.replace(headings[0].outerHTML, headings[0].outerHTML.replace(/^$/i, "")) : null }); } let prevLevel = 0; headings.forEach((h, idx) => { const level = parseInt(h.tagName.slice(1), 10); if (prevLevel > 0 && level > prevLevel + 1) { const expectedTag = `h${prevLevel + 1}`; issues.push({ id: `EAA-HDG-SKIP-${idx}`, severity: "MAJOR", wcag: "WCAG 1.3.1 / 2.4.6 (AA)", line: findLineNumber(rawHtml, h.textContent.trim()), title: `Skipped heading hierarchy: jumped directly to `, desc: `Change to <${expectedTag}> to preserve sequential hierarchy.`, before: h.outerHTML, after: h.outerHTML.replace(new RegExp(`^$`, "i"), ``), patchFn: (s) => s.replace(h.outerHTML, h.outerHTML.replace(new RegExp(`^$`, "i"), ``)) }); } prevLevel = level; }); doc.querySelectorAll("[tabindex]").forEach((el, idx) => { const ti = parseInt(el.getAttribute("tabindex"), 10); if (ti > 0) { const openTag = outerOpeningTag(el); issues.push({ id: `EAA-TABINDEX-${idx}`, severity: "MAJOR", wcag: "WCAG 2.4.3 (A)", line: findLineNumber(rawHtml, `tabindex="${ti}"`), title: `Positive tabindex="${ti}" disrupts keyboard focus order`, desc: "Use tabindex=\"0\" and natural DOM order.", before: openTag, after: openTag.replace(/tabindex=["']\d+["']/i, 'tabindex="0"'), patchFn: (s) => s.replace(new RegExp(`tabindex=["']${ti}["']`), 'tabindex="0"') }); } }); doc.querySelectorAll("div[onclick], span[onclick]").forEach((el, idx) => { if (!el.getAttribute("role") || !el.hasAttribute("tabindex")) { issues.push({ id: `EAA-KBD-CLICK-${idx}`, severity: "CRITICAL", wcag: "WCAG 2.1.1 / 4.1.2 (A)", line: findLineNumber(rawHtml, "onclick="), title: `Non-interactive <${el.tagName.toLowerCase()}> with onclick handler is unreachable by keyboard`, desc: "Replace with semantic `, patchFn: (s) => s.includes(el.outerHTML) ? s.replace(el.outerHTML, ``) : s }); } }); lines.forEach((ln, idx) => { if (/outline\s*:\s*(none|0)\b/i.test(ln) && !/focus-visible/i.test(ln)) { issues.push({ id: `EAA-FOCUS-CSS-${idx}`, severity: "CRITICAL", wcag: "WCAG 2.4.7 (AA)", line: idx + 1, title: "CSS `outline: none` suppresses visible keyboard focus indicator", desc: "Replace with a high-contrast `:focus-visible` focus ring.", before: ln.trim(), after: `:focus-visible { outline: 3px solid #0ea5e9; outline-offset: 2px; }`, patchFn: (s) => s.replace(ln, ln.replace(/outline\s*:\s*(none|0)\s*;?/i, "outline: 3px solid #0ea5e9; outline-offset: 2px;")) }); } }); doc.querySelectorAll("[style]").forEach((el, idx) => { const st = el.getAttribute("style") || ""; const fgM = st.match(/(?:^|;)\s*color\s*:\s*([^;]+)/i); const bgM = st.match(/background(?:-color)?\s*:\s*([^;]+)/i); if (fgM && bgM) { const fg = parseCssColor(fgM[1]), bg = parseCssColor(bgM[1]); if (fg && bg) { const { ratio } = contrastRatio(fg, bg); if (ratio < 4.5) { const fixedFg = rgbToHex(solveAccessibleFg(fg, bg, 4.55)); const openTag = outerOpeningTag(el); issues.push({ id: `EAA-CONTRAST-INLINE-${idx}`, severity: "CRITICAL", wcag: "WCAG 1.4.3 (AA) · EN 301 549 9.1.4.3", line: findLineNumber(rawHtml, fgM[1].trim()), title: `Insufficient inline contrast ratio ${ratio.toFixed(2)}:1 (Requires ≥ 4.50:1 AA)`, desc: `Foreground ${rgbToHex(fg)} on background ${rgbToHex(bg)} fails WCAG 2.1 AA contrast.`, before: openTag, after: openTag.replace(fgM[1].trim(), fixedFg), patchFn: (s) => s.replace(st, st.replace(fgM[1].trim(), fixedFg)) }); } } } }); return { issues, headings: headings.map((h) => ({ tag: h.tagName, text: h.textContent.trim() || "(empty)" })), lineCount: lines.length, elementCount: doc.querySelectorAll("*").length }; } function renderAudit() { const res = auditHtmlSource(document.getElementById("htmlSourceInput").value); currentIssues = res.issues; document.getElementById("lineStatsNote").textContent = `${res.lineCount} lines · ${res.elementCount} DOM elements parsed`; const crit = currentIssues.filter((i) => i.severity === "CRITICAL").length; const maj = currentIssues.filter((i) => i.severity === "MAJOR").length; const mod = currentIssues.filter((i) => i.severity === "MODERATE").length; const score = Math.max(0, Math.round(100 - crit * 14 - maj * 7 - mod * 3)); const kpiScore = document.getElementById("kpiScore"); kpiScore.textContent = `${score}%`; kpiScore.style.color = score >= 90 ? "var(--emerald)" : score >= 65 ? "var(--amber)" : "var(--rose)"; document.getElementById("kpiIssues").textContent = String(currentIssues.length); document.getElementById("cntAll").textContent = String(currentIssues.length); document.getElementById("cntCrit").textContent = String(crit); document.getElementById("cntMaj").textContent = String(maj); document.getElementById("cntMod").textContent = String(mod); const hBox = document.getElementById("headingOutlineBox"); hBox.innerHTML = res.headings.length === 0 ? `Heading Hierarchy Tree: No <h1>–<h6> elements found.` : `
Document Heading Outline (${res.headings.length}):
` + res.headings.map((h) => `
<${h.tag.toLowerCase()}> ${escapeHtml(h.text)}
`).join(""); renderFilteredIssues(); } function renderFilteredIssues() { const list = document.getElementById("issuesListContainer"); const filtered = activeFilter === "ALL" ? currentIssues : currentIssues.filter((i) => i.severity === activeFilter); if (filtered.length === 0) { list.innerHTML = `
PASS · ZERO VIOLATIONS
All checked EAA / WCAG 2.1 AA rules passed!
`; return; } list.innerHTML = filtered.map((item) => { const bClass = item.severity === "CRITICAL" ? "badge-crit" : item.severity === "MAJOR" ? "badge-maj" : "badge-mod"; return `
${item.severity} Line ${item.line} ${escapeHtml(item.wcag)}
${escapeHtml(item.title)}
${escapeHtml(item.desc)}
- ${escapeHtml(item.before)} + ${escapeHtml(item.after)}
`; }).join(""); list.querySelectorAll(".copy-patch-btn").forEach((btn) => { btn.addEventListener("click", () => { navigator.clipboard.writeText(decodeURIComponent(btn.dataset.patch)); btn.textContent = "✓ Copied"; setTimeout(() => { btn.textContent = "Copy Fix"; }, 1300); }); }); } document.querySelectorAll("#issueFilterBar button").forEach((btn) => { btn.addEventListener("click", () => { document.querySelectorAll("#issueFilterBar button").forEach((b) => b.classList.remove("btn-primary")); btn.classList.add("btn-primary"); activeFilter = btn.dataset.filter; renderFilteredIssues(); }); }); document.getElementById("loadBadSampleBtn").addEventListener("click", () => { document.getElementById("htmlSourceInput").value = BROKEN_SAMPLE; renderAudit(); }); document.getElementById("loadCleanSampleBtn").addEventListener("click", () => { document.getElementById("htmlSourceInput").value = CLEAN_SAMPLE; renderAudit(); }); document.getElementById("runAuditBtn").addEventListener("click", renderAudit); document.getElementById("htmlSourceInput").addEventListener("input", () => { clearTimeout(window.__at); window.__at = setTimeout(renderAudit, 250); }); document.getElementById("htmlFileUpload").addEventListener("change", (e) => { const file = e.target.files && e.target.files[0]; if (!file) return; const r = new FileReader(); r.onload = () => { document.getElementById("htmlSourceInput").value = String(r.result || ""); renderAudit(); }; r.readAsText(file); }); document.getElementById("fetchUrlBtn").addEventListener("click", async () => { let url = document.getElementById("targetUrlInput").value.trim(); const statusEl = document.getElementById("fetchStatus"); if (!url) { statusEl.textContent = "Please enter a valid https:// URL first."; return; } if (!/^https?:\/\//i.test(url)) url = "https://" + url; statusEl.textContent = `Fetching live HTML from ${url}...`; const endpoints = [url, `https://api.allorigins.win/raw?url=${encodeURIComponent(url)}`, `https://api.codetabs.com/v1/proxy?quest=${encodeURIComponent(url)}`]; let fetchedHtml = null; for (const ep of endpoints) { try { const ctrl = new AbortController(); const t = setTimeout(() => ctrl.abort(), 7000); const resp = await fetch(ep, { signal: ctrl.signal }); clearTimeout(t); if (resp.ok) { const txt = await resp.text(); if (txt && txt.length > 40 && /<[a-zA-Z]/.test(txt)) { fetchedHtml = txt; break; } } } catch (_) {} } if (fetchedHtml) { document.getElementById("htmlSourceInput").value = fetchedHtml; document.getElementById("stSiteUrl").value = url; statusEl.innerHTML = `✓ Fetched ${fetchedHtml.length.toLocaleString()} chars from ${escapeHtml(url)}.`; renderAudit(); } else { statusEl.innerHTML = `Cross-origin blocked by target WAF — paste Page Source directly into the editor below or run our Chrome Extension!`; } }); document.getElementById("autoFixAllHtmlBtn").addEventListener("click", () => { let src = document.getElementById("htmlSourceInput").value; let applied = 0; currentIssues.forEach((iss) => { if (typeof iss.patchFn === "function") { const next = iss.patchFn(src); if (next !== src) { src = next; applied++; } } }); document.getElementById("htmlSourceInput").value = src; renderAudit(); document.getElementById("fetchStatus").innerHTML = `✓ Applied ${applied} automated accessibility patches!`; }); document.getElementById("copyPatchedHtmlBtn").addEventListener("click", (e) => { navigator.clipboard.writeText(document.getElementById("htmlSourceInput").value); e.currentTarget.textContent = "✓ Copied"; setTimeout(() => { e.currentTarget.textContent = "Copy Source"; }, 1400); }); function downloadBlob(filename, content, mime) { const blob = new Blob([content], { type: mime }); const a = document.createElement("a"); a.href = URL.createObjectURL(blob); a.download = filename; document.body.appendChild(a); a.click(); a.remove(); setTimeout(() => URL.revokeObjectURL(a.href), 2000); } document.getElementById("exportJsonBtn").addEventListener("click", () => { downloadBlob("accessshield-eaa-audit.json", JSON.stringify({ tool: "AccessShield EU v2.6", timestamp: new Date().toISOString(), findings: currentIssues.map(({ patchFn, ...r }) => r) }, null, 2), "application/json"); }); document.getElementById("exportCsvBtn").addEventListener("click", () => { const rows = [["Rule_ID", "Severity", "Line", "Standard", "Title", "Recommended_Fix"], ...currentIssues.map((i) => [i.id, i.severity, String(i.line), i.wcag, i.title, i.after])]; downloadBlob("accessshield-eaa-audit.csv", rows.map((r) => r.map((c) => `"${String(c).replace(/"/g, '""')}"`).join(",")).join("\n"), "text/csv;charset=utf-8"); }); document.getElementById("exportReportHtmlBtn").addEventListener("click", () => { const html = `EAA Audit Report

AccessShield EU — WCAG 2.1 AA & EAA Audit Report

${currentIssues.map((i) => ``).join("")}
SeverityLineStandardIssueFix
${i.severity}${i.line}${escapeHtml(i.wcag)}${escapeHtml(i.title)}${escapeHtml(i.after)}
`; downloadBlob("accessshield-eaa-audit-report.html", html, "text/html;charset=utf-8"); }); // Contrast Lab const fgPicker = document.getElementById("fgColorPicker"), bgPicker = document.getElementById("bgColorPicker"); const fgHex = document.getElementById("fgHexInput"), bgHex = document.getElementById("bgHexInput"); function updateContrastLab() { const fg = parseCssColor(fgHex.value) || { r: 226, g: 232, b: 240 }; const bg = parseCssColor(bgHex.value) || { r: 15, g: 23, b: 42 }; const fgNorm = rgbToHex(fg), bgNorm = rgbToHex(bg); fgPicker.value = fgNorm.toLowerCase(); bgPicker.value = bgNorm.toLowerCase(); const { ratio, l1, l2, hi, lo } = contrastRatio(fg, bg); const ratioStr = `${ratio.toFixed(2)}:1`; document.getElementById("contrastRatioDisplay").textContent = ratioStr; document.getElementById("kpiContrast").textContent = ratioStr; document.getElementById("fgLumNote").textContent = `Relative Luminance L1: ${l1.toFixed(4)}`; document.getElementById("bgLumNote").textContent = `Relative Luminance L2: ${l2.toFixed(4)}`; document.getElementById("contrastFormulaMath").textContent = `(${hi.toFixed(4)} + 0.05) / (${lo.toFixed(4)} + 0.05) = ${ratio.toFixed(4)}`; const checks = [ { label: "Normal Text AA", req: 4.5, ref: "WCAG 1.4.3 (≥ 4.5:1)" }, { label: "Normal Text AAA", req: 7.0, ref: "WCAG 1.4.6 (≥ 7.0:1)" }, { label: "Large Text AA", req: 3.0, ref: "≥ 18pt / 14pt Bold" }, { label: "Large Text AAA", req: 4.5, ref: "WCAG 1.4.6 Large" }, { label: "UI & Icons AA", req: 3.0, ref: "WCAG 1.4.11 Non-Text" } ]; document.getElementById("wcagMatrixGrid").innerHTML = checks.map((c) => { const pass = ratio >= c.req; return `
${c.label}${pass ? "PASS" : "FAIL"}
${c.ref}
`; }).join(""); const preview = document.getElementById("liveContrastPreviewBox"); preview.style.color = fgNorm; preview.style.backgroundColor = bgNorm; document.getElementById("previewMetaTag").textContent = `FG ${fgNorm} on BG ${bgNorm} (${ratioStr})`; const aaFg = rgbToHex(solveAccessibleFg(fg, bg, 4.52)); const aaaFg = rgbToHex(solveAccessibleFg(fg, bg, 7.05)); document.getElementById("solverSuggestions").innerHTML = ` `; document.getElementById("applyAaSolveBtn").addEventListener("click", () => { fgHex.value = aaFg; updateContrastLab(); }); document.getElementById("applyAaaSolveBtn").addEventListener("click", () => { fgHex.value = aaaFg; updateContrastLab(); }); document.getElementById("contrastCssOutput").value = `:root {\n --eaa-surface-bg: ${bgNorm};\n --eaa-text-primary: ${ratio >= 4.5 ? fgNorm : aaFg};\n --eaa-text-aaa: ${ratio >= 7.0 ? fgNorm : aaaFg};\n --eaa-focus-ring: ${aaFg};\n}\n.accessible-component {\n background-color: var(--eaa-surface-bg);\n color: var(--eaa-text-primary);\n}\n.accessible-component :focus-visible {\n outline: 3px solid var(--eaa-focus-ring);\n outline-offset: 2px;\n}`; } fgPicker.addEventListener("input", () => { fgHex.value = fgPicker.value.toUpperCase(); updateContrastLab(); }); bgPicker.addEventListener("input", () => { bgHex.value = bgPicker.value.toUpperCase(); updateContrastLab(); }); fgHex.addEventListener("input", updateContrastLab); bgHex.addEventListener("input", updateContrastLab); document.getElementById("swapColorsBtn").addEventListener("click", () => { const t = fgHex.value; fgHex.value = bgHex.value; bgHex.value = t; updateContrastLab(); }); document.getElementById("copyContrastCssBtn").addEventListener("click", (e) => { navigator.clipboard.writeText(document.getElementById("contrastCssOutput").value); e.currentTarget.textContent = "✓ Copied"; setTimeout(() => { e.currentTarget.textContent = "Copy Accessible CSS Patch"; }, 1400); }); // Widget Builder function buildWidgetJsSource() { const color = document.getElementById("wBrandColorHex").value.trim() || "#0EA5E9"; const pos = document.getElementById("wPosition").value; const lang = document.getElementById("wLang").value; const stmtUrl = document.getElementById("wStatementUrl").value.trim() || "/accessibility"; const domPatch = document.getElementById("wFeatDomPatch").checked; const fontScale = document.getElementById("wFeatFontScale").checked; const hiContrast = document.getElementById("wFeatContrast").checked; const dyslexia = document.getElementById("wFeatDyslexia").checked; const labels = { en: { title: "Accessibility (EU EAA)", scale: "Increase Text Size", contrast: "High Contrast + Focus Rings", spacing: "Dyslexia Spacing & Pause Motion", reset: "Reset Settings", stmt: "Accessibility Statement" }, de: { title: "Barrierefreiheit (BFSG)", scale: "Schriftgröße erhöhen", contrast: "Hoher Kontrast & Fokusring", spacing: "Lesefreundlicher Abstand", reset: "Zurücksetzen", stmt: "Erklärung zur Barrierefreiheit" }, fr: { title: "Accessibilité (RGAA / EAA)", scale: "Agrandir le texte", contrast: "Contraste élevé & Focus", spacing: "Espacement dyslexie", reset: "Réinitialiser", stmt: "Déclaration d'accessibilité" }, tr: { title: "Erişilebilirlik (AB EAA)", scale: "Metin Boyutunu Büyüt", contrast: "Yüksek Kontrast & Odak", spacing: "Disleksi Aralığı & Animasyon Durdur", reset: "Sıfırla", stmt: "Erişilebilirlik Beyanı" } }[lang]; return `/* AccessShield EU Auto-Remediation Widget — BahaTech Software LLC */ (function(){ if(window.__accessShieldLoaded)return;window.__accessShieldLoaded=true; var cfg={color:${JSON.stringify(color)},pos:${JSON.stringify(pos)},stmt:${JSON.stringify(stmtUrl)},L:${JSON.stringify(labels)}}; var st=document.createElement("style"); st.textContent="html.as-hc{filter:contrast(1.28)!important}html.as-hc *:focus{outline:3px solid "+cfg.color+"!important;outline-offset:2px!important}html.as-dys *{letter-spacing:.06em!important;word-spacing:.14em!important;animation:none!important;transition:none!important}#as-eaa-btn{position:fixed;bottom:20px;"+cfg.pos+":20px;z-index:2147483646;background:"+cfg.color+";color:#fff;border:none;border-radius:999px;padding:11px 16px;font:700 13px/1 system-ui,sans-serif;cursor:pointer;box-shadow:0 8px 24px rgba(0,0,0,.35)}#as-eaa-panel{position:fixed;bottom:68px;"+cfg.pos+":20px;z-index:2147483646;width:280px;background:#0b1222;color:#f8fafc;border:1px solid "+cfg.color+";border-radius:12px;padding:14px;font:13px/1.45 system-ui,sans-serif;display:none;box-shadow:0 16px 40px rgba(0,0,0,.5)}#as-eaa-panel button{width:100%;margin-top:7px;padding:8px 10px;border-radius:7px;border:1px solid #233559;background:#111b31;color:#f8fafc;cursor:pointer;text-align:left;font-weight:600}"; document.head.appendChild(st); ${domPatch ? `function patchDom(){if(!document.querySelector("main,[role='main']")&&document.body.firstElementChild)document.body.firstElementChild.setAttribute("role","main");document.querySelectorAll("img:not([alt])").forEach(function(i){i.setAttribute("alt","");i.setAttribute("role","presentation")});document.querySelectorAll("button,a[href]").forEach(function(b){if(!b.textContent.trim()&&!b.getAttribute("aria-label")&&!b.querySelector("img[alt]"))b.setAttribute("aria-label",b.getAttribute("title")||b.getAttribute("href")||"Interactive control")});}if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",patchDom);else patchDom();` : ""} var scaleIdx=0,scales=[100,115,130,150],btn=document.createElement("button");btn.id="as-eaa-btn";btn.type="button";btn.textContent="♿ "+cfg.L.title; var pnl=document.createElement("div");pnl.id="as-eaa-panel";pnl.setAttribute("role","dialog"); pnl.innerHTML=""+cfg.L.title+""+${fontScale ? `""+` : `""+`}${hiContrast ? `""+` : `""+`}${dyslexia ? `""+` : `""+`}""+cfg.L.stmt+" →"; btn.onclick=function(){pnl.style.display=pnl.style.display==="block"?"none":"block"}; pnl.addEventListener("click",function(e){var a=e.target.getAttribute("data-act");if(!a)return;if(a==="scale"){scaleIdx=(scaleIdx+1)%scales.length;document.documentElement.style.fontSize=scales[scaleIdx]+"%";e.target.textContent=cfg.L.scale+" ("+scales[scaleIdx]+"%)"}if(a==="hc")document.documentElement.classList.toggle("as-hc");if(a==="dys")document.documentElement.classList.toggle("as-dys");if(a==="reset"){scaleIdx=0;document.documentElement.style.fontSize="";document.documentElement.classList.remove("as-hc","as-dys")}}); document.body.appendChild(btn);document.body.appendChild(pnl); })();`; } function refreshWidgetBuilder() { const js = buildWidgetJsSource(); document.getElementById("widgetCodeOutput").value = `