Spaces:
Runtime error
Runtime error
Update templates/menu.html
Browse files- templates/menu.html +37 -49
templates/menu.html
CHANGED
@@ -136,11 +136,13 @@
|
|
136 |
align-items: center;
|
137 |
justify-content: center;
|
138 |
gap: 8px;
|
|
|
139 |
}
|
140 |
.view-cart-button:hover {
|
141 |
background-color: #109835;
|
142 |
text-decoration: none;
|
143 |
color: #fff;
|
|
|
144 |
}
|
145 |
.cart-icon-badge {
|
146 |
background-color: #fff;
|
@@ -154,6 +156,11 @@
|
|
154 |
font-size: 12px;
|
155 |
font-weight: bold;
|
156 |
margin-left: 5px;
|
|
|
|
|
|
|
|
|
|
|
157 |
}
|
158 |
.avatar-dropdown-container {
|
159 |
position: absolute;
|
@@ -792,8 +799,8 @@
|
|
792 |
<div class="view-cart-container">
|
793 |
<a href="{{ url_for('cart.cart') }}" class="view-cart-button">
|
794 |
<i class="bi bi-cart"></i>
|
795 |
-
|
796 |
-
|
797 |
</a>
|
798 |
</div>
|
799 |
|
@@ -1245,6 +1252,24 @@
|
|
1245 |
const img = new Image();
|
1246 |
img.src = link.href;
|
1247 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1248 |
});
|
1249 |
|
1250 |
function debounce(func, wait) {
|
@@ -1861,13 +1886,18 @@
|
|
1861 |
totalQuantity += item.quantity;
|
1862 |
});
|
1863 |
|
1864 |
-
// Update cart
|
1865 |
-
const
|
1866 |
-
if (
|
1867 |
-
|
1868 |
-
|
|
|
|
|
|
|
|
|
1869 |
}
|
1870 |
|
|
|
1871 |
const buttonContainers = document.querySelectorAll('.button-container');
|
1872 |
buttonContainers.forEach(container => {
|
1873 |
const itemName = container.getAttribute('data-item-name');
|
@@ -1891,48 +1921,6 @@
|
|
1891 |
}
|
1892 |
});
|
1893 |
}
|
1894 |
-
|
1895 |
-
document.addEventListener('DOMContentLoaded', function () {
|
1896 |
-
const decreaseBtn = document.getElementById('decreaseQuantity');
|
1897 |
-
const increaseBtn = document.getElementById('increaseQuantity');
|
1898 |
-
const quantityInput = document.getElementById('quantityInput');
|
1899 |
-
|
1900 |
-
decreaseBtn.addEventListener('click', function () {
|
1901 |
-
let currentQuantity = parseInt(quantityInput.value);
|
1902 |
-
if (currentQuantity > 1) {
|
1903 |
-
currentQuantity--;
|
1904 |
-
quantityInput.value = currentQuantity;
|
1905 |
-
}
|
1906 |
-
});
|
1907 |
-
|
1908 |
-
increaseBtn.addEventListener('click', function () {
|
1909 |
-
let currentQuantity = parseInt(quantityInput.value);
|
1910 |
-
currentQuantity++;
|
1911 |
-
quantityInput.value = currentQuantity;
|
1912 |
-
});
|
1913 |
-
|
1914 |
-
fetch('/cart/get')
|
1915 |
-
.then(response => {
|
1916 |
-
if (!response.ok) {
|
1917 |
-
throw new Error(`HTTP error! Status: ${response.status}`);
|
1918 |
-
}
|
1919 |
-
return response.json();
|
1920 |
-
})
|
1921 |
-
.then(data => {
|
1922 |
-
if (data.success) {
|
1923 |
-
updateCartUI(data.cart);
|
1924 |
-
} else {
|
1925 |
-
console.error('Failed to fetch cart:', data.error);
|
1926 |
-
const cart = getCartLocalStorage();
|
1927 |
-
updateCartUI(cart);
|
1928 |
-
}
|
1929 |
-
})
|
1930 |
-
.catch(err => {
|
1931 |
-
console.error('Error fetching cart:', err);
|
1932 |
-
const cart = getCartLocalStorage();
|
1933 |
-
updateCartUI(cart);
|
1934 |
-
});
|
1935 |
-
});
|
1936 |
</script>
|
1937 |
</body>
|
1938 |
</html>
|
|
|
136 |
align-items: center;
|
137 |
justify-content: center;
|
138 |
gap: 8px;
|
139 |
+
transition: background-color 0.3s ease, transform 0.2s ease;
|
140 |
}
|
141 |
.view-cart-button:hover {
|
142 |
background-color: #109835;
|
143 |
text-decoration: none;
|
144 |
color: #fff;
|
145 |
+
transform: scale(1.05);
|
146 |
}
|
147 |
.cart-icon-badge {
|
148 |
background-color: #fff;
|
|
|
156 |
font-size: 12px;
|
157 |
font-weight: bold;
|
158 |
margin-left: 5px;
|
159 |
+
transition: background-color 0.3s ease, color 0.3s ease;
|
160 |
+
}
|
161 |
+
.cart-icon-badge.active {
|
162 |
+
background-color: #ffcc00;
|
163 |
+
color: #0FAA39;
|
164 |
}
|
165 |
.avatar-dropdown-container {
|
166 |
position: absolute;
|
|
|
799 |
<div class="view-cart-container">
|
800 |
<a href="{{ url_for('cart.cart') }}" class="view-cart-button">
|
801 |
<i class="bi bi-cart"></i>
|
802 |
+
Go to Cart
|
803 |
+
<span id="cart-item-count" class="cart-icon-badge">0</span>
|
804 |
</a>
|
805 |
</div>
|
806 |
|
|
|
1252 |
const img = new Image();
|
1253 |
img.src = link.href;
|
1254 |
});
|
1255 |
+
|
1256 |
+
const decreaseBtn = document.getElementById('decreaseQuantity');
|
1257 |
+
const increaseBtn = document.getElementById('increaseQuantity');
|
1258 |
+
const quantityInput = document.getElementById('quantityInput');
|
1259 |
+
|
1260 |
+
decreaseBtn.addEventListener('click', function () {
|
1261 |
+
let currentQuantity = parseInt(quantityInput.value);
|
1262 |
+
if (currentQuantity > 1) {
|
1263 |
+
currentQuantity--;
|
1264 |
+
quantityInput.value = currentQuantity;
|
1265 |
+
}
|
1266 |
+
});
|
1267 |
+
|
1268 |
+
increaseBtn.addEventListener('click', function () {
|
1269 |
+
let currentQuantity = parseInt(quantityInput.value);
|
1270 |
+
currentQuantity++;
|
1271 |
+
quantityInput.value = currentQuantity;
|
1272 |
+
});
|
1273 |
});
|
1274 |
|
1275 |
function debounce(func, wait) {
|
|
|
1886 |
totalQuantity += item.quantity;
|
1887 |
});
|
1888 |
|
1889 |
+
// Update cart item count badge
|
1890 |
+
const cartItemCount = document.getElementById('cart-item-count');
|
1891 |
+
if (cartItemCount) {
|
1892 |
+
cartItemCount.innerText = totalQuantity;
|
1893 |
+
if (totalQuantity > 0) {
|
1894 |
+
cartItemCount.classList.add('active');
|
1895 |
+
} else {
|
1896 |
+
cartItemCount.classList.remove('active');
|
1897 |
+
}
|
1898 |
}
|
1899 |
|
1900 |
+
// Update quantity displays for soft drinks
|
1901 |
const buttonContainers = document.querySelectorAll('.button-container');
|
1902 |
buttonContainers.forEach(container => {
|
1903 |
const itemName = container.getAttribute('data-item-name');
|
|
|
1921 |
}
|
1922 |
});
|
1923 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1924 |
</script>
|
1925 |
</body>
|
1926 |
</html>
|