Evento
' + ''; break; } case 'calendario-embed': { const calData = d.calendarioEmbed || {}; const calUrl = `https://calendario.ch/?embed=true&handle=${calData.handle || 'username'}`; html += `
${calData.title || 'Prenota una consulenza online'}
`; break; } case 'usso-auth': { const authData = d.ussoAuth || {}; const title = authData.title || 'Accesso con USSO'; const subtitle = authData.subtitle || 'Accedi in 1 clic con Passkey o email. Nessuna password richiesta.'; const btnLabel = authData.buttonLabel || 'Continua con USSO'; const gate = !!authData.contentGate; html += `
>>

${title}

${subtitle}

${gate ? '
🔒 I contenuti successivi richiedono l\'accesso
' : ''}
Secured by USSO.ch · Identità sovrana elvetica
`; break; } default: if (d.text || b.content) { html += `

${d.text || b.content}

`; } } }); mainEl.innerHTML = html; initCounters(); } function initCounters() { const counters = document.querySelectorAll('.counter-grid[data-target]'); counters.forEach(el => { const targetStr = el.getAttribute('data-target'); if (!targetStr) return; const target = new Date(targetStr + 'T00:00:00').getTime(); if (isNaN(target)) return; const tick = () => { const now = Date.now(); const left = Math.max(0, target - now); const days = Math.floor(left / 86400000); const hours = Math.floor((left % 86400000) / 3600000); const mins = Math.floor((left % 3600000) / 60000); const secs = Math.floor((left % 60000) / 1000); const dEl = el.querySelector('.days'); const hEl = el.querySelector('.hours'); const mEl = el.querySelector('.mins'); const sEl = el.querySelector('.secs'); if (dEl) dEl.textContent = String(days); if (hEl) hEl.textContent = String(hours).padStart(2, '0'); if (mEl) mEl.textContent = String(mins).padStart(2, '0'); if (sEl) sEl.textContent = String(secs).padStart(2, '0'); }; tick(); setInterval(tick, 1000); }); } function initUssoBlocks() { try { var rawUser = localStorage.getItem('usso_user'); if (rawUser) { var userObj = JSON.parse(rawUser); document.querySelectorAll('.usso-auth-block').forEach(function(el) { var actions = el.querySelector('.usso-auth-actions'); var logged = el.querySelector('.usso-user-logged'); var nameEl = el.querySelector('.usso-user-name'); var emailEl = el.querySelector('.usso-user-email'); if (actions) actions.style.display = 'none'; if (logged) logged.style.display = 'block'; if (nameEl && userObj.name) nameEl.textContent = '✓ ' + userObj.name; if (emailEl && userObj.email) emailEl.textContent = userObj.email; }); } } catch(e) {} } renderNav(); renderContent(); initUssoBlocks();