Spaces:
Sleeping
Sleeping
Update app.py
Browse files104 unmodified lines10510610710810911015 unmodified lines1261271281291301311321331341351361371381391401411421431441451461471481491501511527 unmodified lines1601611621631641651661671681691701711721731741751765 unmodified lines182183184185186187104 unmodified lines<button onclick="showPopup('{dish['image']}', '{dish['name']}', '{dish['description']}', '{dish['price']}', event)"style="margin-top: 15px; padding: 10px 20px; background-color: #28a745; color: white; border: none;border-radius: 5px; cursor: pointer;">Add</button></div></div>"""15 unmodified lines# JavaScript for managing the pop-upgr.HTML("""<div id="popup" style="display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);background-color: white; padding: 20px; border-radius: 10px;box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 500px;"><img id="popup-image" src="" alt="" style="width: 100%; height: auto; border-radius: 10px;"><h2 id="popup-title" style="margin-top: 20px; color: #444;"></h2><p id="popup-description" style="margin-top: 10px; font-size: 16px; color: #666;"></p><p id="popup-price" style="margin-top: 10px; font-size: 16px; color: #444;"></p><h4 style="text-align: left; margin-top: 20px;">Choose a spice level</h4><div style="display: flex; flex-wrap: wrap; justify-content: space-between; border: 1px solid #ddd; padding: 10px; border-radius: 5px;">""" + "".join([f'<label style="margin-right: 10px; display: block;"><input type="radio" name="spice" value="{spice}" style="margin-right: 5px;">{spice}</label>'for spice in spice_levels]) + """</div><h4 style="text-align: left; margin-top: 20px;">Choose Extras</h4><div style="display: flex; flex-wrap: wrap; justify-content: space-between; border: 1px solid #ddd; padding: 10px; border-radius: 5px;">""" + "".join([f'<label style="margin-right: 10px; display: block;"><input type="checkbox" name="extras" value="{extra["name"]}" style="margin-right: 5px;">{extra["name"]} + {extra["price"]}</label>'for extra in extras]) + """</div><button onclick="addToCart(document.getElementById('popup-title').textContent, document.querySelector('input[name=spice]:checked').value)"style="margin-top: 20px; padding: 10px 20px; background-color: #007bff; color: white; border: none;7 unmodified linesconst rect = event.target.getBoundingClientRect();// Set the content of the pop-updocument.getElementById('popup-image').src = image;document.getElementById('popup-title').textContent = title;document.getElementById('popup-description').textContent = description;document.getElementById('popup-price').textContent = "Price: " + price;// Position the pop-up near the clicked itemconst popup = document.getElementById('popup');popup.style.display = 'block';popup.style.position = 'absolute';popup.style.top = `${rect.top + window.scrollY + rect.height + 10}px`; // Below the buttonpopup.style.left = `${rect.left + window.scrollX}px`; // Align with the left of the button}function closePopup() {5 unmodified linesalert(dishName + " with " + spiceLevel + " spice level and extras: " + selectedExtras + " has been added to the cart!");}</script>""")# Button click eventsbtn_all.click(104 unmodified lines10510610710810911011115 unmodified lines1271281291301311321331341351361371381391401417 unmodified lines1491501511521531541551561571581591601611621631641655 unmodified lines171172173174175176177104 unmodified lines<button onclick="showPopup('{dish['image']}', '{dish['name']}', '{dish['description']}', '{dish['price']}', event)"style="margin-top: 15px; padding: 10px 20px; background-color: #28a745; color: white; border: none;border-radius: 5px; cursor: pointer;">Add</button></div></div>"""15 unmodified lines# JavaScript for managing the pop-upgr.HTML("""<div id="popup" style="display: none; position: absolute; background-color: white; padding: 20px; border-radius: 10px;box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 300px;"><img id="popup-image" src="" alt="" style="width: 100%; height: auto; border-radius: 10px;"><h2 id="popup-title" style="margin-top: 20px; color: #444;"></h2><p id="popup-description" style="margin-top: 10px; font-size: 16px; color: #666;"></p><p id="popup-price" style="margin-top: 10px; font-size: 16px; color: #444;"></p><button onclick="closePopup()" style="margin-top: 20px; padding: 10px 20px; background-color: #007bff;color: white; border: none; border-radius: 5px; cursor: pointer;">Close</button></div><button onclick="addToCart(document.getElementById('popup-title').textContent, document.querySelector('input[name=spice]:checked').value)"style="margin-top: 20px; padding: 10px 20px; background-color: #007bff; color: white; border: none;7 unmodified linesconst rect = event.target.getBoundingClientRect();// Set the content of the pop-upconst popup = document.getElementById('popup');document.getElementById('popup-image').src = image;document.getElementById('popup-title').textContent = title;document.getElementById('popup-description').textContent = description;document.getElementById('popup-price').textContent = "Price: " + price;// Position the pop-up near the clicked itempopup.style.display = 'block';popup.style.position = 'absolute';popup.style.top = `${rect.top + window.scrollY + rect.height + 10}px`; // Slightly below the buttonpopup.style.left = `${rect.left + window.scrollX}px`; // Align with the button's left side}function closePopup() {5 unmodified linesalert(dishName + " with " + spiceLevel + " spice level and extras: " + selectedExtras + " has been added to the cart!");}</script>""")# Button click eventsbtn_all.click(
app.py+14-24