Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -84,7 +84,6 @@ menu_data = [
|
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
-
# Spice levels and extras
|
| 88 |
spice_levels = ["American Mild", "American Medium", "American Spicy",
|
| 89 |
"Indian Mild", "Indian Medium", "Indian Spicy", "Indian Very Spicy"]
|
| 90 |
extras = [
|
|
@@ -178,15 +177,20 @@ with gr.Blocks() as demo:
|
|
| 178 |
document.getElementById('popup-description').textContent = description;
|
| 179 |
document.getElementById('popup-price').textContent = "Price: " + price;
|
| 180 |
|
| 181 |
-
//
|
| 182 |
-
selectedSpice = null;
|
| 183 |
-
selectedExtras = [];
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
|
| 189 |
-
// Display the popup
|
| 190 |
document.getElementById('popup').style.display = 'block';
|
| 191 |
}
|
| 192 |
|
|
@@ -217,4 +221,4 @@ with gr.Blocks() as demo:
|
|
| 217 |
outputs=dish_display
|
| 218 |
)
|
| 219 |
|
| 220 |
-
demo.launch()
|
|
|
|
| 84 |
|
| 85 |
|
| 86 |
|
|
|
|
| 87 |
spice_levels = ["American Mild", "American Medium", "American Spicy",
|
| 88 |
"Indian Mild", "Indian Medium", "Indian Spicy", "Indian Very Spicy"]
|
| 89 |
extras = [
|
|
|
|
| 177 |
document.getElementById('popup-description').textContent = description;
|
| 178 |
document.getElementById('popup-price').textContent = "Price: " + price;
|
| 179 |
|
| 180 |
+
// Keep current state
|
| 181 |
+
selectedSpice = document.querySelector('input[name=spice]:checked')?.value || null;
|
| 182 |
+
selectedExtras = Array.from(document.querySelectorAll('input[name=extras]:checked')).map(input => input.value);
|
| 183 |
+
|
| 184 |
+
// Re-select checkboxes and radio buttons
|
| 185 |
+
if (selectedSpice) {
|
| 186 |
+
document.querySelector(`input[name=spice][value="${selectedSpice}"]`).checked = true;
|
| 187 |
+
}
|
| 188 |
+
document.querySelectorAll('input[name=extras]').forEach(input => {
|
| 189 |
+
if (selectedExtras.includes(input.value)) {
|
| 190 |
+
input.checked = true;
|
| 191 |
+
}
|
| 192 |
+
});
|
| 193 |
|
|
|
|
| 194 |
document.getElementById('popup').style.display = 'block';
|
| 195 |
}
|
| 196 |
|
|
|
|
| 221 |
outputs=dish_display
|
| 222 |
)
|
| 223 |
|
| 224 |
+
demo.launch()
|