Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -112,7 +112,7 @@ with gr.Blocks() as demo:
|
|
| 112 |
border-radius: 5px; cursor: pointer;">Add to Cart</button>
|
| 113 |
</div>
|
| 114 |
<script>
|
| 115 |
-
function showPopup(image, title, description, price) {
|
| 116 |
document.getElementById('popup-image').src = image;
|
| 117 |
document.getElementById('popup-title').textContent = title;
|
| 118 |
document.getElementById('popup-description').textContent = description;
|
|
@@ -120,20 +120,20 @@ with gr.Blocks() as demo:
|
|
| 120 |
|
| 121 |
// Display the popup
|
| 122 |
document.getElementById('popup').style.display = 'block';
|
| 123 |
-
}
|
| 124 |
-
function closePopup() {
|
| 125 |
document.getElementById('popup').style.display = 'none';
|
| 126 |
-
}
|
| 127 |
-
function addToCart() {
|
| 128 |
const extras = Array.from(document.querySelectorAll('input[name=extras]:checked'))
|
| 129 |
.map(extra => extra.value)
|
| 130 |
.join(", ");
|
| 131 |
alert("Item added to cart with extras: " + extras);
|
| 132 |
closePopup();
|
| 133 |
-
}
|
| 134 |
</script>
|
| 135 |
""")
|
| 136 |
-
|
| 137 |
|
| 138 |
# Button click events
|
| 139 |
btn_all.click(
|
|
@@ -149,48 +149,4 @@ demo.launch()
|
|
| 149 |
outputs=dish_display
|
| 150 |
)
|
| 151 |
|
| 152 |
-
demo.launch()gr.HTML(f"""
|
| 153 |
-
<div id="popup" style="display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
|
| 154 |
-
background-color: white; padding: 20px; border-radius: 10px;
|
| 155 |
-
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 500px;">
|
| 156 |
-
<span onclick="closePopup()" style="position: absolute; top: 10px; right: 10px; cursor: pointer; font-size: 20px;">×</span>
|
| 157 |
-
|
| 158 |
-
<img id="popup-image" src="" alt="" style="width: 100%; height: auto; border-radius: 10px;">
|
| 159 |
-
<h2 id="popup-title" style="margin-top: 20px; color: #444;"></h2>
|
| 160 |
-
<p id="popup-description" style="margin-top: 10px; font-size: 16px; color: #666;"></p>
|
| 161 |
-
<p id="popup-price" style="margin-top: 10px; font-size: 16px; color: #444;"></p>
|
| 162 |
-
|
| 163 |
-
<h4 style="text-align: left; margin-top: 20px;">Choose Extras</h4>
|
| 164 |
-
<div style="display: flex; flex-wrap: wrap; justify-content: space-between; border: 1px solid #ddd; padding: 10px; border-radius: 5px;">
|
| 165 |
-
<label style="margin-right: 10px;"><input type="checkbox" name="extras" value="Extra Raitha"> Extra Raitha</label>
|
| 166 |
-
<label style="margin-right: 10px;"><input type="checkbox" name="extras" value="Extra Salan"> Extra Salan</label>
|
| 167 |
-
</div>
|
| 168 |
-
|
| 169 |
-
<button onclick="addToCart()"
|
| 170 |
-
style="margin-top: 20px; padding: 10px 20px; background-color: #007bff; color: white; border: none;
|
| 171 |
-
border-radius: 5px; cursor: pointer;">Add to Cart</button>
|
| 172 |
-
</div>
|
| 173 |
-
<script>
|
| 174 |
-
function showPopup(image, title, description, price) {
|
| 175 |
-
document.getElementById('popup-image').src = image;
|
| 176 |
-
document.getElementById('popup-title').textContent = title;
|
| 177 |
-
document.getElementById('popup-description').textContent = description;
|
| 178 |
-
document.getElementById('popup-price').textContent = "Price: " + price;
|
| 179 |
-
|
| 180 |
-
// Display the popup
|
| 181 |
-
document.getElementById('popup').style.display = 'block';
|
| 182 |
-
}
|
| 183 |
-
function closePopup() {
|
| 184 |
-
document.getElementById('popup').style.display = 'none';
|
| 185 |
-
}
|
| 186 |
-
function addToCart() {
|
| 187 |
-
const extras = Array.from(document.querySelectorAll('input[name=extras]:checked'))
|
| 188 |
-
.map(extra => extra.value)
|
| 189 |
-
.join(", ");
|
| 190 |
-
alert("Item added to cart with extras: " + extras);
|
| 191 |
-
closePopup();
|
| 192 |
-
}
|
| 193 |
-
</script>
|
| 194 |
-
""")
|
| 195 |
-
|
| 196 |
demo.launch()
|
|
|
|
| 112 |
border-radius: 5px; cursor: pointer;">Add to Cart</button>
|
| 113 |
</div>
|
| 114 |
<script>
|
| 115 |
+
function showPopup(image, title, description, price) {{
|
| 116 |
document.getElementById('popup-image').src = image;
|
| 117 |
document.getElementById('popup-title').textContent = title;
|
| 118 |
document.getElementById('popup-description').textContent = description;
|
|
|
|
| 120 |
|
| 121 |
// Display the popup
|
| 122 |
document.getElementById('popup').style.display = 'block';
|
| 123 |
+
}}
|
| 124 |
+
function closePopup() {{
|
| 125 |
document.getElementById('popup').style.display = 'none';
|
| 126 |
+
}}
|
| 127 |
+
function addToCart() {{
|
| 128 |
const extras = Array.from(document.querySelectorAll('input[name=extras]:checked'))
|
| 129 |
.map(extra => extra.value)
|
| 130 |
.join(", ");
|
| 131 |
alert("Item added to cart with extras: " + extras);
|
| 132 |
closePopup();
|
| 133 |
+
}}
|
| 134 |
</script>
|
| 135 |
""")
|
| 136 |
+
|
| 137 |
|
| 138 |
# Button click events
|
| 139 |
btn_all.click(
|
|
|
|
| 149 |
outputs=dish_display
|
| 150 |
)
|
| 151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
demo.launch()
|