(function() {
async function loadStats() {
try {
const response = await fetch('assets/data/stats.json');
if (!response.ok) {
console.log('Stats not available - stats.json not found');
return;
}
const stats = await response.json();
const testCountElements = document.querySelectorAll('#test-count-header, .test-count');
testCountElements.forEach(el => {
if (el) {
el.textContent = stats.test_count.toLocaleString();
}
});
const roundedTestCountElements = document.querySelectorAll('.test-count-rounded');
roundedTestCountElements.forEach(el => {
if (el) {
const roundedCount = Math.floor(stats.test_count / 100) * 100;
el.textContent = roundedCount.toLocaleString();
}
});
let statsLoaded = false;
document.querySelectorAll('[data-stat]').forEach(el => {
const statKey = el.getAttribute('data-stat');
if (stats[statKey] !== undefined) {
el.textContent = stats[statKey].toLocaleString();
statsLoaded = true;
}
});
if (statsLoaded) {
const statsGrid = document.getElementById('stats-grid');
const statsLoading = document.getElementById('stats-loading');
if (statsGrid) statsGrid.style.display = 'grid';
if (statsLoading) statsLoading.style.display = 'none';
}
} catch (error) {
console.log('Stats not available:', error);
}
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', loadStats);
} else {
loadStats();
}
})();