1 2 3// ***** Handle the Request Product Manual form 4const requestForm = document.getElementById('requestForm'); 5if (requestForm) { 6 7 const requestModal = new bootstrap.Modal(requestForm); 8 9 requestForm.form = requestForm.getElementsByTagName('form')[0]; 10 11 // Form cannot be sent unless it is visible 12 requestForm.addEventListener('show.bs.modal', function() { 13 14 // Get current time from the server 15 var http = getHTTPObject(); 16 17 http.open('GET', '/includes/ajax/manual.php', true); 18 http.onreadystatechange = function() { 19 if (http.readyState == 4) { 20 requestForm.form.elements['stamp'].value = http.responseText; 21 } 22 }; 23 http.send(null); 24 25 }, false); 26 27 requestForm.addEventListener('hide.bs.modal', function() { 28 requestForm.form.elements['stamp'].value = ''; 29 }, false); 30 31 requestForm.form.addEventListener('submit', function(e) { 32 e.preventDefault(); 33 34 // ***** Check validity 35 // Stamp - required 36 if (!this['stamp']) return false; 37 38 // Name - required 39 this['reqName'].value = this['reqName'].value.trim(); 40 if (!this['reqName'].value.length) { 41 alert('Please include your name in the field provided.'); 42 return false; 43 } 44 45 // Email - required and valid structure 46 this['reqEmail'].value = this['reqEmail'].value.trim().toLowerCase(); 47 if (!this['reqEmail'].value.length) { 48 alert('Please include your email address in the field provided.'); 49 return false; 50 } 51 if (!this['reqEmail'].value.match(/^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/)) { 52 alert('Please enter a valid email address.'); 53 return false; 54 } 55 56 // Phone 57 this['reqPhone'].value = this['reqPhone'].value.replace(/[^0-9.()-]/g, '').trim(); 58 if (this['reqPhone'].value.length < 7) { 59 alert('Please include your phone number in the field provided.'); 60 return false; 61 } 62 63 // Company 64 this['reqCompany'].value = this['reqCompany'].value.trim(); 65 if (this['reqCompany'].value.length < 2) { 66 alert('Please include your company name in the field provided.'); 67 return false; 68 } 69 70 // Location 71 this['reqLocation'].value = this['reqLocation'].value.trim(); 72 if (this['reqLocation'].value.length < 3) { 73 alert('Please include your company location in the field provided.'); 74 return false; 75 } 76 77 // Project 78 this['reqProject'].value = this['reqProject'].value.trim(); 79 if (this['reqProject'].value.length < 2) { 80 alert('Please include the name of your project (or \'N/A\') in the field provided.'); 81 return false; 82 } 83 84 // Representative 85 this['reqRep'].value = this['reqRep'].value.trim(); 86 if (this['reqRep'].value.length < 3) { 87 alert('Please include your Evertz sales representative name in the field provided.'); 88 return false; 89 } 90 91 // Do they own this product? 92 var reqOwn = document.getElementsByName('reqOwn'), reqOwnVal; 93 if (!reqOwn[0].checked && !reqOwn[1].checked) { 94 alert('Please indicate whether or not you own this product.'); 95 return false; 96 } else reqOwnVal = (reqOwn[0].checked) ? reqOwn[0].value : reqOwn[1].value; 97 98 // Hide form with throbber 99 let reqForm = this.querySelector('#requestForm form fieldset'); 100 let reqWorking = this.querySelector('#requestForm form fieldset + div'); 101 reqForm.classList.add('d-none'); 102 reqWorking.classList.remove('d-none'); 103 reqWorking.classList.add('d-flex'); 104 105 var values = [ 106 'reqName=' + encodeURIComponent(this['reqName'].value), 107 'reqEmail=' + encodeURIComponent(this['reqEmail'].value), 108 'reqPhone=' + encodeURIComponent(this['reqPhone'].value), 109 'reqCompany=' + encodeURIComponent(this['reqCompany'].value), 110 'reqLocation=' + encodeURIComponent(this['reqLocation'].value), 111 'reqProject=' + encodeURIComponent(this['reqProject'].value), 112 'reqRep=' + encodeURIComponent(this['reqRep'].value), 113 'reqOwn=' + encodeURIComponent(reqOwnVal), 114 'stamp=' + encodeURIComponent(this['stamp'].value), 115 'product=' + encodeURIComponent(window.location.pathname.replace(/^.+products\//, '')) 116 ].join('&'); 117 118 let http = getHTTPObject(); 119 120 http.open('POST', '/includes/ajax/manual.php', true); 121 http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 122 http.onreadystatechange = function() { 123 if (http.readyState == 4) { 124 if (http.responseText.indexOf('Success') === 0) { 125 126 // Display Success message for a couple seconds 127 while (reqWorking.firstChild) reqWorking.removeChild(reqWorking.firstChild); 128 let h3 = document.createElement('h3'); 129 h3.appendChild(document.createTextNode('Request has been sent!')); 130 reqWorking.appendChild(h3); 131 132 requestForm.form.reset();
133 document.querySelector('#requestForm .modal-footer').classList.add('d-none'); 134 135 setTimeout(function() { requestModal.hide(); }, 2500); 136 137 } else { 138 139 // Show an error message 140 while (reqWorking.firstChild) reqWorking.removeChild(reqWorking.firstChild); 141 let pre = document.createElement('pre'); 142 pre.appendChild(document.createTextNode(http.responseText)); 143 reqWorking.appendChild(pre); 144 145 let button = document.createElement('button'); 146 button.setAttribute('type', 'button'); 147 button.appendChild(document.createTextNode('OK')); 148 button.classList.add('form-control'); 149 button.classList.add('mx-auto'); 150 button.addEventListener('click', function(e) { 151 requestModal.hide(); 152 reqForm.classList.remove('d-none'); 153 reqWorking.classList.remove('d-flex'); 154 reqWorking.classList.add('d-none'); 155 156 // Restore the original 'Please Wait...' message 157 while (reqWorking.firstChild) reqWorking.removeChild(reqWorking.firstChild); 158 let h3 = document.createElement('h3'); 159 h3.appendChild(document.createTextNode('Please Wait... ')); 160 h3.classList.add('text-center'); 161 let img = document.createElement('img'); 162 img.src = '/img/evertz/loading.428px.webp'; 163 img.alt = ''; 164 img.classList.add('d-block', 'w-75', 'mx-auto'); 165 h3.appendChild(img); 166 reqWorking.appendChild(h3); 167 168 }, false); 169 reqWorking.appendChild(button); 170 } 171 } 172 }; 173 http.send(values); 174 175 return false; 176 }, false); 177 178} // end if (requestForm) 179 180 181// Correct the URL if we got here via a typo redirect 182if (!MIRROR && (window.location.hostname == 'evertz.com' || !window.location.pathname.match(/a\d{6}$/))) { 183 let canonical = document.querySelector('link[rel="canonical"]').href.replace(/^.+\/products\//, ''); 184 let targetState = '/products/' + canonical + window.location.search + window.location.hash; 185 if (window.location.href != window.location.origin + targetState) { 186 console.log('Page URL changed from "' + window.location.href + '" to "' + window.location.origin + targetState + '"'); 187 window.history.replaceState({}, '', window.location.origin + targetState); 188 } 189}
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.