Skip to content

Commit

Permalink
Update script.js to add new functionality and fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
freedompraise committed Jun 29, 2024
1 parent d50f4f8 commit d52a69a
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 57 deletions.
1 change: 1 addition & 0 deletions quote.html
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ <h2 class="font-bold mb-4">Result:</h2>
</footer>

<script src="quote.js"></script>
<script src="script.js"></script>
</body>

</html>
114 changes: 57 additions & 57 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ function openOrderForm(productName, productImageSrc) {
orderFormSection.scrollIntoView({ behavior: "smooth" });
}


function scrollToInstallmentalPlan() {
const installmentalPaymentSection = document.getElementById(
"installmentalPaymentSection"
Expand All @@ -16,20 +15,17 @@ function scrollToInstallmentalPlan() {
installmentalPaymentSection.scrollIntoView({ behavior: "smooth" });
}


function openProductImagePopup(imageSrc) {
const popup = document.getElementById("productImagePopup");
const image = document.getElementById("popupImage");
image.src = imageSrc;
popup.style.display = "block";
}


function closeProductImagePopup() {
document.getElementById("productImagePopup").style.display = "none";
}


document.addEventListener("DOMContentLoaded", function () {
const orderButtons = document.querySelectorAll(".order-button");
const orderCovers = document.querySelectorAll(".object-cover");
Expand Down Expand Up @@ -61,7 +57,6 @@ document.addEventListener("DOMContentLoaded", function () {
});
});


// to open the product image popup when the order cover is clicked
orderCovers.forEach(function (cover) {
cover.addEventListener("click", function () {
Expand All @@ -70,7 +65,7 @@ document.addEventListener("DOMContentLoaded", function () {
});
});

// capture order and send to whatsapp
// capture order and send to whatsapp
const orderForm = document.getElementById("orderForm");
orderForm.addEventListener("submit", function (event) {
event.preventDefault();
Expand Down Expand Up @@ -105,73 +100,78 @@ document.addEventListener("DOMContentLoaded", function () {
});
});

// mobile menu
const mobileMenuButton = document.querySelector(".mobile-menu-button");
const mobileMenu = document.querySelector(".mobile-menu");

mobileMenuButton.addEventListener("click", () => {
mobileMenu.classList.toggle("hidden");
});

// slides
let slideIndex = 1;
showSlide(slideIndex);
// change slide with the prev/next button
function moveSlide(moveStep) {
showSlide(slideIndex += moveStep);
}
showSlide((slideIndex += moveStep));
}

function showSlide(n) {
let i;
const slides = document.getElementsByClassName("slide");
const dots = document.getElementsByClassName('dot');

if (n > slides.length) { slideIndex = 1 }
if (n < 1) { slideIndex = slides.length }
// hide all slides
for (i = 0; i < slides.length; i++) {
slides[i].classList.add('hidden');
}
// remove the active class from all dots
for (i = 0; i < dots.length; i++) {
dots[i].classList.remove('active');
}

slides[slideIndex - 1].classList.remove('hidden');
slides[slideIndex - 1].style.animation = 'slideRight 1s forwards';

};

setInterval(() => {
moveSlide(1);
}, 5000);



// toggle visibility of paragraphs when clicking on Font Awesome icons
document.addEventListener('DOMContentLoaded', function() {
const icons = document.querySelectorAll('.fa-plus-circle');

icons.forEach(icon => {
icon.addEventListener('click', function() {
const paragraph = this.parentElement.nextElementSibling;
paragraph.classList.toggle('hidden');
this.classList.toggle('fa-minus-circle');

});
const dots = document.getElementsByClassName("dot");

if (n > slides.length) {
slideIndex = 1;
}
if (n < 1) {
slideIndex = slides.length;
}
// hide all slides
for (i = 0; i < slides.length; i++) {
slides[i].classList.add("hidden");
}
// remove the active class from all dots
for (i = 0; i < dots.length; i++) {
dots[i].classList.remove("active");
}

slides[slideIndex - 1].classList.remove("hidden");
slides[slideIndex - 1].style.animation = "slideRight 1s forwards";
}

setInterval(() => {
moveSlide(1);
}, 5000);

// toggle visibility of paragraphs when clicking on Font Awesome icons
document.addEventListener("DOMContentLoaded", function () {
const icons = document.querySelectorAll(".fa-plus-circle");

icons.forEach((icon) => {
icon.addEventListener("click", function () {
const paragraph = this.parentElement.nextElementSibling;
paragraph.classList.toggle("hidden");
this.classList.toggle("fa-minus-circle");
});
});
});

const contactForm = document.getElementById("contactForm");
contactForm.addEventListener("submit", (event) => {
event.preventDefault(); // Prevent default form submission
const name = document.getElementById("name").value;
const number = document.getElementById("number").value;
const subject = document.getElementById("subject").value;
const message = document.getElementById("message").value;

const contactForm = document.getElementById('contactForm');
contactForm.addEventListener('submit', (event) => {
event.preventDefault(); // Prevent default form submission
const name = document.getElementById('name').value;
const number = document.getElementById('number').value;
const subject = document.getElementById('subject').value;
const message = document.getElementById('message').value;

const contactMessage = `Contact Details:
const contactMessage = `Contact Details:
Name: ${name}
Phone Number: ${number}
Subject: ${subject}
Message: ${message}`;

const encodedMessage = encodeURIComponent(contactMessage);
const whatsappURL = `https://wa.me/2348120691079/?text=${encodedMessage}`;
window.location.href = whatsappURL;
}
);
const encodedMessage = encodeURIComponent(contactMessage);
const whatsappURL = `https://wa.me/2348120691079/?text=${encodedMessage}`;
window.location.href = whatsappURL;
});

0 comments on commit d52a69a

Please sign in to comment.