← Return to site
${title} — BagEngine ${content}`); } function loadEmails() { const emails = JSON.parse(localStorage.getItem('sl_captured_emails') || '[]'); const container = document.getElementById('emailList'); if (!container) return; if (emails.length === 0) { container.innerHTML = '

No emails captured yet.

'; return; } container.innerHTML = emails.map(e => `
${escapeHtml(e.email)}
${new Date(e.timestamp).toLocaleString()}
`).join(''); } function exportEmails() { const emails = JSON.parse(localStorage.getItem('sl_captured_emails') || '[]'); if (emails.length === 0) return alert('No emails to export'); let csv = 'Email,Date,Page\n'; emails.forEach(e => { csv += `"${e.email}",${new Date(e.timestamp).toISOString()},"${e.source || ''}"\n`; }); const blob = new Blob([csv], { type: 'text/csv' }); const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = `bagengine_emails_${new Date().toISOString().split('T')[0]}.csv`; a.click(); } function clearEmails() { if (confirm('Delete ALL captured emails? Cannot be undone.')) { localStorage.setItem('sl_captured_emails', '[]'); loadEmails(); updateStats(); alert('All emails cleared'); } } function savePopupConfig() { const config = { enabled: document.getElementById('popupEnabled').value === 'true', headline: document.getElementById('popupHeadline').value, subheadline: document.getElementById('popupSubheadline').value, ctaText: document.getElementById('popupCtaText').value }; localStorage.setItem('sl_popup_config', JSON.stringify(config)); alert('Popup settings saved!'); } function updateStats() { const emails = JSON.parse(localStorage.getItem('sl_captured_emails') || '[]'); document.getElementById('statEmails').innerText = emails.length; } function escapeHtml(str) { if (!str) return ''; return str.replace(/[&<>]/g, m => ({'&':'&','<':'<','>':'>'}[m])); } function initAdmin() { loadArticles(); loadKeywords(); loadEmails(); updateStats(); }