Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -109,42 +109,25 @@ def modal_js():
|
|
109 |
<script>
|
110 |
let cart = [];
|
111 |
|
112 |
-
// Dynamically create and append the sticky cart button
|
113 |
-
document.addEventListener("DOMContentLoaded", function () {
|
114 |
-
const cartButton = document.createElement("div");
|
115 |
-
cartButton.id = "cart-button";
|
116 |
-
cartButton.style.position = "fixed";
|
117 |
-
cartButton.style.bottom = "20px";
|
118 |
-
cartButton.style.right = "20px";
|
119 |
-
cartButton.style.background = "#28a745";
|
120 |
-
cartButton.style.color = "white";
|
121 |
-
cartButton.style.padding = "10px 20px";
|
122 |
-
cartButton.style.borderRadius = "30px";
|
123 |
-
cartButton.style.cursor = "pointer";
|
124 |
-
cartButton.style.zIndex = "1000";
|
125 |
-
cartButton.textContent = "View Cart (0 items)";
|
126 |
-
cartButton.addEventListener("click", openCartModal);
|
127 |
-
document.body.appendChild(cartButton);
|
128 |
-
});
|
129 |
-
|
130 |
function openModal(name, image2, description, price) {
|
131 |
const modal = document.getElementById('modal');
|
132 |
-
modal.style.display = 'block';
|
133 |
modal.style.position = 'fixed';
|
134 |
modal.style.width = window.innerWidth <= 768 ? '90%' : '30%';
|
135 |
-
modal.style.top =
|
136 |
modal.style.left = '50%';
|
137 |
modal.style.transform = 'translate(-50%, -50%)';
|
138 |
-
document.getElementById('modal-image').src = image2;
|
139 |
document.getElementById('modal-name').innerText = name;
|
140 |
document.getElementById('modal-description').innerText = description;
|
141 |
document.getElementById('modal-price').innerText = price;
|
142 |
-
document.getElementById('quantity').value = 1;
|
143 |
-
document.getElementById('special-instructions').value = '';
|
144 |
}
|
145 |
|
146 |
function closeModal() {
|
147 |
-
document.getElementById('modal')
|
|
|
148 |
}
|
149 |
|
150 |
function addToCart() {
|
@@ -185,17 +168,18 @@ def modal_js():
|
|
185 |
</div>
|
186 |
`;
|
187 |
});
|
188 |
-
cartModal.style.display = 'block';
|
189 |
}
|
190 |
|
191 |
function closeCartModal() {
|
192 |
-
document.getElementById('cart-modal')
|
|
|
193 |
}
|
194 |
|
195 |
function removeFromCart(index) {
|
196 |
cart.splice(index, 1);
|
197 |
updateCartButton();
|
198 |
-
openCartModal();
|
199 |
}
|
200 |
|
201 |
function proceedToCheckout() {
|
|
|
109 |
<script>
|
110 |
let cart = [];
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
function openModal(name, image2, description, price) {
|
113 |
const modal = document.getElementById('modal');
|
114 |
+
modal.style.display = 'block'; // Make the modal visible
|
115 |
modal.style.position = 'fixed';
|
116 |
modal.style.width = window.innerWidth <= 768 ? '90%' : '30%';
|
117 |
+
modal.style.top = '50%';
|
118 |
modal.style.left = '50%';
|
119 |
modal.style.transform = 'translate(-50%, -50%)';
|
120 |
+
document.getElementById('modal-image').src = image2 || ''; // Set image or leave empty
|
121 |
document.getElementById('modal-name').innerText = name;
|
122 |
document.getElementById('modal-description').innerText = description;
|
123 |
document.getElementById('modal-price').innerText = price;
|
124 |
+
document.getElementById('quantity').value = 1; // Reset quantity
|
125 |
+
document.getElementById('special-instructions').value = ''; // Reset special instructions
|
126 |
}
|
127 |
|
128 |
function closeModal() {
|
129 |
+
const modal = document.getElementById('modal');
|
130 |
+
modal.style.display = 'none'; // Hide the modal
|
131 |
}
|
132 |
|
133 |
function addToCart() {
|
|
|
168 |
</div>
|
169 |
`;
|
170 |
});
|
171 |
+
cartModal.style.display = 'block'; // Make the cart modal visible
|
172 |
}
|
173 |
|
174 |
function closeCartModal() {
|
175 |
+
const cartModal = document.getElementById('cart-modal');
|
176 |
+
cartModal.style.display = 'none'; // Hide the cart modal
|
177 |
}
|
178 |
|
179 |
function removeFromCart(index) {
|
180 |
cart.splice(index, 1);
|
181 |
updateCartButton();
|
182 |
+
openCartModal(); // Refresh the cart modal
|
183 |
}
|
184 |
|
185 |
function proceedToCheckout() {
|