1document.addEventListener("DOMContentLoaded", function () { 2 function showLoader() { 3 let loaderHTML = ` 4 <div id="loading-wrapper" style="display: none;"> 5 <div id="loader"> 6 <div id="d1"></div> 7 <div id="d2"></div> 8 <div id="d3"></div> 9 <div id="d4"></div> 10 <div id="d5"></div> 11 </div> 12 </div> 13 `; 14 document.body.insertAdjacentHTML("beforeend", loaderHTML); 15 16 // Defer style change until after element is added to DOM 17 requestAnimationFrame(() => { 18 document.getElementById("loading-wrapper").style.display = "flex"; 19 }); 20 } 21 function hideLoader() { 22 document.getElementById("loading-wrapper").remove(); 23 } 24 let premium_domain = location.protocol + '//' + location.host; 25 if (premium_domain) { 26 let inputField = document.getElementById('origin_url'); 27 if(inputField) { 28 inputField.value = premium_domain; 29 } 30 } 31 const form = document.getElementById("main-form"); 32 if (form) { 33 const nextBtns = document.querySelectorAll(".pp-next"); 34 const submitButton = form.querySelector("button[type='submit']"); 35 // const formWarning = document.getElementById("formWarning"); 36 37 nextBtns.forEach(btn => { 38 btn.addEventListener("click", function (event) { 39 showLoader(); 40 setTimeout(function() { 41 hideLoader(); 42 }, 200); 43 document.getElementById("pp-form-step-1").style.display = 'none'; 44 document.getElementById("pp-form-step-2").style.display = 'block'; 45 }); 46 }); 47 48 // JavaScript to toggle pages within the form 49 const tabs = document.querySelectorAll('input[name="mode"]'); 50 const personalPage = document.getElementById('personal-page'); 51 const businessPage = document.getElementById('business-page'); 52 const personalFields = document.querySelectorAll("#mode-personal1, #mode-personal2"); 53 const businessField = document.querySelector("#mode-business"); 54 55 function updateView() { 56 if (tabs[0].checked) { 57 personalPage.classList.add('active'); 58 businessPage.classList.remove('active'); 59 tabs[0].parentElement.classList.add('active'); 60 tabs[1].parentElement.classList.remove('active'); 61 personalFields.forEach(el => el.style.display = "flex"); 62 businessField.style.display = "none"; 63 } else { 64 personalPage.classList.remove('active'); 65 businessPage.classList.add('active'); 66 tabs[0].parentElement.classList.remove('active'); 67 tabs[1].parentElement.classList.add('active'); 68 personalFields.forEach(el => el.style.display = "none"); 69 businessField.style.display = "flex"; 70 } 71 } 72 updateView();
73 tabs.forEach(tab => tab.addEventListener('change', updateView)); 74 updateView(); 75 76 77 78 function checkFields() { 79 // Get only the visible inputs and textareas 80 const visibleInputs = Array.from(form.querySelectorAll("input:not([type='hidden']):not([type='checkbox'])")) 81 .filter(input => input.offsetParent !== null); 82 const visibleTextareas = Array.from(form.querySelectorAll("textarea")) 83 .filter(textarea => textarea.offsetParent !== null); 84 85 const allVisibleFields = visibleInputs.concat(visibleTextareas); 86 const isValid = allVisibleFields.every(field => field.value.trim() !== ""); 87 88 submitButton.disabled = !isValid; 89 90 if (!isValid) { 91 formWarning.style.display = "block"; 92 } else { 93 formWarning.style.display = "none"; 94 } 95 96 return isValid; 97 } 98 99 form.addEventListener("submit", function (e) { 100 e.preventDefault(); 101 let formData = new FormData(form); 102 const url = new URL("https://aisearch.domain.me/premium-parking/1/"); 103 formData.forEach((value, key) => { 104 url.searchParams.append(key, value); 105 }); 106 // Display loader HTML if validation passes 107 showLoader(); 108 fetch( 109 url, { 110 // "https://kodiraj.me/proxy.php",{ 111 method: "GET", 112 // headers: { 113 // "X-CSRFToken": getCsrfToken(), 114 // }, 115 // credentials: "include", 116 // body: formData, 117 }) 118 .then(response => response.json()) 119 .then(data => { 120 hideLoader(); 121 if (data.status === "success" && data.redirect_url) { 122 window.location.href = data.redirect_url; 123 } else { 124 console.error("No redirect_url found in response"); 125 } 126 }) 127 .catch(error => { 128 hideLoader(); 129 console.error("Error submitting form:", error); 130 }); 131 }); 132 } 133})
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.