1function updateOverlay(show) { 2 document.querySelector('.review-form-overlay').classList.toggle('in', show); 3} 4 5function checkQuestionsAnswered() { 6 const questions = ['question_1', 'question_2', 'question_3']; 7 let answered = false; 8 for (let question of questions) { 9 const row = document.querySelector('.row-feedback[data-question="' + question + '"]'); 10 if (row) { 11 const radios = document.getElementsByName(question); 12 for (let radio of radios) { 13 if (radio.checked) { 14 answered = true; 15 break; 16 } 17 } 18 } 19 } 20 21 if (!answered) { 22 document.querySelectorAll('.row-feedback').forEach((row) => { 23 row.classList.add('in'); 24 }); 25 return false; 26 } 27 return true; 28} 29 30document.addEventListener('DOMContentLoaded', () => { 31 document.querySelectorAll('.star-rating input').forEach((input) => { 32 input.addEventListener('change', (e) => { 33 document.querySelectorAll('.row-feedback').forEach((row) => { 34 row.classList.remove('in'); 35 }); 36 }); 37 }); 38 39 document.querySelector('#review-form').addEventListener('submit', (e) => { 40 e.preventDefault(); 41 42 const allAnswered = checkQuestionsAnswered(); 43 if (!allAnswered) { 44 return false; 45 } 46 47 updateOverlay(true); 48 let formData = new FormData(e.target); 49 50 fetch(review_form.ajax_url, { 51 method: 'POST', 52 body: formData 53 } 54 ) 55 .then(response => response.json()) 56 .then(data => { 57 updateOverlay(false); 58 if (data.success) { 59 document.querySelector('#form-holder').innerHTML = data.data.html; 60 initContactRequestForm(); 61 } else { 62 alert('There was an error submitting your review. Please try again.'); 63 } 64 }) 65 .catch(error => { 66 console.log('Error:', error); 67 }); 68 69 }); 70 71}); 72 73function initContactRequestForm() { 74 document.querySelector('#contact-request-form').addEventListener('submit', (e) => { 75 e.preventDefault(); 76 updateOverlay(true); 77 78 let formData = new FormData(e.target); 79 80 fetch(review_form.ajax_url, { 81 method: 'POST', 82 body: formData 83 } 84 ) 85 .then(response => response.json()) 86 .then(data => { 87 console.log('Success:', data); 88 updateOverlay(false); 89 if (data.success) { 90 console.log(document.querySelector('#from-holder')); 91 if(data.data.redirect) { 92 window.location = data.data.redirect_url; 93 } else { 94 document.querySelector('#form-holder').innerHTML = data.data.html; 95 } 96 } 97 98 }) 99 .catch(error => { 100 console.log('Error:', error); 101 }); 102 }); 103 104}
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.