tractatus/public/js/media-triage-transparency.js
TheFlow 36b3ee5055 feat: comprehensive accessibility improvements (WCAG 2.1 AA)
Achieved 81% error reduction (31 → 6 errors) across 9 pages through systematic
accessibility audit and remediation.

Key improvements:
- Add aria-labels to navigation close buttons (all pages)
- Fix footer text contrast: gray-600 → gray-300 (7 pages)
- Fix button contrast: amber-600 → amber-700, green-600 → green-700
- Fix docs modal empty h2 heading issue
- Fix leader page color contrast (bulk replacement)
- Update audit script: advocate.html → leader.html

Results:
- 7 of 9 pages now fully WCAG 2.1 AA compliant
- Remaining 6 errors likely tool false positives
- All critical accessibility issues resolved

Files modified:
- public/js/components/navbar.js (mobile menu accessibility)
- public/js/components/document-cards.js (modal heading fix)
- public/*.html (footer contrast, button colors)
- public/leader.html (comprehensive color updates)
- scripts/audit-accessibility.js (page list update)

Documentation: docs/accessibility-improvements-2025-10.md

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-12 07:08:40 +13:00

82 lines
3.8 KiB
JavaScript

/**
* Media Triage Transparency - Public Statistics Display
* Demonstrates AI governance in practice with measurable transparency
*/
// Fetch and display triage statistics
async function loadTriageStats() {
const loadingState = document.getElementById('loading-state');
const statsContent = document.getElementById('stats-content');
try {
const response = await fetch('/api/media/triage-stats');
const data = await response.json();
if (!data.success) {
throw new Error('Failed to load statistics');
}
const stats = data.statistics;
// Hide loading, show content
loadingState.classList.add('hidden');
statsContent.classList.remove('hidden');
// Update key metrics
document.getElementById('stat-total').textContent = stats.total_triaged || 0;
document.getElementById('stat-values').textContent = stats.involves_values_count || 0;
// Update urgency distribution
const totalUrgency = stats.by_urgency.high + stats.by_urgency.medium + stats.by_urgency.low || 1;
const highPct = Math.round((stats.by_urgency.high / totalUrgency) * 100);
const mediumPct = Math.round((stats.by_urgency.medium / totalUrgency) * 100);
const lowPct = Math.round((stats.by_urgency.low / totalUrgency) * 100);
document.getElementById('urgency-high-count').textContent = `${stats.by_urgency.high} inquiries (${highPct}%)`;
document.getElementById('urgency-high-bar').style.width = `${highPct}%`;
document.getElementById('urgency-medium-count').textContent = `${stats.by_urgency.medium} inquiries (${mediumPct}%)`;
document.getElementById('urgency-medium-bar').style.width = `${mediumPct}%`;
document.getElementById('urgency-low-count').textContent = `${stats.by_urgency.low} inquiries (${lowPct}%)`;
document.getElementById('urgency-low-bar').style.width = `${lowPct}%`;
// Update sensitivity distribution
const totalSensitivity = stats.by_sensitivity.high + stats.by_sensitivity.medium + stats.by_sensitivity.low || 1;
const sensHighPct = Math.round((stats.by_sensitivity.high / totalSensitivity) * 100);
const sensMediumPct = Math.round((stats.by_sensitivity.medium / totalSensitivity) * 100);
const sensLowPct = Math.round((stats.by_sensitivity.low / totalSensitivity) * 100);
document.getElementById('sensitivity-high-count').textContent = `${stats.by_sensitivity.high} inquiries (${sensHighPct}%)`;
document.getElementById('sensitivity-high-bar').style.width = `${sensHighPct}%`;
document.getElementById('sensitivity-medium-count').textContent = `${stats.by_sensitivity.medium} inquiries (${sensMediumPct}%)`;
document.getElementById('sensitivity-medium-bar').style.width = `${sensMediumPct}%`;
document.getElementById('sensitivity-low-count').textContent = `${stats.by_sensitivity.low} inquiries (${sensLowPct}%)`;
document.getElementById('sensitivity-low-bar').style.width = `${sensLowPct}%`;
// Update framework compliance metrics
document.getElementById('boundary-enforcements').textContent = stats.boundary_enforcements || 0;
document.getElementById('avg-response-time').textContent = stats.avg_response_time_hours || 0;
} catch (error) {
console.error('Failed to load triage statistics:', error);
// Show error message
loadingState.innerHTML = `
<div class="bg-red-50 border border-red-200 rounded-lg p-6 text-center">
<svg class="mx-auto h-12 w-12 text-red-400 mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
<p class="text-red-800 font-medium mb-2">Failed to load statistics</p>
<p class="text-sm text-red-600">Please try again later or contact support if the problem persists.</p>
</div>
`;
}
}
// Load stats on page load
loadTriageStats();