From 50bdfbcc0fdf7ead76e88400ed7dc485f5b52233 Mon Sep 17 00:00:00 2001 From: cowboykipnugget <524877@vistacollege.nl> Date: Thu, 13 Feb 2025 13:44:02 +0100 Subject: [PATCH 1/2] n --- website/welcome.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/welcome.html b/website/welcome.html index 8e4a925..b720b0e 100644 --- a/website/welcome.html +++ b/website/welcome.html @@ -15,7 +15,7 @@

Mees

Naar menu

- + From 248b2b4a7ecda13852ed6afc23392f9abab94481 Mon Sep 17 00:00:00 2001 From: vista-man <524715@vistacollege.nl> Date: Thu, 13 Feb 2025 13:44:06 +0100 Subject: [PATCH 2/2] cart icon --- website/cart.js | 38 +++++++++++++++++++++++--------------- website/index.html | 2 +- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/website/cart.js b/website/cart.js index 7048aac..a4b1ecf 100644 --- a/website/cart.js +++ b/website/cart.js @@ -1,20 +1,17 @@ - - // Array to hold items added to the shopping cart const cart = []; +let cartCount = 0; // Initialize cart count - - -// Functie om een item aan het winkelwagentje toe te voegen +// Function to add an item to the shopping cart function addToCart(item) { cart.unshift(item); // Add item to the beginning of the cart array updateCart(); + cartCount++; // Increment cart count + updateCartCountDisplay(); // Update the cart count display closeModal(); } - - -// Functie om het winkelwagentje bij te werken +// Function to update the shopping cart display function updateCart() { const cartItemsContainer = document.getElementById("cart-items"); cartItemsContainer.innerHTML = ''; @@ -41,18 +38,29 @@ function updateCart() { } } - -// Functie om een item uit het winkelwagentje te verwijderen +// Function to remove an item from the shopping cart function removeFromCart(index) { cart.splice(index, 1); updateCart(); + cartCount--; // Decrement cart count + updateCartCountDisplay(); // Update the cart count display } -// Initial call to updateCart to ensure the button is hidden on page load -updateCart(); +// Function to update the cart count display +function updateCartCountDisplay() { + const cartCountElement = document.getElementById("cart-count"); // Get the element to display the count + if (cartCountElement) { // Check if the element exists + cartCountElement.textContent = cartCount; // Update the text content with the cart count + } +} -// Functie om het modaal venster te sluiten + +// Initial calls +updateCart(); +updateCartCountDisplay(); // Initialize the cart count on page load + + +// Function to close the modal window function closeModal() { document.getElementById('modal').style.display = 'none'; -} - +} \ No newline at end of file diff --git a/website/index.html b/website/index.html index 6c24724..64c6963 100644 --- a/website/index.html +++ b/website/index.html @@ -56,7 +56,7 @@
- 0 + 0