[BACK]Return to form.min.js CVS log [TXT][DIR] Up to [local] / draft

Diff for /draft/form.min.js between version 1.19 and 1.74

version 1.19, 2024/03/28 18:57:11 version 1.74, 2024/03/31 14:17:27
Line 1 
Line 1 
 const form = document.querySelector("#cform");  const form = document.querySelector("#cform");
   
 function validateEmail(email) {  function validateEmail(email) {
         const regex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;          var em = email.toLowerCase();
         return regex.test(email);          // 1. max len = 96
           const regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+(\.[a-zA-Z]{2,})+$/;
           return regex.test(em);
 };  };
   
 function validateSubject(subject) {  function validateSubject(subject) {
           // 1. remove special chars
           // 2. min len = 4
           // 3. max len = 96
         return (subject.length>5);          return (subject.length>5);
 }  }
   
 function validateMsg(msg) {  function validateMsg(msg) {
           // 1. remove special chars
           // 2. min len = 4
           // 3. max len = 2048
         return (msg.length>5);          return (msg.length>5);
 }  }
   
 async function sendData() {  async function sendData() {
         const form = document.querySelector("#cform");  
         const formData = new FormData(form);  
         var er = 0;          var er = 0;
                 em = document.getElementById("cfem").value,                  em = document.getElementById("cfem").value,
                 su = document.getElementById("cfsu").value,                  su = document.getElementById("cfsu").value,
Line 28  async function sendData() {
Line 34  async function sendData() {
                 ii.textContent="One or more fields have an error. Please check and try again.";                  ii.textContent="One or more fields have an error. Please check and try again.";
         } else {          } else {
                 var fc = document.querySelectorAll(".wpcf7-form-control");                  var fc = document.querySelectorAll(".wpcf7-form-control");
                 ii.textContent="All good.";                  ii.textContent="Please wait...";
                 fc.forEach((f) => {                  fc.forEach((f) => {
                 f.disabled=true;                  f.disabled=true;
                         l=f;                          l=f;
Line 38  async function sendData() {
Line 44  async function sendData() {
                         turnstile.render('#cfcontainer', {                          turnstile.render('#cfcontainer', {
                                 theme: 'light',                                  theme: 'light',
                                 sitekey: '0x4AAAAAAAVpXFEy152AON1L',                                  sitekey: '0x4AAAAAAAVpXFEy152AON1L',
                                   'response-field': false,
                                   retry: 'never',
                                 'error-callback': function(e) {                                  'error-callback': function(e) {
                                         turnstile.remove();  //                                      turnstile.remove();
                                           ii.textContent="Cloudflare Turnstile verification error. Try again later."
                                 },                                  },
                                 callback: function(token) {                                  callback: function(token) {
                                         ii.textContent="Sent";                                          const dataToSend = JSON.stringify({"add": em, "sub": su, "msg": ms, "tok": token});
                                         console.log(`Challenge Success ${token}`);                                          ii.textContent="Sending...";
 /* ---------- */  
   try {  
           console.log(`TRY`);  
     const response = await fetch("https://draft.hgk.global/feedbk/", {  
       method: "POST",  
       body: formData,  
     });  
         console.log(`AWAIT`);  
     console.log(await response.text());  
           console.log(`RESPONSE`);  
   } catch (e) {  
                                                 console.log(`ERROR`);  
     console.error(e);  
   }  
 }  
 /* ---------- */  
   
   
   fetch("/feedbk/", {
           credentials: "same-origin",
           mode: "same-origin",
           method: "post",
           headers: { "Content-Type": "application/json" },
           body: dataToSend
   })
         .then(response => response.json())
             .then(json => ii.textContent=json['msg'])
   
   
   
                                 },                                  },
                         });                          });
                           turnstile.remove();
                 });                  });
         }          }
 };  };

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.74

https://cvs.kroczynski.net