/** * Template Name: NewBiz * Updated: Sep 18 2023 with Bootstrap v5.3.2 * Template URL: https://bootstrapmade.com/newbiz-bootstrap-business-template/ * Author: BootstrapMade.com * License: https://bootstrapmade.com/license/ */ (function () { "use strict"; /** * Easy selector helper function */ const select = (el, all = false) => { el = el.trim() if (all) { return [...document.querySelectorAll(el)] } else { return document.querySelector(el) } } /** * Easy event listener function */ const on = (type, el, listener, all = false) => { let selectEl = select(el, all) if (selectEl) { if (all) { selectEl.forEach(e => e.addEventListener(type, listener)) } else { selectEl.addEventListener(type, listener) } } } /** * Easy on scroll event listener */ const onscroll = (el, listener) => { el.addEventListener('scroll', listener) } /** * Navbar links active state on scroll */ let navbarlinks = select('#navbar .scrollto', true) const navbarlinksActive = () => { let position = window.scrollY + 200 navbarlinks.forEach(navbarlink => { if (!navbarlink.hash) return let section = select(navbarlink.hash) if (!section) return if (position >= section.offsetTop && position <= (section.offsetTop + section.offsetHeight)) { navbarlink.classList.add('active') } else { navbarlink.classList.remove('active') } }) } window.addEventListener('load', navbarlinksActive) onscroll(document, navbarlinksActive) /** * Scrolls to an element with header offset */ const scrollto = (el) => { let header = select('#header') let offset = header.offsetHeight if (!header.classList.contains('header-scrolled')) { offset -= 20 } let elementPos = select(el).offsetTop window.scrollTo({ top: elementPos - offset, behavior: 'smooth' }) } /** * Toggle .header-scrolled class to #header when page is scrolled */ let selectHeader = select('#header') if (selectHeader) { const headerScrolled = () => { if (window.scrollY > 100) { selectHeader.classList.add('header-scrolled') } else { selectHeader.classList.remove('header-scrolled') } } window.addEventListener('load', headerScrolled) onscroll(document, headerScrolled) } /** * Back to top button */ let backtotop = select('.back-to-top') if (backtotop) { const toggleBacktotop = () => { if (window.scrollY > 100) { backtotop.classList.add('active') } else { backtotop.classList.remove('active') } } window.addEventListener('load', toggleBacktotop) onscroll(document, toggleBacktotop) } /** * Mobile nav toggle */ on('click', '.mobile-nav-toggle', function (e) { select('#navbar').classList.toggle('navbar-mobile') this.classList.toggle('bi-list') this.classList.toggle('bi-x') }) /** * Mobile nav dropdowns activate */ on('click', '.navbar .dropdown > a', function (e) { if (select('#navbar').classList.contains('navbar-mobile')) { e.preventDefault() this.nextElementSibling.classList.toggle('dropdown-active') } }, true) /** * Scrool with ofset on links with a class name .scrollto */ on('click', '.scrollto', function (e) { if (select(this.hash)) { e.preventDefault() let navbar = select('#navbar') if (navbar.classList.contains('navbar-mobile')) { navbar.classList.remove('navbar-mobile') let navbarToggle = select('.mobile-nav-toggle') navbarToggle.classList.toggle('bi-list') navbarToggle.classList.toggle('bi-x') } scrollto(this.hash) } }, true) /** * Scroll with ofset on page load with hash links in the url */ window.addEventListener('load', () => { if (window.location.hash) { if (select(window.location.hash)) { scrollto(window.location.hash) } } }); /** * Porfolio isotope and filter */ window.addEventListener('load', () => { let portfolioContainer = select('.portfolio-container'); if (portfolioContainer) { let portfolioIsotope = new Isotope(portfolioContainer, { itemSelector: '.portfolio-item' }); let portfolioFilters = select('#portfolio-flters li', true); on('click', '#portfolio-flters li', function (e) { e.preventDefault(); portfolioFilters.forEach(function (el) { el.classList.remove('filter-active'); }); this.classList.add('filter-active'); portfolioIsotope.arrange({ filter: this.getAttribute('data-filter') }); portfolioIsotope.on('arrangeComplete', function () { AOS.refresh() }); }, true); } }); /** * Initiate portfolio lightbox */ const portfolioLightbox = GLightbox({ selector: '.portfolio-lightbox' }); /** * Portfolio details slider */ new Swiper('.portfolio-details-slider', { speed: 400, loop: true, autoplay: { delay: 5000, disableOnInteraction: false }, pagination: { el: '.swiper-pagination', type: 'bullets', clickable: true } }); /** * Testimonials slider */ new Swiper('.testimonials-slider', { speed: 600, loop: true, autoplay: { delay: 5000, disableOnInteraction: false }, slidesPerView: 'auto', pagination: { el: '.swiper-pagination', type: 'bullets', clickable: true } }); /** * Animation on scroll */ window.addEventListener('load', () => { AOS.init({ duration: 1000, easing: 'ease-in-out', once: true, mirror: false }) }); })() // Forms function showPopup(formId) { document.getElementById(formId).style.display = 'block'; document.getElementById('overlay').style.display = 'block'; setTimeout(function () { document.getElementById(formId).style.opacity = '1'; document.getElementById('overlay').style.opacity = '1'; }, 50); } function hidePopup(formId) { document.getElementById(formId).style.opacity = '0'; document.getElementById('overlay').style.opacity = '0'; setTimeout(function () { document.getElementById(formId).style.display = 'none'; document.getElementById('overlay').style.display = 'none'; }, 300); } //Make Offer var canSubmitForm = false; document.getElementById('priceForm').addEventListener('submit', function (event) { var inputPrice = parseFloat(document.getElementById('inputPrice').value); var discountedPrice = parseFloat(document.getElementById('discountPercentageInput').innerText); // Reset styles and enable the submit button document.getElementById('inputPrice').style.removeProperty('border-color'); if (isNaN(inputPrice) || inputPrice < discountedPrice) { // Show an error message alert("Error: Your offer cannot be below the minimum offer price."); // Set styles and disable the submit button document.getElementById('inputPrice').style.setProperty('border-color', 'red', 'important'); // Prevent form submission event.preventDefault(); canSubmitForm = false; // Set the flag to false } else { canSubmitForm = true; // Set the flag to true } // Check if the form can be submitted if (!canSubmitForm) { event.preventDefault(); alert("Error: Please enter a valid price."); } }); document.getElementById('inputPrice').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); // Make Offer2 var canSubmitForm2 = false; document.getElementById('priceForm2').addEventListener('submit', function (event) { var inputPrice = parseFloat(document.getElementById('inputPrice2').value); var discountedPrice = parseFloat(document.getElementById('discountPercentageInput').innerText); // Reset styles and enable the submit button document.getElementById('inputPrice2').style.removeProperty('border-color'); if (isNaN(inputPrice) || inputPrice < discountedPrice) { // Show an error message alert("Error: Your offer cannot be below the minimum offer price."); // Set styles and disable the submit button document.getElementById('inputPrice2').style.setProperty('border-color', 'red', 'important'); // Prevent form submission event.preventDefault(); canSubmitForm2 = false; // Set the flag to false } else { canSubmitForm2 = true; // Set the flag to true } // Check if the form can be submitted if (!canSubmitForm2) { event.preventDefault(); alert("Error: Please enter a valid price."); } }); document.getElementById('inputPrice2').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); // Escrow Form function submitForm(event) { // Prevent the default form submission event.preventDefault(); // Your existing form submission logic here $.ajax({ url: "/add-buyer", type: "POST", data: $(event.target).serialize(), success: function (data) { // Check if the server response indicates success if (data && data.success) { // Hide the Buy Now form $('#buyNowForm').hide(); // Show the escrow modal in front of the Buy Now form $('#escrowModal').modal('show').css({ 'z-index': 10000, 'position': 'absolute' }); // Set a higher z-index // Add an event listener for the modal's close button click $('#escrowModal .close').on('click', function () { // Perform any actions you want when the close button is clicked console.log('Close button clicked.'); // Close the modal $('#escrowModal').modal('hide'); // Show the Buy Now form again $('#buyNowForm').show(); }); } else { // Check if the error message indicates that the user has already submitted the form within the last hour if (data && data.error && data.error.includes('already submitted the form')) { alert(data.error); } else { // Display a generic error message alert("You have already submitted the contact form. Please try again after 1 hour."); } } }, error: function () { // Handle the case where there was an error with the AJAX request alert("An error occurred while submitting the form."); } }); } // TELEPHONE FORMAT const phoneInputField1 = document.querySelector("#buy-now-phone"); const phoneInput1 = window.intlTelInput(phoneInputField1, { utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js", }); // Add an event listener for the "input" event on the phone input field phoneInputField1.addEventListener("input", function () { // Get the selected country code const selectedCountryCode = phoneInput1.getSelectedCountryData().iso2; // Define the maximum number of digits based on the selected country code let maxDigits = 0; switch (selectedCountryCode) { case 'us': maxDigits = 10; // Assuming the US has a 10-digit phone number break; case 'gb': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; case 'pk': maxDigits = 11; // Assuming Pakistan has an 11-digit phone number break; // Add more cases for other countries as needed default: maxDigits = 15; // Default to a common maximum number of digits } // Remove non-digit characters from the input value let phoneNumber = phoneInputField1.value.replace(/[^0-9]/g, ''); // Trim the phone number to the maximum allowed digits phoneNumber = phoneNumber.slice(0, maxDigits); // Update the input value phoneInputField1.value = phoneNumber; }); // Prevent pasting into the phone input field phoneInputField1.addEventListener("paste", function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); const phoneInputField2 = document.querySelector("#make-offer-phone"); const phoneInput2 = window.intlTelInput(phoneInputField2, { utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js", }); // Add an event listener for the "input" event on the phone input field phoneInputField2.addEventListener("input", function () { // Get the selected country code const selectedCountryCode = phoneInput2.getSelectedCountryData().iso2; // Define the maximum number of digits based on the selected country code let maxDigits = 0; switch (selectedCountryCode) { case 'us': maxDigits = 10; // Assuming the US has a 10-digit phone number break; case 'gb': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; case 'pk': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; // Add more cases for other countries as needed default: maxDigits = 15; // Default to a common maximum number of digits } // Remove non-digit characters from the input value let phoneNumber = phoneInputField2.value.replace(/[^0-9]/g, ''); // Trim the phone number to the maximum allowed digits phoneNumber = phoneNumber.slice(0, maxDigits); // Update the input value phoneInputField2.value = phoneNumber; }); // Prevent pasting into the phone input field phoneInputField2.addEventListener("paste", function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); const phoneInputField3 = document.querySelector("#make-offer-2-phone"); const phoneInput3 = window.intlTelInput(phoneInputField3, { utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js", }); // Add an event listener for the "input" event on the phone input field phoneInputField3.addEventListener("input", function () { // Get the selected country code const selectedCountryCode = phoneInput3.getSelectedCountryData().iso2; // Define the maximum number of digits based on the selected country code let maxDigits = 0; switch (selectedCountryCode) { case 'us': maxDigits = 10; // Assuming the US has a 10-digit phone number break; case 'gb': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; case 'pk': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; // Add more cases for other countries as needed default: maxDigits = 15; // Default to a common maximum number of digits } // Remove non-digit characters from the input value let phoneNumber = phoneInputField3.value.replace(/[^0-9]/g, ''); // Trim the phone number to the maximum allowed digits phoneNumber = phoneNumber.slice(0, maxDigits); // Update the input value phoneInputField3.value = phoneNumber; }); // Prevent pasting into the phone input field phoneInputField3.addEventListener("paste", function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); const phoneInputField4 = document.querySelector("#contact-phone"); const phoneInput4 = window.intlTelInput(phoneInputField4, { utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js", }); // Add an event listener for the "input" event on the phone input field phoneInputField4.addEventListener("input", function () { // Get the selected country code const selectedCountryCode = phoneInput4.getSelectedCountryData().iso2; // Define the maximum number of digits based on the selected country code let maxDigits = 0; switch (selectedCountryCode) { case 'us': maxDigits = 10; // Assuming the US has a 10-digit phone number break; case 'gb': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; case 'pk': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; // Add more cases for other countries as needed default: maxDigits = 15; // Default to a common maximum number of digits } // Remove non-digit characters from the input value let phoneNumber = phoneInputField4.value.replace(/[^0-9]/g, ''); // Trim the phone number to the maximum allowed digits phoneNumber = phoneNumber.slice(0, maxDigits); // Update the input value phoneInputField4.value = phoneNumber; }); // Prevent pasting into the phone input field phoneInputField4.addEventListener("paste", function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); // Disable Copy Pasting document.getElementById('noPasteInput1').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput2').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput3').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput4').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput5').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput6').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput7').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput8').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput9').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput10').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput11').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput12').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput13').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); // Make Offer document.getElementById("inputPrice").addEventListener("input", function(event) { const inputValue = event.target.value; // Replace any non-numeric characters const sanitizedValue = inputValue.replace(/\D/g, ""); // Limit the length to 10 digits const truncatedValue = sanitizedValue.slice(0, 5); // Update the input value with the sanitized value event.target.value = truncatedValue; }); document.getElementById("inputPrice2").addEventListener("input", function(event) { const inputValue = event.target.value; // Replace any non-numeric characters const sanitizedValue = inputValue.replace(/\D/g, ""); // Limit the length to 10 digits const truncatedValue = sanitizedValue.slice(0, 5); // Update the input value with the sanitized value event.target.value = truncatedValue; });/** * Template Name: NewBiz * Updated: Sep 18 2023 with Bootstrap v5.3.2 * Template URL: https://bootstrapmade.com/newbiz-bootstrap-business-template/ * Author: BootstrapMade.com * License: https://bootstrapmade.com/license/ */ (function () { "use strict"; /** * Easy selector helper function */ const select = (el, all = false) => { el = el.trim() if (all) { return [...document.querySelectorAll(el)] } else { return document.querySelector(el) } } /** * Easy event listener function */ const on = (type, el, listener, all = false) => { let selectEl = select(el, all) if (selectEl) { if (all) { selectEl.forEach(e => e.addEventListener(type, listener)) } else { selectEl.addEventListener(type, listener) } } } /** * Easy on scroll event listener */ const onscroll = (el, listener) => { el.addEventListener('scroll', listener) } /** * Navbar links active state on scroll */ let navbarlinks = select('#navbar .scrollto', true) const navbarlinksActive = () => { let position = window.scrollY + 200 navbarlinks.forEach(navbarlink => { if (!navbarlink.hash) return let section = select(navbarlink.hash) if (!section) return if (position >= section.offsetTop && position <= (section.offsetTop + section.offsetHeight)) { navbarlink.classList.add('active') } else { navbarlink.classList.remove('active') } }) } window.addEventListener('load', navbarlinksActive) onscroll(document, navbarlinksActive) /** * Scrolls to an element with header offset */ const scrollto = (el) => { let header = select('#header') let offset = header.offsetHeight if (!header.classList.contains('header-scrolled')) { offset -= 20 } let elementPos = select(el).offsetTop window.scrollTo({ top: elementPos - offset, behavior: 'smooth' }) } /** * Toggle .header-scrolled class to #header when page is scrolled */ let selectHeader = select('#header') if (selectHeader) { const headerScrolled = () => { if (window.scrollY > 100) { selectHeader.classList.add('header-scrolled') } else { selectHeader.classList.remove('header-scrolled') } } window.addEventListener('load', headerScrolled) onscroll(document, headerScrolled) } /** * Back to top button */ let backtotop = select('.back-to-top') if (backtotop) { const toggleBacktotop = () => { if (window.scrollY > 100) { backtotop.classList.add('active') } else { backtotop.classList.remove('active') } } window.addEventListener('load', toggleBacktotop) onscroll(document, toggleBacktotop) } /** * Mobile nav toggle */ on('click', '.mobile-nav-toggle', function (e) { select('#navbar').classList.toggle('navbar-mobile') this.classList.toggle('bi-list') this.classList.toggle('bi-x') }) /** * Mobile nav dropdowns activate */ on('click', '.navbar .dropdown > a', function (e) { if (select('#navbar').classList.contains('navbar-mobile')) { e.preventDefault() this.nextElementSibling.classList.toggle('dropdown-active') } }, true) /** * Scrool with ofset on links with a class name .scrollto */ on('click', '.scrollto', function (e) { if (select(this.hash)) { e.preventDefault() let navbar = select('#navbar') if (navbar.classList.contains('navbar-mobile')) { navbar.classList.remove('navbar-mobile') let navbarToggle = select('.mobile-nav-toggle') navbarToggle.classList.toggle('bi-list') navbarToggle.classList.toggle('bi-x') } scrollto(this.hash) } }, true) /** * Scroll with ofset on page load with hash links in the url */ window.addEventListener('load', () => { if (window.location.hash) { if (select(window.location.hash)) { scrollto(window.location.hash) } } }); /** * Porfolio isotope and filter */ window.addEventListener('load', () => { let portfolioContainer = select('.portfolio-container'); if (portfolioContainer) { let portfolioIsotope = new Isotope(portfolioContainer, { itemSelector: '.portfolio-item' }); let portfolioFilters = select('#portfolio-flters li', true); on('click', '#portfolio-flters li', function (e) { e.preventDefault(); portfolioFilters.forEach(function (el) { el.classList.remove('filter-active'); }); this.classList.add('filter-active'); portfolioIsotope.arrange({ filter: this.getAttribute('data-filter') }); portfolioIsotope.on('arrangeComplete', function () { AOS.refresh() }); }, true); } }); /** * Initiate portfolio lightbox */ const portfolioLightbox = GLightbox({ selector: '.portfolio-lightbox' }); /** * Portfolio details slider */ new Swiper('.portfolio-details-slider', { speed: 400, loop: true, autoplay: { delay: 5000, disableOnInteraction: false }, pagination: { el: '.swiper-pagination', type: 'bullets', clickable: true } }); /** * Testimonials slider */ new Swiper('.testimonials-slider', { speed: 600, loop: true, autoplay: { delay: 5000, disableOnInteraction: false }, slidesPerView: 'auto', pagination: { el: '.swiper-pagination', type: 'bullets', clickable: true } }); /** * Animation on scroll */ window.addEventListener('load', () => { AOS.init({ duration: 1000, easing: 'ease-in-out', once: true, mirror: false }) }); })() // Forms function showPopup(formId) { document.getElementById(formId).style.display = 'block'; document.getElementById('overlay').style.display = 'block'; setTimeout(function () { document.getElementById(formId).style.opacity = '1'; document.getElementById('overlay').style.opacity = '1'; }, 50); } function hidePopup(formId) { document.getElementById(formId).style.opacity = '0'; document.getElementById('overlay').style.opacity = '0'; setTimeout(function () { document.getElementById(formId).style.display = 'none'; document.getElementById('overlay').style.display = 'none'; }, 300); } //Make Offer var canSubmitForm = false; document.getElementById('priceForm').addEventListener('submit', function (event) { var inputPrice = parseFloat(document.getElementById('inputPrice').value); var discountedPrice = parseFloat(document.getElementById('discountPercentageInput').innerText); // Reset styles and enable the submit button document.getElementById('inputPrice').style.removeProperty('border-color'); if (isNaN(inputPrice) || inputPrice < discountedPrice) { // Show an error message alert("Error: Your offer cannot be below the minimum offer price."); // Set styles and disable the submit button document.getElementById('inputPrice').style.setProperty('border-color', 'red', 'important'); // Prevent form submission event.preventDefault(); canSubmitForm = false; // Set the flag to false } else { canSubmitForm = true; // Set the flag to true } // Check if the form can be submitted if (!canSubmitForm) { event.preventDefault(); alert("Error: Please enter a valid price."); } }); document.getElementById('inputPrice').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); // Make Offer2 var canSubmitForm2 = false; document.getElementById('priceForm2').addEventListener('submit', function (event) { var inputPrice = parseFloat(document.getElementById('inputPrice2').value); var discountedPrice = parseFloat(document.getElementById('discountPercentageInput').innerText); // Reset styles and enable the submit button document.getElementById('inputPrice2').style.removeProperty('border-color'); if (isNaN(inputPrice) || inputPrice < discountedPrice) { // Show an error message alert("Error: Your offer cannot be below the minimum offer price."); // Set styles and disable the submit button document.getElementById('inputPrice2').style.setProperty('border-color', 'red', 'important'); // Prevent form submission event.preventDefault(); canSubmitForm2 = false; // Set the flag to false } else { canSubmitForm2 = true; // Set the flag to true } // Check if the form can be submitted if (!canSubmitForm2) { event.preventDefault(); alert("Error: Please enter a valid price."); } }); document.getElementById('inputPrice2').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); // Escrow Form function submitForm(event) { // Prevent the default form submission event.preventDefault(); // Your existing form submission logic here $.ajax({ url: "/add-buyer", type: "POST", data: $(event.target).serialize(), success: function (data) { // Check if the server response indicates success if (data && data.success) { // Hide the Buy Now form $('#buyNowForm').hide(); // Show the escrow modal in front of the Buy Now form $('#escrowModal').modal('show').css({ 'z-index': 10000, 'position': 'absolute' }); // Set a higher z-index // Add an event listener for the modal's close button click $('#escrowModal .close').on('click', function () { // Perform any actions you want when the close button is clicked console.log('Close button clicked.'); // Close the modal $('#escrowModal').modal('hide'); // Show the Buy Now form again $('#buyNowForm').show(); }); } else { // Check if the error message indicates that the user has already submitted the form within the last hour if (data && data.error && data.error.includes('already submitted the form')) { alert(data.error); } else { // Display a generic error message alert("You have already submitted the contact form. Please try again after 1 hour."); } } }, error: function () { // Handle the case where there was an error with the AJAX request alert("An error occurred while submitting the form."); } }); } // TELEPHONE FORMAT const phoneInputField1 = document.querySelector("#buy-now-phone"); const phoneInput1 = window.intlTelInput(phoneInputField1, { utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js", }); // Add an event listener for the "input" event on the phone input field phoneInputField1.addEventListener("input", function () { // Get the selected country code const selectedCountryCode = phoneInput1.getSelectedCountryData().iso2; // Define the maximum number of digits based on the selected country code let maxDigits = 0; switch (selectedCountryCode) { case 'us': maxDigits = 10; // Assuming the US has a 10-digit phone number break; case 'gb': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; case 'pk': maxDigits = 11; // Assuming Pakistan has an 11-digit phone number break; // Add more cases for other countries as needed default: maxDigits = 15; // Default to a common maximum number of digits } // Remove non-digit characters from the input value let phoneNumber = phoneInputField1.value.replace(/[^0-9]/g, ''); // Trim the phone number to the maximum allowed digits phoneNumber = phoneNumber.slice(0, maxDigits); // Update the input value phoneInputField1.value = phoneNumber; }); // Prevent pasting into the phone input field phoneInputField1.addEventListener("paste", function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); const phoneInputField2 = document.querySelector("#make-offer-phone"); const phoneInput2 = window.intlTelInput(phoneInputField2, { utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js", }); // Add an event listener for the "input" event on the phone input field phoneInputField2.addEventListener("input", function () { // Get the selected country code const selectedCountryCode = phoneInput2.getSelectedCountryData().iso2; // Define the maximum number of digits based on the selected country code let maxDigits = 0; switch (selectedCountryCode) { case 'us': maxDigits = 10; // Assuming the US has a 10-digit phone number break; case 'gb': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; case 'pk': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; // Add more cases for other countries as needed default: maxDigits = 15; // Default to a common maximum number of digits } // Remove non-digit characters from the input value let phoneNumber = phoneInputField2.value.replace(/[^0-9]/g, ''); // Trim the phone number to the maximum allowed digits phoneNumber = phoneNumber.slice(0, maxDigits); // Update the input value phoneInputField2.value = phoneNumber; }); // Prevent pasting into the phone input field phoneInputField2.addEventListener("paste", function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); const phoneInputField3 = document.querySelector("#make-offer-2-phone"); const phoneInput3 = window.intlTelInput(phoneInputField3, { utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js", }); // Add an event listener for the "input" event on the phone input field phoneInputField3.addEventListener("input", function () { // Get the selected country code const selectedCountryCode = phoneInput3.getSelectedCountryData().iso2; // Define the maximum number of digits based on the selected country code let maxDigits = 0; switch (selectedCountryCode) { case 'us': maxDigits = 10; // Assuming the US has a 10-digit phone number break; case 'gb': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; case 'pk': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; // Add more cases for other countries as needed default: maxDigits = 15; // Default to a common maximum number of digits } // Remove non-digit characters from the input value let phoneNumber = phoneInputField3.value.replace(/[^0-9]/g, ''); // Trim the phone number to the maximum allowed digits phoneNumber = phoneNumber.slice(0, maxDigits); // Update the input value phoneInputField3.value = phoneNumber; }); // Prevent pasting into the phone input field phoneInputField3.addEventListener("paste", function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); const phoneInputField4 = document.querySelector("#contact-phone"); const phoneInput4 = window.intlTelInput(phoneInputField4, { utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js", }); // Add an event listener for the "input" event on the phone input field phoneInputField4.addEventListener("input", function () { // Get the selected country code const selectedCountryCode = phoneInput4.getSelectedCountryData().iso2; // Define the maximum number of digits based on the selected country code let maxDigits = 0; switch (selectedCountryCode) { case 'us': maxDigits = 10; // Assuming the US has a 10-digit phone number break; case 'gb': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; case 'pk': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; // Add more cases for other countries as needed default: maxDigits = 15; // Default to a common maximum number of digits } // Remove non-digit characters from the input value let phoneNumber = phoneInputField4.value.replace(/[^0-9]/g, ''); // Trim the phone number to the maximum allowed digits phoneNumber = phoneNumber.slice(0, maxDigits); // Update the input value phoneInputField4.value = phoneNumber; }); // Prevent pasting into the phone input field phoneInputField4.addEventListener("paste", function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); // Disable Copy Pasting document.getElementById('noPasteInput1').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput2').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput3').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput4').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput5').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput6').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput7').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput8').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput9').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput10').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput11').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput12').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput13').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); // Make Offer document.getElementById("inputPrice").addEventListener("input", function(event) { const inputValue = event.target.value; // Replace any non-numeric characters const sanitizedValue = inputValue.replace(/\D/g, ""); // Limit the length to 10 digits const truncatedValue = sanitizedValue.slice(0, 5); // Update the input value with the sanitized value event.target.value = truncatedValue; }); document.getElementById("inputPrice2").addEventListener("input", function(event) { const inputValue = event.target.value; // Replace any non-numeric characters const sanitizedValue = inputValue.replace(/\D/g, ""); // Limit the length to 10 digits const truncatedValue = sanitizedValue.slice(0, 5); // Update the input value with the sanitized value event.target.value = truncatedValue; });/** * Template Name: NewBiz * Updated: Sep 18 2023 with Bootstrap v5.3.2 * Template URL: https://bootstrapmade.com/newbiz-bootstrap-business-template/ * Author: BootstrapMade.com * License: https://bootstrapmade.com/license/ */ (function () { "use strict"; /** * Easy selector helper function */ const select = (el, all = false) => { el = el.trim() if (all) { return [...document.querySelectorAll(el)] } else { return document.querySelector(el) } } /** * Easy event listener function */ const on = (type, el, listener, all = false) => { let selectEl = select(el, all) if (selectEl) { if (all) { selectEl.forEach(e => e.addEventListener(type, listener)) } else { selectEl.addEventListener(type, listener) } } } /** * Easy on scroll event listener */ const onscroll = (el, listener) => { el.addEventListener('scroll', listener) } /** * Navbar links active state on scroll */ let navbarlinks = select('#navbar .scrollto', true) const navbarlinksActive = () => { let position = window.scrollY + 200 navbarlinks.forEach(navbarlink => { if (!navbarlink.hash) return let section = select(navbarlink.hash) if (!section) return if (position >= section.offsetTop && position <= (section.offsetTop + section.offsetHeight)) { navbarlink.classList.add('active') } else { navbarlink.classList.remove('active') } }) } window.addEventListener('load', navbarlinksActive) onscroll(document, navbarlinksActive) /** * Scrolls to an element with header offset */ const scrollto = (el) => { let header = select('#header') let offset = header.offsetHeight if (!header.classList.contains('header-scrolled')) { offset -= 20 } let elementPos = select(el).offsetTop window.scrollTo({ top: elementPos - offset, behavior: 'smooth' }) } /** * Toggle .header-scrolled class to #header when page is scrolled */ let selectHeader = select('#header') if (selectHeader) { const headerScrolled = () => { if (window.scrollY > 100) { selectHeader.classList.add('header-scrolled') } else { selectHeader.classList.remove('header-scrolled') } } window.addEventListener('load', headerScrolled) onscroll(document, headerScrolled) } /** * Back to top button */ let backtotop = select('.back-to-top') if (backtotop) { const toggleBacktotop = () => { if (window.scrollY > 100) { backtotop.classList.add('active') } else { backtotop.classList.remove('active') } } window.addEventListener('load', toggleBacktotop) onscroll(document, toggleBacktotop) } /** * Mobile nav toggle */ on('click', '.mobile-nav-toggle', function (e) { select('#navbar').classList.toggle('navbar-mobile') this.classList.toggle('bi-list') this.classList.toggle('bi-x') }) /** * Mobile nav dropdowns activate */ on('click', '.navbar .dropdown > a', function (e) { if (select('#navbar').classList.contains('navbar-mobile')) { e.preventDefault() this.nextElementSibling.classList.toggle('dropdown-active') } }, true) /** * Scrool with ofset on links with a class name .scrollto */ on('click', '.scrollto', function (e) { if (select(this.hash)) { e.preventDefault() let navbar = select('#navbar') if (navbar.classList.contains('navbar-mobile')) { navbar.classList.remove('navbar-mobile') let navbarToggle = select('.mobile-nav-toggle') navbarToggle.classList.toggle('bi-list') navbarToggle.classList.toggle('bi-x') } scrollto(this.hash) } }, true) /** * Scroll with ofset on page load with hash links in the url */ window.addEventListener('load', () => { if (window.location.hash) { if (select(window.location.hash)) { scrollto(window.location.hash) } } }); /** * Porfolio isotope and filter */ window.addEventListener('load', () => { let portfolioContainer = select('.portfolio-container'); if (portfolioContainer) { let portfolioIsotope = new Isotope(portfolioContainer, { itemSelector: '.portfolio-item' }); let portfolioFilters = select('#portfolio-flters li', true); on('click', '#portfolio-flters li', function (e) { e.preventDefault(); portfolioFilters.forEach(function (el) { el.classList.remove('filter-active'); }); this.classList.add('filter-active'); portfolioIsotope.arrange({ filter: this.getAttribute('data-filter') }); portfolioIsotope.on('arrangeComplete', function () { AOS.refresh() }); }, true); } }); /** * Initiate portfolio lightbox */ const portfolioLightbox = GLightbox({ selector: '.portfolio-lightbox' }); /** * Portfolio details slider */ new Swiper('.portfolio-details-slider', { speed: 400, loop: true, autoplay: { delay: 5000, disableOnInteraction: false }, pagination: { el: '.swiper-pagination', type: 'bullets', clickable: true } }); /** * Testimonials slider */ new Swiper('.testimonials-slider', { speed: 600, loop: true, autoplay: { delay: 5000, disableOnInteraction: false }, slidesPerView: 'auto', pagination: { el: '.swiper-pagination', type: 'bullets', clickable: true } }); /** * Animation on scroll */ window.addEventListener('load', () => { AOS.init({ duration: 1000, easing: 'ease-in-out', once: true, mirror: false }) }); })() // Forms function showPopup(formId) { document.getElementById(formId).style.display = 'block'; document.getElementById('overlay').style.display = 'block'; setTimeout(function () { document.getElementById(formId).style.opacity = '1'; document.getElementById('overlay').style.opacity = '1'; }, 50); } function hidePopup(formId) { document.getElementById(formId).style.opacity = '0'; document.getElementById('overlay').style.opacity = '0'; setTimeout(function () { document.getElementById(formId).style.display = 'none'; document.getElementById('overlay').style.display = 'none'; }, 300); } //Make Offer var canSubmitForm = false; document.getElementById('priceForm').addEventListener('submit', function (event) { var inputPrice = parseFloat(document.getElementById('inputPrice').value); var discountedPrice = parseFloat(document.getElementById('discountPercentageInput').innerText); // Reset styles and enable the submit button document.getElementById('inputPrice').style.removeProperty('border-color'); if (isNaN(inputPrice) || inputPrice < discountedPrice) { // Show an error message alert("Error: Your offer cannot be below the minimum offer price."); // Set styles and disable the submit button document.getElementById('inputPrice').style.setProperty('border-color', 'red', 'important'); // Prevent form submission event.preventDefault(); canSubmitForm = false; // Set the flag to false } else { canSubmitForm = true; // Set the flag to true } // Check if the form can be submitted if (!canSubmitForm) { event.preventDefault(); alert("Error: Please enter a valid price."); } }); document.getElementById('inputPrice').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); // Make Offer2 var canSubmitForm2 = false; document.getElementById('priceForm2').addEventListener('submit', function (event) { var inputPrice = parseFloat(document.getElementById('inputPrice2').value); var discountedPrice = parseFloat(document.getElementById('discountPercentageInput').innerText); // Reset styles and enable the submit button document.getElementById('inputPrice2').style.removeProperty('border-color'); if (isNaN(inputPrice) || inputPrice < discountedPrice) { // Show an error message alert("Error: Your offer cannot be below the minimum offer price."); // Set styles and disable the submit button document.getElementById('inputPrice2').style.setProperty('border-color', 'red', 'important'); // Prevent form submission event.preventDefault(); canSubmitForm2 = false; // Set the flag to false } else { canSubmitForm2 = true; // Set the flag to true } // Check if the form can be submitted if (!canSubmitForm2) { event.preventDefault(); alert("Error: Please enter a valid price."); } }); document.getElementById('inputPrice2').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); // Escrow Form function submitForm(event) { // Prevent the default form submission event.preventDefault(); // Your existing form submission logic here $.ajax({ url: "/add-buyer", type: "POST", data: $(event.target).serialize(), success: function (data) { // Check if the server response indicates success if (data && data.success) { // Hide the Buy Now form $('#buyNowForm').hide(); // Show the escrow modal in front of the Buy Now form $('#escrowModal').modal('show').css({ 'z-index': 10000, 'position': 'absolute' }); // Set a higher z-index // Add an event listener for the modal's close button click $('#escrowModal .close').on('click', function () { // Perform any actions you want when the close button is clicked console.log('Close button clicked.'); // Close the modal $('#escrowModal').modal('hide'); // Show the Buy Now form again $('#buyNowForm').show(); }); } else { // Check if the error message indicates that the user has already submitted the form within the last hour if (data && data.error && data.error.includes('already submitted the form')) { alert(data.error); } else { // Display a generic error message alert("You have already submitted the contact form. Please try again after 1 hour."); } } }, error: function () { // Handle the case where there was an error with the AJAX request alert("An error occurred while submitting the form."); } }); } // TELEPHONE FORMAT const phoneInputField1 = document.querySelector("#buy-now-phone"); const phoneInput1 = window.intlTelInput(phoneInputField1, { utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js", }); // Add an event listener for the "input" event on the phone input field phoneInputField1.addEventListener("input", function () { // Get the selected country code const selectedCountryCode = phoneInput1.getSelectedCountryData().iso2; // Define the maximum number of digits based on the selected country code let maxDigits = 0; switch (selectedCountryCode) { case 'us': maxDigits = 10; // Assuming the US has a 10-digit phone number break; case 'gb': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; case 'pk': maxDigits = 11; // Assuming Pakistan has an 11-digit phone number break; // Add more cases for other countries as needed default: maxDigits = 15; // Default to a common maximum number of digits } // Remove non-digit characters from the input value let phoneNumber = phoneInputField1.value.replace(/[^0-9]/g, ''); // Trim the phone number to the maximum allowed digits phoneNumber = phoneNumber.slice(0, maxDigits); // Update the input value phoneInputField1.value = phoneNumber; }); // Prevent pasting into the phone input field phoneInputField1.addEventListener("paste", function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); const phoneInputField2 = document.querySelector("#make-offer-phone"); const phoneInput2 = window.intlTelInput(phoneInputField2, { utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js", }); // Add an event listener for the "input" event on the phone input field phoneInputField2.addEventListener("input", function () { // Get the selected country code const selectedCountryCode = phoneInput2.getSelectedCountryData().iso2; // Define the maximum number of digits based on the selected country code let maxDigits = 0; switch (selectedCountryCode) { case 'us': maxDigits = 10; // Assuming the US has a 10-digit phone number break; case 'gb': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; case 'pk': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; // Add more cases for other countries as needed default: maxDigits = 15; // Default to a common maximum number of digits } // Remove non-digit characters from the input value let phoneNumber = phoneInputField2.value.replace(/[^0-9]/g, ''); // Trim the phone number to the maximum allowed digits phoneNumber = phoneNumber.slice(0, maxDigits); // Update the input value phoneInputField2.value = phoneNumber; }); // Prevent pasting into the phone input field phoneInputField2.addEventListener("paste", function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); const phoneInputField3 = document.querySelector("#make-offer-2-phone"); const phoneInput3 = window.intlTelInput(phoneInputField3, { utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js", }); // Add an event listener for the "input" event on the phone input field phoneInputField3.addEventListener("input", function () { // Get the selected country code const selectedCountryCode = phoneInput3.getSelectedCountryData().iso2; // Define the maximum number of digits based on the selected country code let maxDigits = 0; switch (selectedCountryCode) { case 'us': maxDigits = 10; // Assuming the US has a 10-digit phone number break; case 'gb': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; case 'pk': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; // Add more cases for other countries as needed default: maxDigits = 15; // Default to a common maximum number of digits } // Remove non-digit characters from the input value let phoneNumber = phoneInputField3.value.replace(/[^0-9]/g, ''); // Trim the phone number to the maximum allowed digits phoneNumber = phoneNumber.slice(0, maxDigits); // Update the input value phoneInputField3.value = phoneNumber; }); // Prevent pasting into the phone input field phoneInputField3.addEventListener("paste", function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); const phoneInputField4 = document.querySelector("#contact-phone"); const phoneInput4 = window.intlTelInput(phoneInputField4, { utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js", }); // Add an event listener for the "input" event on the phone input field phoneInputField4.addEventListener("input", function () { // Get the selected country code const selectedCountryCode = phoneInput4.getSelectedCountryData().iso2; // Define the maximum number of digits based on the selected country code let maxDigits = 0; switch (selectedCountryCode) { case 'us': maxDigits = 10; // Assuming the US has a 10-digit phone number break; case 'gb': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; case 'pk': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; // Add more cases for other countries as needed default: maxDigits = 15; // Default to a common maximum number of digits } // Remove non-digit characters from the input value let phoneNumber = phoneInputField4.value.replace(/[^0-9]/g, ''); // Trim the phone number to the maximum allowed digits phoneNumber = phoneNumber.slice(0, maxDigits); // Update the input value phoneInputField4.value = phoneNumber; }); // Prevent pasting into the phone input field phoneInputField4.addEventListener("paste", function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); // Disable Copy Pasting document.getElementById('noPasteInput1').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput2').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput3').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput4').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput5').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput6').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput7').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput8').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput9').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput10').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput11').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput12').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput13').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); // Make Offer document.getElementById("inputPrice").addEventListener("input", function(event) { const inputValue = event.target.value; // Replace any non-numeric characters const sanitizedValue = inputValue.replace(/\D/g, ""); // Limit the length to 10 digits const truncatedValue = sanitizedValue.slice(0, 5); // Update the input value with the sanitized value event.target.value = truncatedValue; }); document.getElementById("inputPrice2").addEventListener("input", function(event) { const inputValue = event.target.value; // Replace any non-numeric characters const sanitizedValue = inputValue.replace(/\D/g, ""); // Limit the length to 10 digits const truncatedValue = sanitizedValue.slice(0, 5); // Update the input value with the sanitized value event.target.value = truncatedValue; });/** * Template Name: NewBiz * Updated: Sep 18 2023 with Bootstrap v5.3.2 * Template URL: https://bootstrapmade.com/newbiz-bootstrap-business-template/ * Author: BootstrapMade.com * License: https://bootstrapmade.com/license/ */ (function () { "use strict"; /** * Easy selector helper function */ const select = (el, all = false) => { el = el.trim() if (all) { return [...document.querySelectorAll(el)] } else { return document.querySelector(el) } } /** * Easy event listener function */ const on = (type, el, listener, all = false) => { let selectEl = select(el, all) if (selectEl) { if (all) { selectEl.forEach(e => e.addEventListener(type, listener)) } else { selectEl.addEventListener(type, listener) } } } /** * Easy on scroll event listener */ const onscroll = (el, listener) => { el.addEventListener('scroll', listener) } /** * Navbar links active state on scroll */ let navbarlinks = select('#navbar .scrollto', true) const navbarlinksActive = () => { let position = window.scrollY + 200 navbarlinks.forEach(navbarlink => { if (!navbarlink.hash) return let section = select(navbarlink.hash) if (!section) return if (position >= section.offsetTop && position <= (section.offsetTop + section.offsetHeight)) { navbarlink.classList.add('active') } else { navbarlink.classList.remove('active') } }) } window.addEventListener('load', navbarlinksActive) onscroll(document, navbarlinksActive) /** * Scrolls to an element with header offset */ const scrollto = (el) => { let header = select('#header') let offset = header.offsetHeight if (!header.classList.contains('header-scrolled')) { offset -= 20 } let elementPos = select(el).offsetTop window.scrollTo({ top: elementPos - offset, behavior: 'smooth' }) } /** * Toggle .header-scrolled class to #header when page is scrolled */ let selectHeader = select('#header') if (selectHeader) { const headerScrolled = () => { if (window.scrollY > 100) { selectHeader.classList.add('header-scrolled') } else { selectHeader.classList.remove('header-scrolled') } } window.addEventListener('load', headerScrolled) onscroll(document, headerScrolled) } /** * Back to top button */ let backtotop = select('.back-to-top') if (backtotop) { const toggleBacktotop = () => { if (window.scrollY > 100) { backtotop.classList.add('active') } else { backtotop.classList.remove('active') } } window.addEventListener('load', toggleBacktotop) onscroll(document, toggleBacktotop) } /** * Mobile nav toggle */ on('click', '.mobile-nav-toggle', function (e) { select('#navbar').classList.toggle('navbar-mobile') this.classList.toggle('bi-list') this.classList.toggle('bi-x') }) /** * Mobile nav dropdowns activate */ on('click', '.navbar .dropdown > a', function (e) { if (select('#navbar').classList.contains('navbar-mobile')) { e.preventDefault() this.nextElementSibling.classList.toggle('dropdown-active') } }, true) /** * Scrool with ofset on links with a class name .scrollto */ on('click', '.scrollto', function (e) { if (select(this.hash)) { e.preventDefault() let navbar = select('#navbar') if (navbar.classList.contains('navbar-mobile')) { navbar.classList.remove('navbar-mobile') let navbarToggle = select('.mobile-nav-toggle') navbarToggle.classList.toggle('bi-list') navbarToggle.classList.toggle('bi-x') } scrollto(this.hash) } }, true) /** * Scroll with ofset on page load with hash links in the url */ window.addEventListener('load', () => { if (window.location.hash) { if (select(window.location.hash)) { scrollto(window.location.hash) } } }); /** * Porfolio isotope and filter */ window.addEventListener('load', () => { let portfolioContainer = select('.portfolio-container'); if (portfolioContainer) { let portfolioIsotope = new Isotope(portfolioContainer, { itemSelector: '.portfolio-item' }); let portfolioFilters = select('#portfolio-flters li', true); on('click', '#portfolio-flters li', function (e) { e.preventDefault(); portfolioFilters.forEach(function (el) { el.classList.remove('filter-active'); }); this.classList.add('filter-active'); portfolioIsotope.arrange({ filter: this.getAttribute('data-filter') }); portfolioIsotope.on('arrangeComplete', function () { AOS.refresh() }); }, true); } }); /** * Initiate portfolio lightbox */ const portfolioLightbox = GLightbox({ selector: '.portfolio-lightbox' }); /** * Portfolio details slider */ new Swiper('.portfolio-details-slider', { speed: 400, loop: true, autoplay: { delay: 5000, disableOnInteraction: false }, pagination: { el: '.swiper-pagination', type: 'bullets', clickable: true } }); /** * Testimonials slider */ new Swiper('.testimonials-slider', { speed: 600, loop: true, autoplay: { delay: 5000, disableOnInteraction: false }, slidesPerView: 'auto', pagination: { el: '.swiper-pagination', type: 'bullets', clickable: true } }); /** * Animation on scroll */ window.addEventListener('load', () => { AOS.init({ duration: 1000, easing: 'ease-in-out', once: true, mirror: false }) }); })() // Forms function showPopup(formId) { document.getElementById(formId).style.display = 'block'; document.getElementById('overlay').style.display = 'block'; setTimeout(function () { document.getElementById(formId).style.opacity = '1'; document.getElementById('overlay').style.opacity = '1'; }, 50); } function hidePopup(formId) { document.getElementById(formId).style.opacity = '0'; document.getElementById('overlay').style.opacity = '0'; setTimeout(function () { document.getElementById(formId).style.display = 'none'; document.getElementById('overlay').style.display = 'none'; }, 300); } //Make Offer var canSubmitForm = false; document.getElementById('priceForm').addEventListener('submit', function (event) { var inputPrice = parseFloat(document.getElementById('inputPrice').value); var discountedPrice = parseFloat(document.getElementById('discountPercentageInput').innerText); // Reset styles and enable the submit button document.getElementById('inputPrice').style.removeProperty('border-color'); if (isNaN(inputPrice) || inputPrice < discountedPrice) { // Show an error message alert("Error: Your offer cannot be below the minimum offer price."); // Set styles and disable the submit button document.getElementById('inputPrice').style.setProperty('border-color', 'red', 'important'); // Prevent form submission event.preventDefault(); canSubmitForm = false; // Set the flag to false } else { canSubmitForm = true; // Set the flag to true } // Check if the form can be submitted if (!canSubmitForm) { event.preventDefault(); alert("Error: Please enter a valid price."); } }); document.getElementById('inputPrice').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); // Make Offer2 var canSubmitForm2 = false; document.getElementById('priceForm2').addEventListener('submit', function (event) { var inputPrice = parseFloat(document.getElementById('inputPrice2').value); var discountedPrice = parseFloat(document.getElementById('discountPercentageInput').innerText); // Reset styles and enable the submit button document.getElementById('inputPrice2').style.removeProperty('border-color'); if (isNaN(inputPrice) || inputPrice < discountedPrice) { // Show an error message alert("Error: Your offer cannot be below the minimum offer price."); // Set styles and disable the submit button document.getElementById('inputPrice2').style.setProperty('border-color', 'red', 'important'); // Prevent form submission event.preventDefault(); canSubmitForm2 = false; // Set the flag to false } else { canSubmitForm2 = true; // Set the flag to true } // Check if the form can be submitted if (!canSubmitForm2) { event.preventDefault(); alert("Error: Please enter a valid price."); } }); document.getElementById('inputPrice2').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); // Escrow Form function submitForm(event) { // Prevent the default form submission event.preventDefault(); // Your existing form submission logic here $.ajax({ url: "/add-buyer", type: "POST", data: $(event.target).serialize(), success: function (data) { // Check if the server response indicates success if (data && data.success) { // Hide the Buy Now form $('#buyNowForm').hide(); // Show the escrow modal in front of the Buy Now form $('#escrowModal').modal('show').css({ 'z-index': 10000, 'position': 'absolute' }); // Set a higher z-index // Add an event listener for the modal's close button click $('#escrowModal .close').on('click', function () { // Perform any actions you want when the close button is clicked console.log('Close button clicked.'); // Close the modal $('#escrowModal').modal('hide'); // Show the Buy Now form again $('#buyNowForm').show(); }); } else { // Check if the error message indicates that the user has already submitted the form within the last hour if (data && data.error && data.error.includes('already submitted the form')) { alert(data.error); } else { // Display a generic error message alert("You have already submitted the contact form. Please try again after 1 hour."); } } }, error: function () { // Handle the case where there was an error with the AJAX request alert("An error occurred while submitting the form."); } }); } // TELEPHONE FORMAT const phoneInputField1 = document.querySelector("#buy-now-phone"); const phoneInput1 = window.intlTelInput(phoneInputField1, { utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js", }); // Add an event listener for the "input" event on the phone input field phoneInputField1.addEventListener("input", function () { // Get the selected country code const selectedCountryCode = phoneInput1.getSelectedCountryData().iso2; // Define the maximum number of digits based on the selected country code let maxDigits = 0; switch (selectedCountryCode) { case 'us': maxDigits = 10; // Assuming the US has a 10-digit phone number break; case 'gb': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; case 'pk': maxDigits = 11; // Assuming Pakistan has an 11-digit phone number break; // Add more cases for other countries as needed default: maxDigits = 15; // Default to a common maximum number of digits } // Remove non-digit characters from the input value let phoneNumber = phoneInputField1.value.replace(/[^0-9]/g, ''); // Trim the phone number to the maximum allowed digits phoneNumber = phoneNumber.slice(0, maxDigits); // Update the input value phoneInputField1.value = phoneNumber; }); // Prevent pasting into the phone input field phoneInputField1.addEventListener("paste", function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); const phoneInputField2 = document.querySelector("#make-offer-phone"); const phoneInput2 = window.intlTelInput(phoneInputField2, { utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js", }); // Add an event listener for the "input" event on the phone input field phoneInputField2.addEventListener("input", function () { // Get the selected country code const selectedCountryCode = phoneInput2.getSelectedCountryData().iso2; // Define the maximum number of digits based on the selected country code let maxDigits = 0; switch (selectedCountryCode) { case 'us': maxDigits = 10; // Assuming the US has a 10-digit phone number break; case 'gb': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; case 'pk': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; // Add more cases for other countries as needed default: maxDigits = 15; // Default to a common maximum number of digits } // Remove non-digit characters from the input value let phoneNumber = phoneInputField2.value.replace(/[^0-9]/g, ''); // Trim the phone number to the maximum allowed digits phoneNumber = phoneNumber.slice(0, maxDigits); // Update the input value phoneInputField2.value = phoneNumber; }); // Prevent pasting into the phone input field phoneInputField2.addEventListener("paste", function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); const phoneInputField3 = document.querySelector("#make-offer-2-phone"); const phoneInput3 = window.intlTelInput(phoneInputField3, { utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js", }); // Add an event listener for the "input" event on the phone input field phoneInputField3.addEventListener("input", function () { // Get the selected country code const selectedCountryCode = phoneInput3.getSelectedCountryData().iso2; // Define the maximum number of digits based on the selected country code let maxDigits = 0; switch (selectedCountryCode) { case 'us': maxDigits = 10; // Assuming the US has a 10-digit phone number break; case 'gb': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; case 'pk': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; // Add more cases for other countries as needed default: maxDigits = 15; // Default to a common maximum number of digits } // Remove non-digit characters from the input value let phoneNumber = phoneInputField3.value.replace(/[^0-9]/g, ''); // Trim the phone number to the maximum allowed digits phoneNumber = phoneNumber.slice(0, maxDigits); // Update the input value phoneInputField3.value = phoneNumber; }); // Prevent pasting into the phone input field phoneInputField3.addEventListener("paste", function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); const phoneInputField4 = document.querySelector("#contact-phone"); const phoneInput4 = window.intlTelInput(phoneInputField4, { utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js", }); // Add an event listener for the "input" event on the phone input field phoneInputField4.addEventListener("input", function () { // Get the selected country code const selectedCountryCode = phoneInput4.getSelectedCountryData().iso2; // Define the maximum number of digits based on the selected country code let maxDigits = 0; switch (selectedCountryCode) { case 'us': maxDigits = 10; // Assuming the US has a 10-digit phone number break; case 'gb': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; case 'pk': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; // Add more cases for other countries as needed default: maxDigits = 15; // Default to a common maximum number of digits } // Remove non-digit characters from the input value let phoneNumber = phoneInputField4.value.replace(/[^0-9]/g, ''); // Trim the phone number to the maximum allowed digits phoneNumber = phoneNumber.slice(0, maxDigits); // Update the input value phoneInputField4.value = phoneNumber; }); // Prevent pasting into the phone input field phoneInputField4.addEventListener("paste", function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); // Disable Copy Pasting document.getElementById('noPasteInput1').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput2').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput3').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput4').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput5').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput6').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput7').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput8').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput9').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput10').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput11').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput12').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput13').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); // Make Offer document.getElementById("inputPrice").addEventListener("input", function(event) { const inputValue = event.target.value; // Replace any non-numeric characters const sanitizedValue = inputValue.replace(/\D/g, ""); // Limit the length to 10 digits const truncatedValue = sanitizedValue.slice(0, 5); // Update the input value with the sanitized value event.target.value = truncatedValue; }); document.getElementById("inputPrice2").addEventListener("input", function(event) { const inputValue = event.target.value; // Replace any non-numeric characters const sanitizedValue = inputValue.replace(/\D/g, ""); // Limit the length to 10 digits const truncatedValue = sanitizedValue.slice(0, 5); // Update the input value with the sanitized value event.target.value = truncatedValue; });/** * Template Name: NewBiz * Updated: Sep 18 2023 with Bootstrap v5.3.2 * Template URL: https://bootstrapmade.com/newbiz-bootstrap-business-template/ * Author: BootstrapMade.com * License: https://bootstrapmade.com/license/ */ (function () { "use strict"; /** * Easy selector helper function */ const select = (el, all = false) => { el = el.trim() if (all) { return [...document.querySelectorAll(el)] } else { return document.querySelector(el) } } /** * Easy event listener function */ const on = (type, el, listener, all = false) => { let selectEl = select(el, all) if (selectEl) { if (all) { selectEl.forEach(e => e.addEventListener(type, listener)) } else { selectEl.addEventListener(type, listener) } } } /** * Easy on scroll event listener */ const onscroll = (el, listener) => { el.addEventListener('scroll', listener) } /** * Navbar links active state on scroll */ let navbarlinks = select('#navbar .scrollto', true) const navbarlinksActive = () => { let position = window.scrollY + 200 navbarlinks.forEach(navbarlink => { if (!navbarlink.hash) return let section = select(navbarlink.hash) if (!section) return if (position >= section.offsetTop && position <= (section.offsetTop + section.offsetHeight)) { navbarlink.classList.add('active') } else { navbarlink.classList.remove('active') } }) } window.addEventListener('load', navbarlinksActive) onscroll(document, navbarlinksActive) /** * Scrolls to an element with header offset */ const scrollto = (el) => { let header = select('#header') let offset = header.offsetHeight if (!header.classList.contains('header-scrolled')) { offset -= 20 } let elementPos = select(el).offsetTop window.scrollTo({ top: elementPos - offset, behavior: 'smooth' }) } /** * Toggle .header-scrolled class to #header when page is scrolled */ let selectHeader = select('#header') if (selectHeader) { const headerScrolled = () => { if (window.scrollY > 100) { selectHeader.classList.add('header-scrolled') } else { selectHeader.classList.remove('header-scrolled') } } window.addEventListener('load', headerScrolled) onscroll(document, headerScrolled) } /** * Back to top button */ let backtotop = select('.back-to-top') if (backtotop) { const toggleBacktotop = () => { if (window.scrollY > 100) { backtotop.classList.add('active') } else { backtotop.classList.remove('active') } } window.addEventListener('load', toggleBacktotop) onscroll(document, toggleBacktotop) } /** * Mobile nav toggle */ on('click', '.mobile-nav-toggle', function (e) { select('#navbar').classList.toggle('navbar-mobile') this.classList.toggle('bi-list') this.classList.toggle('bi-x') }) /** * Mobile nav dropdowns activate */ on('click', '.navbar .dropdown > a', function (e) { if (select('#navbar').classList.contains('navbar-mobile')) { e.preventDefault() this.nextElementSibling.classList.toggle('dropdown-active') } }, true) /** * Scrool with ofset on links with a class name .scrollto */ on('click', '.scrollto', function (e) { if (select(this.hash)) { e.preventDefault() let navbar = select('#navbar') if (navbar.classList.contains('navbar-mobile')) { navbar.classList.remove('navbar-mobile') let navbarToggle = select('.mobile-nav-toggle') navbarToggle.classList.toggle('bi-list') navbarToggle.classList.toggle('bi-x') } scrollto(this.hash) } }, true) /** * Scroll with ofset on page load with hash links in the url */ window.addEventListener('load', () => { if (window.location.hash) { if (select(window.location.hash)) { scrollto(window.location.hash) } } }); /** * Porfolio isotope and filter */ window.addEventListener('load', () => { let portfolioContainer = select('.portfolio-container'); if (portfolioContainer) { let portfolioIsotope = new Isotope(portfolioContainer, { itemSelector: '.portfolio-item' }); let portfolioFilters = select('#portfolio-flters li', true); on('click', '#portfolio-flters li', function (e) { e.preventDefault(); portfolioFilters.forEach(function (el) { el.classList.remove('filter-active'); }); this.classList.add('filter-active'); portfolioIsotope.arrange({ filter: this.getAttribute('data-filter') }); portfolioIsotope.on('arrangeComplete', function () { AOS.refresh() }); }, true); } }); /** * Initiate portfolio lightbox */ const portfolioLightbox = GLightbox({ selector: '.portfolio-lightbox' }); /** * Portfolio details slider */ new Swiper('.portfolio-details-slider', { speed: 400, loop: true, autoplay: { delay: 5000, disableOnInteraction: false }, pagination: { el: '.swiper-pagination', type: 'bullets', clickable: true } }); /** * Testimonials slider */ new Swiper('.testimonials-slider', { speed: 600, loop: true, autoplay: { delay: 5000, disableOnInteraction: false }, slidesPerView: 'auto', pagination: { el: '.swiper-pagination', type: 'bullets', clickable: true } }); /** * Animation on scroll */ window.addEventListener('load', () => { AOS.init({ duration: 1000, easing: 'ease-in-out', once: true, mirror: false }) }); })() // Forms function showPopup(formId) { document.getElementById(formId).style.display = 'block'; document.getElementById('overlay').style.display = 'block'; setTimeout(function () { document.getElementById(formId).style.opacity = '1'; document.getElementById('overlay').style.opacity = '1'; }, 50); } function hidePopup(formId) { document.getElementById(formId).style.opacity = '0'; document.getElementById('overlay').style.opacity = '0'; setTimeout(function () { document.getElementById(formId).style.display = 'none'; document.getElementById('overlay').style.display = 'none'; }, 300); } //Make Offer var canSubmitForm = false; document.getElementById('priceForm').addEventListener('submit', function (event) { var inputPrice = parseFloat(document.getElementById('inputPrice').value); var discountedPrice = parseFloat(document.getElementById('discountPercentageInput').innerText); // Reset styles and enable the submit button document.getElementById('inputPrice').style.removeProperty('border-color'); if (isNaN(inputPrice) || inputPrice < discountedPrice) { // Show an error message alert("Error: Your offer cannot be below the minimum offer price."); // Set styles and disable the submit button document.getElementById('inputPrice').style.setProperty('border-color', 'red', 'important'); // Prevent form submission event.preventDefault(); canSubmitForm = false; // Set the flag to false } else { canSubmitForm = true; // Set the flag to true } // Check if the form can be submitted if (!canSubmitForm) { event.preventDefault(); alert("Error: Please enter a valid price."); } }); document.getElementById('inputPrice').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); // Make Offer2 var canSubmitForm2 = false; document.getElementById('priceForm2').addEventListener('submit', function (event) { var inputPrice = parseFloat(document.getElementById('inputPrice2').value); var discountedPrice = parseFloat(document.getElementById('discountPercentageInput').innerText); // Reset styles and enable the submit button document.getElementById('inputPrice2').style.removeProperty('border-color'); if (isNaN(inputPrice) || inputPrice < discountedPrice) { // Show an error message alert("Error: Your offer cannot be below the minimum offer price."); // Set styles and disable the submit button document.getElementById('inputPrice2').style.setProperty('border-color', 'red', 'important'); // Prevent form submission event.preventDefault(); canSubmitForm2 = false; // Set the flag to false } else { canSubmitForm2 = true; // Set the flag to true } // Check if the form can be submitted if (!canSubmitForm2) { event.preventDefault(); alert("Error: Please enter a valid price."); } }); document.getElementById('inputPrice2').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); // Escrow Form function submitForm(event) { // Prevent the default form submission event.preventDefault(); // Your existing form submission logic here $.ajax({ url: "/add-buyer", type: "POST", data: $(event.target).serialize(), success: function (data) { // Check if the server response indicates success if (data && data.success) { // Hide the Buy Now form $('#buyNowForm').hide(); // Show the escrow modal in front of the Buy Now form $('#escrowModal').modal('show').css({ 'z-index': 10000, 'position': 'absolute' }); // Set a higher z-index // Add an event listener for the modal's close button click $('#escrowModal .close').on('click', function () { // Perform any actions you want when the close button is clicked console.log('Close button clicked.'); // Close the modal $('#escrowModal').modal('hide'); // Show the Buy Now form again $('#buyNowForm').show(); }); } else { // Check if the error message indicates that the user has already submitted the form within the last hour if (data && data.error && data.error.includes('already submitted the form')) { alert(data.error); } else { // Display a generic error message alert("You have already submitted the contact form. Please try again after 1 hour."); } } }, error: function () { // Handle the case where there was an error with the AJAX request alert("An error occurred while submitting the form."); } }); } // TELEPHONE FORMAT const phoneInputField1 = document.querySelector("#buy-now-phone"); const phoneInput1 = window.intlTelInput(phoneInputField1, { utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js", }); // Add an event listener for the "input" event on the phone input field phoneInputField1.addEventListener("input", function () { // Get the selected country code const selectedCountryCode = phoneInput1.getSelectedCountryData().iso2; // Define the maximum number of digits based on the selected country code let maxDigits = 0; switch (selectedCountryCode) { case 'us': maxDigits = 10; // Assuming the US has a 10-digit phone number break; case 'gb': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; case 'pk': maxDigits = 11; // Assuming Pakistan has an 11-digit phone number break; // Add more cases for other countries as needed default: maxDigits = 15; // Default to a common maximum number of digits } // Remove non-digit characters from the input value let phoneNumber = phoneInputField1.value.replace(/[^0-9]/g, ''); // Trim the phone number to the maximum allowed digits phoneNumber = phoneNumber.slice(0, maxDigits); // Update the input value phoneInputField1.value = phoneNumber; }); // Prevent pasting into the phone input field phoneInputField1.addEventListener("paste", function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); const phoneInputField2 = document.querySelector("#make-offer-phone"); const phoneInput2 = window.intlTelInput(phoneInputField2, { utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js", }); // Add an event listener for the "input" event on the phone input field phoneInputField2.addEventListener("input", function () { // Get the selected country code const selectedCountryCode = phoneInput2.getSelectedCountryData().iso2; // Define the maximum number of digits based on the selected country code let maxDigits = 0; switch (selectedCountryCode) { case 'us': maxDigits = 10; // Assuming the US has a 10-digit phone number break; case 'gb': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; case 'pk': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; // Add more cases for other countries as needed default: maxDigits = 15; // Default to a common maximum number of digits } // Remove non-digit characters from the input value let phoneNumber = phoneInputField2.value.replace(/[^0-9]/g, ''); // Trim the phone number to the maximum allowed digits phoneNumber = phoneNumber.slice(0, maxDigits); // Update the input value phoneInputField2.value = phoneNumber; }); // Prevent pasting into the phone input field phoneInputField2.addEventListener("paste", function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); const phoneInputField3 = document.querySelector("#make-offer-2-phone"); const phoneInput3 = window.intlTelInput(phoneInputField3, { utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js", }); // Add an event listener for the "input" event on the phone input field phoneInputField3.addEventListener("input", function () { // Get the selected country code const selectedCountryCode = phoneInput3.getSelectedCountryData().iso2; // Define the maximum number of digits based on the selected country code let maxDigits = 0; switch (selectedCountryCode) { case 'us': maxDigits = 10; // Assuming the US has a 10-digit phone number break; case 'gb': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; case 'pk': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; // Add more cases for other countries as needed default: maxDigits = 15; // Default to a common maximum number of digits } // Remove non-digit characters from the input value let phoneNumber = phoneInputField3.value.replace(/[^0-9]/g, ''); // Trim the phone number to the maximum allowed digits phoneNumber = phoneNumber.slice(0, maxDigits); // Update the input value phoneInputField3.value = phoneNumber; }); // Prevent pasting into the phone input field phoneInputField3.addEventListener("paste", function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); const phoneInputField4 = document.querySelector("#contact-phone"); const phoneInput4 = window.intlTelInput(phoneInputField4, { utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js", }); // Add an event listener for the "input" event on the phone input field phoneInputField4.addEventListener("input", function () { // Get the selected country code const selectedCountryCode = phoneInput4.getSelectedCountryData().iso2; // Define the maximum number of digits based on the selected country code let maxDigits = 0; switch (selectedCountryCode) { case 'us': maxDigits = 10; // Assuming the US has a 10-digit phone number break; case 'gb': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; case 'pk': maxDigits = 11; // Assuming the UK has an 11-digit phone number break; // Add more cases for other countries as needed default: maxDigits = 15; // Default to a common maximum number of digits } // Remove non-digit characters from the input value let phoneNumber = phoneInputField4.value.replace(/[^0-9]/g, ''); // Trim the phone number to the maximum allowed digits phoneNumber = phoneNumber.slice(0, maxDigits); // Update the input value phoneInputField4.value = phoneNumber; }); // Prevent pasting into the phone input field phoneInputField4.addEventListener("paste", function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); // Disable Copy Pasting document.getElementById('noPasteInput1').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput2').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput3').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput4').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput5').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput6').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput7').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput8').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput9').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput10').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput11').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput12').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); document.getElementById('noPasteInput13').addEventListener('paste', function (event) { event.preventDefault(); alert('Pasting is disabled in this input field.'); }); // Make Offer document.getElementById("inputPrice").addEventListener("input", function(event) { const inputValue = event.target.value; // Replace any non-numeric characters const sanitizedValue = inputValue.replace(/\D/g, ""); // Limit the length to 10 digits const truncatedValue = sanitizedValue.slice(0, 5); // Update the input value with the sanitized value event.target.value = truncatedValue; }); document.getElementById("inputPrice2").addEventListener("input", function(event) { const inputValue = event.target.value; // Replace any non-numeric characters const sanitizedValue = inputValue.replace(/\D/g, ""); // Limit the length to 10 digits const truncatedValue = sanitizedValue.slice(0, 5); // Update the input value with the sanitized value event.target.value = truncatedValue; }); Target class [App\Http\Controllers\FrontController] does not exist.