PageSourceSearch

https://fourstarpizzaploiesti.ro/js/newsletter.js

js fourstarpizzaploiesti.ro collected 2026-10-02 01:08:22 UTC 2,086 bytes, 52 lines download raw bytes

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.