Rammohan0504 commited on
Commit
6f878ec
·
verified ·
1 Parent(s): c362922

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
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
- // Reset selections
182
- selectedSpice = null;
183
- selectedExtras = [];
184
- const spiceInputs = document.querySelectorAll('input[name=spice]');
185
- spiceInputs.forEach(input => input.checked = false);
186
- const extraInputs = document.querySelectorAll('input[name=extras]');
187
- extraInputs.forEach(input => input.checked = false);
 
 
 
 
 
 
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()