Simulateur dirigeant
'; } function exporter(mode){ const res = window.__derniereSimulation; if(!res){ alert('Lancez d\'abord une simulation.'); return; } const doc = documentExport(res, mode==='pdf'); if(mode==='html'){ const b = new Blob([doc], {type:'text/html'}), a = document.createElement('a'); a.href = URL.createObjectURL(b); a.download = 'simulation-dirigeant-' + new Date().toISOString().slice(0,10) + '.html'; a.click(); setTimeout(()=>URL.revokeObjectURL(a.href), 4000); } else { const w = window.open('', '_blank'); if(!w){ alert('Autorisez les fenêtres pour ce site afin de générer le PDF.'); return; } w.document.open(); w.document.write(doc); w.document.close(); } } const MENU = $('menu-export'); $('btn-export').addEventListener('click', e=>{ e.stopPropagation(); const o = !MENU.classList.contains('ouvert'); MENU.classList.toggle('ouvert', o); $('btn-export').setAttribute('aria-expanded', o); }); MENU.addEventListener('click', e=>{ const b = e.target.closest('button[data-export]'); if(!b) return; MENU.classList.remove('ouvert'); exporter(b.dataset.export); }); document.addEventListener('pointerdown', e=>{ if(!MENU.contains(e.target) && !e.target.closest('#btn-export')) MENU.classList.remove('ouvert'); }); $('btn-exemple').onclick = ()=>charger(EXEMPLE); $('btn-vider').onclick = ()=>charger({ statut:etat.statut, situation:'couple', enfants:0, salaries:0 }); $('meta').textContent = 'Paramètres '+P.meta.millesime+' · référentiel '+P.meta.version_referentiel+' · vérifié le '+P.meta.last_verified.split('-').reverse().join('/'); charger(EXEMPLE); })();