1(function (w, d){ 2 var OPP = w.OPP; 3 var ajax = OPP.ajax; 4 var submitting = false; 5 6 function nonBlank (s) { 7 if (s && /\S/.exec(s)) { 8 return true; 9 } 10 return false; 11 } 12 13 function validateForm (f) { 14 var fields, valid = false; 15 try { 16 fields = f.elements; 17 // Require either phone number OR email address 18 // AND some message content 19 if ((nonBlank(fields.Phone.value) || 20 nonBlank(fields.Email.value)) 21 && nonBlank(fields.Content.value)) 22 { 23 valid = true; 24 } 25 } 26 catch (e) { 27 // ignore 28 } 29 return valid; 30 } 31 32 function submitSucceeded() { 33 submitting = false; 34 alert("Your message was sent."); 35 this.form && this.form.reset(); // reset the form 36 } 37 38 function submitFailed() { 39 submitting = false; 40 alert("There was a problem sending your message."); 41 } 42 43 function submitForm(form) { 44 var uri = ["age", "/", "mess"]; 45 form.elements["Auth" + "Code"].value = "ha ha"; 46 if (!!ajax) { 47 submitting = true; 48 ajax({ 49 method: 'POST', 50 uri: uri[1] + uri[2] + uri[0], 51 data: new FormData(form), 52 success: submitSucceeded, 53 error: submitFailed, 54 form: form // See submitSucceeded 55 }); 56 } else { 57 submitFailed(); 58 } 59 } 60 61 function handleSubmit(e) { 62 var f = e.target; 63 e.preventDefault(); 64 if (submitting) { 65 return; 66 } 67 try { 68 if (validateForm(f)) { 69 submitForm(f); 70 } 71 else { 72 alert('Please enter your phone number or email and a message.'); 73 } 74 } 75 catch (e) { 76 submitFailed(); 77 } 78 } 79 80 function setup() { 81 var f = d.querySelector('.contact-form form'), 82 x = f.querySelector('.my-url'); 83 if (f) { f.addEventListener('submit', handleSubmit); } 84 if (x && x.parentNode) { x.parentNode.removeChild(x); } 85 } 86 87 setup(); 88}(window, window.document));
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.