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

Diff for /draft/form.min.js between version 1.42 and 1.73

version 1.42, 2024/03/28 20:35:21 version 1.73, 2024/03/31 14:15:20
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 = string.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);
 }  }
   
Line 26  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 39  async function sendData() {
Line 47  async function sendData() {
                                 'response-field': false,                                  'response-field': false,
                                 retry: 'never',                                  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...";
 /* --------------------- */  
 const ob = {mail: em, sub: su, msg: ms, id: token };  
 var data="",  
         status="",  
         feed=JSON.stringify(ob);  
 $.post("/feedbk/", feed, function(data, status){  
     console.log("Data: " + data + "\nStatus: " + status);  
 });  
 /* --------------------- */  
 //var re="";  
 //re=fetch('/feedbk/', {  
 //    method: 'POST',  
 //    headers: {  
 //        'Accept': 'application/json',  
 //        'Content-Type': 'application/json'  
 //    },  
 //    body: JSON.stringify({ "cfem": "a@b.ru", "cfsu" : "subject", "cfme" : "message", "cfto" : "token" })  
 //});  
  //  .then(response => response.json())  
  //  .then(response => console.log(JSON.stringify(response)))  
 //      console.log(re);  
   
   
   
   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.42  
changed lines
  Added in v.1.73

https://cvs.kroczynski.net