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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -17
app.py CHANGED
@@ -84,6 +84,7 @@ menu_data = [
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,20 +178,6 @@ with gr.Blocks() as demo:
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
 
@@ -199,9 +186,9 @@ with gr.Blocks() as demo:
199
  }
200
 
201
  function addToCart() {
202
- selectedSpice = document.querySelector('input[name=spice]:checked')?.value || "No spice selected";
203
- selectedExtras = Array.from(document.querySelectorAll('input[name=extras]:checked')).map(input => input.value);
204
- alert(`Dish added with spice: ${selectedSpice} and extras: ${selectedExtras.join(", ")}`);
205
  closePopup();
206
  }
207
  </script>
 
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
  document.getElementById('popup-description').textContent = description;
179
  document.getElementById('popup-price').textContent = "Price: " + price;
180
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  document.getElementById('popup').style.display = 'block';
182
  }
183
 
 
186
  }
187
 
188
  function addToCart() {
189
+ const spice = document.querySelector('input[name=spice]:checked')?.value || "No spice selected";
190
+ const extras = Array.from(document.querySelectorAll('input[name=extras]:checked')).map(input => input.value);
191
+ alert(`Added with spice level: ${spice}, and extras: ${extras.join(", ")}`);
192
  closePopup();
193
  }
194
  </script>