alalver.pro

Contacto

Atención por WhatsApp (Buenos Aires): +54 11 4398-1275
Tiempo de respuesta: 24–48h hábiles. --:-- ART

Resultado del envío

Cookies y privacidad

Usamos cookies esenciales para mejorar tu experiencia y medir estadísticas anónimas. Procesamos los datos en servidores ubicados en Argentina. Podés cambiar tu preferencia cuando quieras desde el encabezado.
m text-gray-600 dark:text-gray-300">© '+new Date().getFullYear()+' Escuela de Periodismo AR — CABA — +54 11 3476-5902'; } } } injectPartials(); const root = document.documentElement; const themeToggleBtn = document.getElementById('theme-toggle'); const cookieBanner = document.getElementById('cookie-banner'); const cookiesAccept = document.getElementById('cookies-accept'); const cookiesDecline = document.getElementById('cookies-decline'); const consentKey = 'cookieConsent'; const themeKey = 'theme'; const formKey = 'contactFormData'; function getConsent(){ try{ return localStorage.getItem(consentKey); }catch(e){ return null; } } function setConsent(val){ try{ localStorage.setItem(consentKey, val); }catch(e){} } function canStore(){ return getConsent() === 'yes'; } function loadTheme(){ const stored = canStore() ? localStorage.getItem(themeKey) : null; const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches; const useDark = stored ? (stored === 'dark') : prefersDark; root.classList.toggle('dark', !!useDark); } function saveTheme(){ if(!canStore()) return; try{ localStorage.setItem(themeKey, root.classList.contains('dark') ? 'dark' : 'light'); }catch(e){} } function showCookieBannerIfNeeded(){ const consent = getConsent(); if(consent === 'yes' || consent === 'no') return; cookieBanner.classList.remove('hidden'); } cookiesAccept.addEventListener('click', ()=>{ setConsent('yes'); cookieBanner.classList.add('hidden'); saveTheme(); saveForm(); }); cookiesDecline.addEventListener('click', ()=>{ setConsent('no'); cookieBanner.classList.add('hidden'); try{ localStorage.removeItem(themeKey); localStorage.removeItem(formKey); }catch(e){} }); themeToggleBtn.addEventListener('click', ()=>{ root.classList.toggle('dark'); saveTheme(); }); loadTheme(); showCookieBannerIfNeeded(); const f = document.getElementById('form-contacto'); const btnSubmit = document.getElementById('btn-submit'); const mErr = document.getElementById('modal-errores'); const mOk = document.getElementById('modal-ok'); const erroresList = document.getElementById('lista-errores'); const nombre = document.getElementById('c-nombre'); const email = document.getElementById('c-email'); const tel = document.getElementById('c-telefono'); const msg = document.getElementById('c-mensaje'); const charCount = document.getElementById('char-count'); msg.setAttribute('maxlength','500'); msg.addEventListener('input', ()=>{ charCount.textContent = msg.value.length + '/500'; }); function formatArPhoneInput(value){ const digits = value.replace(/\D/g,''); let rest = digits; if(rest.startsWith('0')) rest = rest.slice(1); if(rest.startsWith('54')) rest = rest.slice(2); let out = '+54 '; let area = rest.slice(0,2); let first = rest.slice(2,6); let last = rest.slice(6,10); if(rest.length <= 2){ out += rest; } else if(rest.length <= 6){ out += area + ' ' + first; } else { out += area + ' ' + first + (last ? '-' + last : ''); } return out.trim(); } function normalizePhoneForValidation(value){ return value.replace(/\s+/g,' ').trim(); } tel.addEventListener('input', (e)=>{ const caretEnd = e.target.selectionStart; const raw = e.target.value; const formatted = formatArPhoneInput(raw); e.target.value = formatted; try{ e.target.setSelectionRange(formatted.length, formatted.length); }catch(_){} }); tel.addEventListener('blur', (e)=>{ e.target.value = formatArPhoneInput(e.target.value); }); function emailValid(v){ return /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(v.trim()); } function hasHoneypot(){ const hp = f.querySelector('input[name="website"]'); return hp && hp.value.trim().length > 0; } function openModal(modal, autoSelector){ modal.classList.remove('hidden'); const focusable = modal.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'); const first = focusable[0]; const auto = modal.querySelector(autoSelector); (auto || first)?.focus(); function trap(e){ if(e.key === 'Escape'){ closeModal(modal); } if(e.key === 'Tab'){ const fList = Array.from(focusable).filter(el=>!el.hasAttribute('disabled')); if(fList.length === 0) return; const firstEl = fList[0]; const lastEl = fList[fList.length-1]; if(e.shiftKey){ if(document.activeElement === firstEl){ e.preventDefault(); lastEl.focus(); } }else{ if(document.activeElement === lastEl){ e.preventDefault(); firstEl.focus(); } } } } modal.__trap = trap; document.addEventListener('keydown', trap); } function closeModal(modal){ modal.classList.add('hidden'); if(modal.__trap){ document.removeEventListener('keydown', modal.__trap); modal.__trap = null; } } mErr.addEventListener('click',(e)=>{ if(e.target.matches('[data-close-err], [data-close-err] *')) closeModal(mErr); }); mOk.addEventListener('click',(e)=>{ if(e.target.matches('[data-close-ok], [data-close-ok] *')) closeModal(mOk); }); function collectErrors(){ const errors = []; if (!nombre.value.trim() || nombre.value.trim().length < 2) errors.push('Nombre es obligatorio y debe tener al menos 2 caracteres.'); if (!emailValid(email.value)) errors.push('Email no es válido.'); const telVal = normalizePhoneForValidation(tel.value); const pattern = new RegExp(tel.getAttribute('pattern')); if (!pattern.test(telVal)) errors.push('Teléfono debe tener formato argentino (+54 11 1234-5678).'); if (msg.value.trim().length < 10) errors.push('Mensaje es muy corto.'); if (!f.querySelector('input[name="tema"]:checked')) errors.push('Seleccioná un tema.'); if (hasHoneypot()) errors.push('Error de validación.'); if (!navigator.onLine) errors.push('Parece que estás sin conexión. Reintentá cuando tengas internet.'); return errors; } function renderErrors(list){ erroresList.innerHTML = ''; list.forEach(err=>{ const li=document.createElement('li'); li.textContent=err; erroresList.appendChild(li); }); } function saveForm(){ if(!canStore()) return; const data = { nombre: nombre.value, email: email.value, telefono: tel.value, mensaje: msg.value, tema: (f.querySelector('input[name="tema"]:checked')||{}).value || '', sucursal: f.sucursal?.value || '' }; try{ localStorage.setItem(formKey, JSON.stringify(data)); }catch(e){} } function restoreForm(){ if(!canStore()) return; let data = null; try{ data = JSON.parse(localStorage.getItem(formKey) || 'null'); }catch(e){ data = null; } if(!data) return; if(data.nombre) nombre.value = data.nombre; if(data.email) email.value = data.email; if(data.telefono) tel.value = data.telefono; if(data.mensaje) { msg.value = data.mensaje; charCount.textContent = msg.value.length + '/500'; } if(data.tema){ const radio = f.querySelector('input[name="tema"][value="'+data.tema+'"]'); if(radio) radio.checked = true; } if(data.sucursal && f.sucursal) f.sucursal.value = data.sucursal; } restoreForm(); f.addEventListener('input', (e)=>{ saveForm(); }); f.addEventListener('submit', (e)=>{ const errores = collectErrors(); if (errores.length) { e.preventDefault(); renderErrors(errores); openModal(mErr, '[data-autofocus-err]'); return; } e.preventDefault(); btnSubmit.disabled = true; setTimeout(()=>{ btnSubmit.disabled = false; openModal(mOk, '[data-autofocus-ok]'); f.reset(); charCount.textContent = '0/500'; tel.value = ''; saveForm(); if(canStore()){ try{ localStorage.removeItem(formKey); }catch(e){} } }, 800); }); const mql = window.matchMedia('(prefers-color-scheme: dark)'); try{ mql.addEventListener('change', (e)=>{ const hasStored = canStore() ? !!localStorage.getItem(themeKey) : false; if(!hasStored){ root.classList.toggle('dark', e.matches); } }); }catch(e){} window.addEventListener('load', ()=>{ if(getConsent() === 'no'){ try{ localStorage.removeItem(themeKey); localStorage.removeItem(formKey); }catch(e){} } }); e; } if (ok) { const id = 'ALV-' + Math.random().toString(36).slice(2,7).toUpperCase() + '-' + Date.now().toString().slice(-5); ticketId.textContent = id; successModal.showModal(); form.reset(); clearDraft(); updateCounter(); updateTone(); } else { alertText.innerHTML = 'No pudimos enviar el formulario en este momento. Intentá nuevamente o escribinos a [email protected].'; alertModal.showModal(); } }); document.addEventListener('keydown', (ev) => { if (ev.key === 'Escape') { document.querySelectorAll('dialog[open]').forEach(d => d.close()); } });