const basePrice = JSON.parse('{"1":{"square":"16-27","btu":"7000-9000 \/ 2.1-2.6","price":"7000","price_our_item":"6500","price_remont":"2500","plus_cart":"1000-3000 \u0433\u0440\u043d.","plus_facade":"300-500 \u0433\u0440\u043d."},"2":{"square":"28-37","btu":"12000 \/ 3.2-3.6","price":"7200","price_our_item":"6500","price_remont":"3200","plus_cart":"100-1500 \u0433\u0440\u043d.","plus_facade":"300-500 \u0433\u0440\u043d."},"3":{"square":"38-55","btu":"18000 \/ 4.2-5.5","price":"7500","price_our_item":"6500","price_remont":"4300","plus_cart":"2000-4500 \u0433\u0440\u043d.","plus_facade":"300-500 \u0433\u0440\u043d."}}'); const installOption = JSON.parse('{"2-standard":{"1":{"h1":"\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0431\u043b\u043e\u043a \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","value":"1","img":"indoor-unit-to-the-right-of-the-window.png"},"10":{"h1":"\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0431\u043b\u043e\u043a \u0441\u043b\u0435\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","value":"10","img":"indoor-unit-to-the-left-of-the-window.png"},"11":{"h1":"\u041c\u043e\u043d\u0442\u0430\u0436 \u0447\u0435\u0440\u0435\u0437 \u0431\u0430\u043b\u043a\u043e\u043d","value":"11","img":"installation-through-the-balcony.png"}},"1-standard":{"2":{"h1":"\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0431\u043b\u043e\u043a \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","value":"2","img":"indoor-unit-to-the-right-of-the-window.png"},"16":{"h1":"\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0431\u043b\u043e\u043a \u0441\u043b\u0435\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","value":"16","img":"indoor-unit-to-the-left-of-the-window.png"},"5":{"h1":"\u041c\u043e\u043d\u0442\u0430\u0436 \u0447\u0435\u0440\u0435\u0437 \u0431\u0430\u043b\u043a\u043e\u043d","value":"5","img":"installation-through-the-balcony.png"}},"1-beforeRepair":{"7":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","value":"7","img":"piping-laid-to-the-right-of-the-window.png"},"6":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u0441\u043b\u0435\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","value":"6","img":"piping-laid-to-the-left-of-the-window.png"},"8":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0431\u0430\u043b\u043a\u043e\u043d","value":"8","img":"piping-routed-through-the-balcony.png"},"9":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u043d\u0430\u0434 \u0434\u0432\u0435\u0440\u044c\u044e","value":"9","img":"piping-routed-above-the-door.png"}},"2-beforeRepair":{"13":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","value":"13","img":"piping-laid-to-the-right-of-the-window.png"},"12":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u0441\u043b\u0435\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","value":"12","img":"piping-laid-to-the-left-of-the-window.png"},"14":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0431\u0430\u043b\u043a\u043e\u043d","value":"14","img":"piping-routed-through-the-balcony.png"},"15":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u043d\u0430\u0434 \u0434\u0432\u0435\u0440\u044c\u044e","value":"15","img":"piping-routed-above-the-door.png"}},"3-standard":{"17":{"h1":"\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0431\u043b\u043e\u043a \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","value":"17","img":"indoor-unit-to-the-right-of-the-window.png"},"18":{"h1":"\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0431\u043b\u043e\u043a \u0441\u043b\u0435\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","value":"18","img":"indoor-unit-to-the-left-of-the-window.png"},"19":{"h1":"\u041c\u043e\u043d\u0442\u0430\u0436 \u0447\u0435\u0440\u0435\u0437 \u0431\u0430\u043b\u043a\u043e\u043d","value":"19","img":"installation-through-the-balcony.png"}},"3-beforeRepair":{"20":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","value":"20","img":"piping-laid-to-the-right-of-the-window.png"},"21":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u0441\u043b\u0435\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","value":"21","img":"piping-laid-to-the-left-of-the-window.png"},"22":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0431\u0430\u043b\u043a\u043e\u043d","value":"22","img":"piping-routed-through-the-balcony.png"},"23":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u043d\u0430\u0434 \u0434\u0432\u0435\u0440\u044c\u044e","value":"23","img":"piping-routed-above-the-door.png"}}}'); const variantPrice = JSON.parse('{"2-standard-1":{"h1":"\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0431\u043b\u043e\u043a \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","plus_to_price":"500"},"1-standard-2":{"h1":"\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0431\u043b\u043e\u043a \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","plus_to_price":"800"},"1-standard-16":{"h1":"\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0431\u043b\u043e\u043a \u0441\u043b\u0435\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","plus_to_price":"1500"},"1-standard-5":{"h1":"\u041c\u043e\u043d\u0442\u0430\u0436 \u0447\u0435\u0440\u0435\u0437 \u0431\u0430\u043b\u043a\u043e\u043d","plus_to_price":"2200"},"1-beforeRepair-7":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","plus_to_price":"1200"},"1-beforeRepair-6":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u0441\u043b\u0435\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","plus_to_price":"1500"},"1-beforeRepair-8":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0431\u0430\u043b\u043a\u043e\u043d","plus_to_price":"2100"},"1-beforeRepair-9":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u043d\u0430\u0434 \u0434\u0432\u0435\u0440\u044c\u044e","plus_to_price":"3350"},"2-beforeRepair-13":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","plus_to_price":"1300"},"2-standard-10":{"h1":"\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0431\u043b\u043e\u043a \u0441\u043b\u0435\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","plus_to_price":"1000"},"2-beforeRepair-12":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u0441\u043b\u0435\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","plus_to_price":"1600"},"2-standard-11":{"h1":"\u041c\u043e\u043d\u0442\u0430\u0436 \u0447\u0435\u0440\u0435\u0437 \u0431\u0430\u043b\u043a\u043e\u043d","plus_to_price":"2000"},"2-beforeRepair-14":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0431\u0430\u043b\u043a\u043e\u043d","plus_to_price":"2300"},"3-standard-17":{"h1":"\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0431\u043b\u043e\u043a \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","plus_to_price":"600"},"2-beforeRepair-15":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u043d\u0430\u0434 \u0434\u0432\u0435\u0440\u044c\u044e","plus_to_price":"3500"},"3-standard-18":{"h1":"\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0431\u043b\u043e\u043a \u0441\u043b\u0435\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","plus_to_price":"1100"},"3-standard-19":{"h1":"\u041c\u043e\u043d\u0442\u0430\u0436 \u0447\u0435\u0440\u0435\u0437 \u0431\u0430\u043b\u043a\u043e\u043d","plus_to_price":"2150"},"3-beforeRepair-20":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","plus_to_price":"1400"},"3-beforeRepair-21":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u0441\u043b\u0435\u0432\u0430 \u043e\u0442 \u043e\u043a\u043d\u0430","plus_to_price":"1700"},"3-beforeRepair-22":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0431\u0430\u043b\u043a\u043e\u043d","plus_to_price":"2500"},"3-beforeRepair-23":{"h1":"\u0417\u0430\u043a\u043b\u0430\u0434\u043a\u0430 \u043d\u0430\u0434 \u0434\u0432\u0435\u0440\u044c\u044e","plus_to_price":"3700"}}'); const step2Content = document.getElementById('step-2-content'); const step3Content = document.getElementById('step-3-content'); const step4Content = document.getElementById('step-4-content'); /** * Define a function to navigate betweens form steps. * It accepts one parameter. That is - step number. */ const navigateToFormStep = (stepNumber) => { /** * Hide all form steps. */ document.querySelectorAll(".form-step").forEach((formStepElement) => { formStepElement.classList.add("d-none"); }); /** * Mark all form steps as unfinished. */ document.querySelectorAll(".form-stepper-list").forEach((formStepHeader) => { formStepHeader.classList.add("form-stepper-unfinished"); formStepHeader.classList.remove("form-stepper-active", "form-stepper-completed"); }); /** * Show the current form step (as passed to the function). */ document.querySelector("#step-" + stepNumber).classList.remove("d-none"); /** * Select the form step circle (progress bar). */ const formStepCircle = document.querySelector('li[step="' + stepNumber + '"]'); /** * Mark the current form step as active. */ formStepCircle.classList.remove("form-stepper-unfinished", "form-stepper-completed"); formStepCircle.classList.add("form-stepper-active"); /** * Loop through each form step circles. * This loop will continue up to the current step number. * Example: If the current step is 3, * then the loop will perform operations for step 1 and 2. */ for (let index = 0; index < stepNumber; index++) { /** * Select the form step circle (progress bar). */ const formStepCircle = document.querySelector('li[step="' + index + '"]'); /** * Check if the element exist. If yes, then proceed. */ if (formStepCircle) { formStepCircle.classList.remove("form-stepper-unfinished", "form-stepper-active"); formStepCircle.classList.add("form-stepper-completed"); } } }; /** * Select all form navigation buttons, and loop through them. */ document.querySelectorAll(".btn-navigate-form-step").forEach((formNavigationBtn) => { /** * Add a click event listener to the button. */ formNavigationBtn.addEventListener("click", () => { /** * Get the value of the step. */ const stepNumber = parseInt(formNavigationBtn.getAttribute("step-number")); const skipValidation = parseInt(formNavigationBtn.getAttribute("skip-validation")); if( !skipValidation && !validateStep(stepNumber-1) ) { return false; } changeStepContent(stepNumber); /** * Call the function to navigate to the target form step. */ navigateToFormStep(stepNumber); }); }); function changeStepContent(stepNumber) { if(stepNumber == 2) { step2ChangeContent(); } else if(stepNumber == 3) { step3ChangeContent(); } } function step2ChangeContent() { const roomArea = document.querySelector('input[name="room-area"]:checked').value; // const step2Content = document.getElementById('step-2-content'); if(roomArea === "2") { //step2Content.innerHTML = 'BIG-variants'; } else { //step2Content.innerHTML = 'Other-variants'; } } function step3ChangeContent() { const roomArea = document.querySelector('input[name="room-area"]:checked').value; const installType = document.querySelector('input[name="install-type"]:checked').value; let installTypeForJS = getInstallTypeForJS(installType); //console.log(roomArea, installType, basePrice[roomArea]); const optionForSelectedType = installOption[roomArea+'-'+installTypeForJS]; let item = ''; for (const [key, o] of Object.entries(optionForSelectedType)) { //console.log(`${key}: ${o} -- ${o["h1"]}`); item += `