async function loadHistory() { try { const resp = await fetch(`${API_BASE}/api/history`); if (!resp.ok) return; const reports = await resp.json(); const container = document.getElementById('history-list'); if (reports.length === 0) { container.innerHTML = '

Aucun rapport disponible

'; return; } let html = ''; reports.forEach(r => { const isoText = r.isotopes.length > 0 ? r.isotopes.join(', ') : 'background uniquement'; html += `
${r.date.split('T')[0]} ${r.cps_mean.toFixed(1)} CPS ${r.isotope_count} isotope(s)

Live time: ${r.live_time_hours.toFixed(1)}h | Total: ${r.total_counts} coups

Isotopes: ${isoText}

Background: ${r.background_subtracted ? 'soustrait' : 'non soustrait'}

`; }); container.innerHTML = html; } catch {} } function toggleDetails(el) { const details = el.querySelector('.history-details'); details.classList.toggle('open'); } // Load on tab switch document.querySelector('[data-tab="history"]').addEventListener('click', loadHistory);