






















































































































const cloned = document.documentElement.cloneNode(true); const prev = cloned.querySelector('#embeddedNotes'); if (prev && prev.parentNode) prev.parentNode.removeChild(prev); const body = cloned.querySelector('body') || cloned; const holder = document.createElement('div'); holder.innerHTML = payload; body.appendChild(holder.firstChild); const html = '\n'+cloned.outerHTML; const blob = new Blob([html], {type:'text/html;charset=utf-8'}); const url = URL.createObjectURL(blob); const a = document.createElement('a'); const dt = new Date().toISOString().replace(/[:.]/g,'-'); a.href = url; a.download = 'tehran_map_with_baked_notes_'+dt+'.html'; document.body.appendChild(a); a.click(); setTimeout(()=>{ URL.revokeObjectURL(url); a.remove(); }, 1500); } catch(e){ alert('Could not bake notes: ' + e.message); } } function boot(){ const btn = document.getElementById('bakeNotesFab'); if (!btn) return; btn.addEventListener('click', ()=>{ btn.classList.add('busy'); setTimeout(()=>{ try{ bakeNotesIntoHTML(); } finally{ btn.classList.remove('busy'); }}, 20); }); } window.addEventListener('load', boot); })();