Spaces:
Sleeping
Sleeping
Update app.py
Browse files94 unmodified lines95969798991001011021031041051061071081091101 unmodified line1121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411425 unmodified lines1481491501511521531541551561571581591601611621631641651661675 unmodified lines17317417517617717817918094 unmodified lines# JavaScript for popup modalpopup_js = """<script>function showPopup(name, description, price, image, element) {const popup = document.getElementById("custom-popup");const overlay = document.getElementById("overlay");// Get the bounding rectangle of the clicked elementconst rect = element.getBoundingClientRect();const offsetX = 10; // Offset for better alignmentconst offsetY = 10;popup.innerHTML = `<img src="${image}" alt="${name}" style="width: 200px; height: auto; border-radius: 10px; margin-bottom: 10px;"><h3 style="margin-top: 10px;">${name}</h3><p>${description}</p>1 unmodified line<h4 style="margin-top: 20px;">Choose a Spice Level</h4><div style="display: flex; flex-wrap: wrap; gap: 10px;">${["American Mild", "American Medium", "American Spicy", "Indian Mild", "Indian Medium", "Indian Spicy", "Indian Very Spicy"].map(spice => `<label style="margin-right: 10px;"><input type="radio" name="spice" value="${spice}"> ${spice}</label>`).join("")}</div><h4 style="margin-top: 20px;">Choose Extras</h4><div style="display: flex; flex-wrap: wrap; gap: 10px;">${["Extra Raitha 4oz + $1.00", "Extra Raitha 8oz + $2.00", "Extra Onion + $1.00", "Extra Onion & Lemon + $2.00"].map(extra => `<label style="margin-right: 10px;"><input type="checkbox" name="extras" value="${extra}"> ${extra}</label>`).join("")}</div><button onclick="closePopup()" style="margin-top: 20px; padding: 10px 20px; background-color: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer;">Add to Cart</button><button onclick="closePopup()" style="margin-top: 20px; margin-left: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;">Close</button>`;// Set popup position based on the clicked elementpopup.style.position = "absolute";popup.style.top = `${rect.top + window.scrollY + offsetY}px`;popup.style.left = `${rect.left + window.scrollX + offsetX}px`;popup.style.display = "block";overlay.style.display = "block";}5 unmodified linesoverlay.style.display = "none";}</script>"""# HTML for popup modalpopup_html = """<div id="overlay" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: none; z-index: 999;"></div><div id="custom-popup"style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 70%; max-width: 600px; background: white; padding: 20px; border-radius: 10px; box-shadow: 0px 4px 6px rgba(0,0,0,0.1); display: none; z-index: 1000; text-align: center;"></div>"""# Generate dish cardsdef display_dishes(category):html_content = "<div style='display: flex; flex-direction: column; min-height:50vh; gap: 20px; width: 80%; margin: 0 auto;'>"for dish in menu_data:if category == "ALL" or dish["category"] == category:html_content += f"""5 unmodified lines</div><div style='flex: 1; text-align: center;'><img src='{dish['image']}' alt='{dish['name']}' style='width: 120px; height: 80px; object-fit: cover; border-radius: 10px;'><button onclick="showPopup('{dish['name']}', '{dish['description']}', '{dish['price']}', '{dish['image']}', this)"style="margin-top: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;">Add</button></div></div>"""94 unmodified lines95969798991001011021031041 unmodified line1061071081091101111121131141151161171181191201211221231241251261271281291305 unmodified lines1361371381391401411421431441451461471481491501511521531545 unmodified lines16016116216316416516616716816994 unmodified lines# JavaScript for popup modalpopup_js = """<script>function showPopup(name, description, price, image) {const popup = document.getElementById("custom-popup");const overlay = document.getElementById("overlay");popup.innerHTML =<img src="${image}" alt="${name}" style="width: 200px; height: auto; border-radius: 10px; margin-bottom: 10px;"><h3 style="margin-top: 10px;">${name}</h3><p>${description}</p>1 unmodified line<h4 style="margin-top: 20px;">Choose a Spice Level</h4><div style="display: flex; flex-wrap: wrap; gap: 10px;">${["American Mild", "American Medium", "American Spicy", "Indian Mild", "Indian Medium", "Indian Spicy", "Indian Very Spicy"].map(spice =><label style="margin-right: 10px;"><input type="radio" name="spice" value="${spice}"> ${spice}</label>).join("")}</div><h4 style="margin-top: 20px;">Choose Extras</h4><div style="display: flex; flex-wrap: wrap; gap: 10px;">${["Extra Raitha 4oz + $1.00", "Extra Raitha 8oz + $2.00", "Extra Onion + $1.00", "Extra Onion & Lemon + $2.00"].map(extra =><label style="margin-right: 10px;"><input type="checkbox" name="extras" value="${extra}"> ${extra}</label>).join("")}</div><button onclick="closePopup()" style="margin-top: 20px; padding: 10px 20px; background-color: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer;">Add to Cart</button><button onclick="closePopup()" style="margin-top: 20px; margin-left: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;">Close</button>;popup.style.display = "block";overlay.style.display = "block";}5 unmodified linesoverlay.style.display = "none";}</script>"""# HTML for popup modalpopup_html = """<div id="overlay" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: none; z-index: 999;"></div><div id="custom-popup"style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 50%; max-width: 400px; background: white; padding: 20px; border-radius: 10px; box-shadow: 0px 4px 6px rgba(0,0,0,0.1); display: none; z-index: 1000; text-align: center;"></div>"""# Generate dish cardsdef display_dishes(category):html_content = "<div style='display: flex; flex-direction: column; gap: 20px; width: 80%; margin: 0 auto;'>"for dish in menu_data:if category == "ALL" or dish["category"] == category:html_content += f"""5 unmodified lines</div><div style='flex: 1; text-align: center;'><img src='{dish['image']}' alt='{dish['name']}' style='width: 120px; height: 80px; object-fit: cover; border-radius: 10px;'><button onclick="showPopup('{dish['name']}', '{dish['description']}', '{dish['price']}', '{dish['image']}')"style='margin-top: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;'>Add</button></div></div>"""
app.py+13-24