(function(){ function initMobileCards(tbl){ if (!tbl) return; const heads = Array.from(tbl.querySelectorAll('thead th')).map(th => th.textContent.trim()); tbl.querySelectorAll('tbody tr').forEach(tr => { Array.from(tr.children).forEach((td, i) => { if (!td.hasAttribute('data-label')) { td.setAttribute('data-label', heads[i] || ''); } }); }); // ✅ une seule source de vérité document.documentElement.classList.add('mc-ready'); } function ready(fn){ if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', fn); else fn(); } ready(function(){ const tbl = document.getElementById('table_rdv') || document.querySelector('table.mobile-cards'); initMobileCards(tbl); }); })();