1(function(){ 2 var form = document.getElementById('newsletterForm'); 3 if (!form) return; 4 var statusEl = document.getElementById('newsletterStatus'); 5 6 function setStatus(text, ok){ 7 if (!statusEl) return; 8 statusEl.textContent = text || ''; 9 statusEl.style.color = ok ? '#d1fae5' : '#ffe4b5'; 10 } 11 12 form.addEventListener('submit', function(e){ 13 e.preventDefault(); 14 var emailInput = form.querySelector('input[name="email"]'); 15 var firstInput = form.querySelector('input[name="firstname"]'); 16 var lastInput = form.querySelector('input[name="lastname"]'); 17 var btn = form.querySelector('button[type="submit"]'); 18 var email = (emailInput && emailInput.value || '').trim(); 19 20 // basic email validation 21 if (!email || !/^\S+@\S+\.\S+$/.test(email)){ 22 setStatus('Te rugÄm sÄ introduci un email valid.', false); 23 (emailInput||{}).focus && emailInput.focus(); 24 return; 25 } 26 27 setStatus('Se proceseazÄ abonarea...', true); 28 if (btn) btn.disabled = true; 29
30 fetch('newsman_subscribe.php', { 31 method: 'POST', 32 headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, 33 body: 'email=' + encodeURIComponent(email) + 34 '&firstname=' + encodeURIComponent((firstInput && firstInput.value || '').trim()) + 35 '&lastname=' + encodeURIComponent((lastInput && lastInput.value || '').trim()) 36 }).then(function(r){ return r.json(); }) 37 .then(function(data){ 38 if (data && data.success){ 39 setStatus(data.message || 'MulÈumim! Adresa a fost înregistratÄ.', true); 40 if (emailInput) emailInput.value = ''; 41 if (firstInput) firstInput.value = ''; 42 if (lastInput) lastInput.value = ''; 43 } else { 44 setStatus((data && data.message) || 'Ne pare rÄu, nu am putut procesa abonarea.', false); 45 } 46 }) 47 .catch(function(){ 48 setStatus('Eroare de reÈea. ÃncearcÄ din nou mai târziu.', false); 49 }) 50 .finally(function(){ if (btn) btn.disabled = false; }); 51 }); 52})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.