Rammohan0504 commited on
Commit
405c6b4
·
verified ·
1 Parent(s): 3875b13

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -24
app.py CHANGED
@@ -95,16 +95,10 @@ extras = [
95
  # JavaScript for popup modal
96
  popup_js = """
97
  <script>
98
- function showPopup(name, description, price, image, element) {
99
  const popup = document.getElementById("custom-popup");
100
  const overlay = document.getElementById("overlay");
101
-
102
- // Get the bounding rectangle of the clicked element
103
- const rect = element.getBoundingClientRect();
104
- const offsetX = 10; // Offset for better alignment
105
- const offsetY = 10;
106
-
107
- popup.innerHTML = `
108
  <img src="${image}" alt="${name}" style="width: 200px; height: auto; border-radius: 10px; margin-bottom: 10px;">
109
  <h3 style="margin-top: 10px;">${name}</h3>
110
  <p>${description}</p>
@@ -112,31 +106,25 @@ popup_js = """
112
 
113
  <h4 style="margin-top: 20px;">Choose a Spice Level</h4>
114
  <div style="display: flex; flex-wrap: wrap; gap: 10px;">
115
- ${["American Mild", "American Medium", "American Spicy", "Indian Mild", "Indian Medium", "Indian Spicy", "Indian Very Spicy"].map(spice => `
116
  <label style="margin-right: 10px;">
117
  <input type="radio" name="spice" value="${spice}"> ${spice}
118
  </label>
119
- `).join("")}
120
  </div>
121
 
122
  <h4 style="margin-top: 20px;">Choose Extras</h4>
123
  <div style="display: flex; flex-wrap: wrap; gap: 10px;">
124
- ${["Extra Raitha 4oz + $1.00", "Extra Raitha 8oz + $2.00", "Extra Onion + $1.00", "Extra Onion & Lemon + $2.00"].map(extra => `
125
  <label style="margin-right: 10px;">
126
  <input type="checkbox" name="extras" value="${extra}"> ${extra}
127
  </label>
128
- `).join("")}
129
  </div>
130
 
131
  <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>
132
  <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>
133
- `;
134
-
135
- // Set popup position based on the clicked element
136
- popup.style.position = "absolute";
137
- popup.style.top = `${rect.top + window.scrollY + offsetY}px`;
138
- popup.style.left = `${rect.left + window.scrollX + offsetX}px`;
139
-
140
  popup.style.display = "block";
141
  overlay.style.display = "block";
142
  }
@@ -148,20 +136,19 @@ popup_js = """
148
  overlay.style.display = "none";
149
  }
150
  </script>
151
-
152
  """
153
 
154
  # HTML for popup modal
155
  popup_html = """
156
  <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>
157
  <div id="custom-popup"
158
- 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;">
159
  </div>
160
  """
161
 
162
  # Generate dish cards
163
  def display_dishes(category):
164
- html_content = "<div style='display: flex; flex-direction: column; min-height:50vh; gap: 20px; width: 80%; margin: 0 auto;'>"
165
  for dish in menu_data:
166
  if category == "ALL" or dish["category"] == category:
167
  html_content += f"""
@@ -173,8 +160,10 @@ def display_dishes(category):
173
  </div>
174
  <div style='flex: 1; text-align: center;'>
175
  <img src='{dish['image']}' alt='{dish['name']}' style='width: 120px; height: 80px; object-fit: cover; border-radius: 10px;'>
176
- <button onclick="showPopup('{dish['name']}', '{dish['description']}', '{dish['price']}', '{dish['image']}', this)"
177
- style="margin-top: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;">Add</button>
 
 
178
  </div>
179
  </div>
180
  """
 
95
  # JavaScript for popup modal
96
  popup_js = """
97
  <script>
98
+ function showPopup(name, description, price, image) {
99
  const popup = document.getElementById("custom-popup");
100
  const overlay = document.getElementById("overlay");
101
+ popup.innerHTML =
 
 
 
 
 
 
102
  <img src="${image}" alt="${name}" style="width: 200px; height: auto; border-radius: 10px; margin-bottom: 10px;">
103
  <h3 style="margin-top: 10px;">${name}</h3>
104
  <p>${description}</p>
 
106
 
107
  <h4 style="margin-top: 20px;">Choose a Spice Level</h4>
108
  <div style="display: flex; flex-wrap: wrap; gap: 10px;">
109
+ ${["American Mild", "American Medium", "American Spicy", "Indian Mild", "Indian Medium", "Indian Spicy", "Indian Very Spicy"].map(spice =>
110
  <label style="margin-right: 10px;">
111
  <input type="radio" name="spice" value="${spice}"> ${spice}
112
  </label>
113
+ ).join("")}
114
  </div>
115
 
116
  <h4 style="margin-top: 20px;">Choose Extras</h4>
117
  <div style="display: flex; flex-wrap: wrap; gap: 10px;">
118
+ ${["Extra Raitha 4oz + $1.00", "Extra Raitha 8oz + $2.00", "Extra Onion + $1.00", "Extra Onion & Lemon + $2.00"].map(extra =>
119
  <label style="margin-right: 10px;">
120
  <input type="checkbox" name="extras" value="${extra}"> ${extra}
121
  </label>
122
+ ).join("")}
123
  </div>
124
 
125
  <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>
126
  <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>
127
+ ;
 
 
 
 
 
 
128
  popup.style.display = "block";
129
  overlay.style.display = "block";
130
  }
 
136
  overlay.style.display = "none";
137
  }
138
  </script>
 
139
  """
140
 
141
  # HTML for popup modal
142
  popup_html = """
143
  <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>
144
  <div id="custom-popup"
145
+ 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;">
146
  </div>
147
  """
148
 
149
  # Generate dish cards
150
  def display_dishes(category):
151
+ html_content = "<div style='display: flex; flex-direction: column; gap: 20px; width: 80%; margin: 0 auto;'>"
152
  for dish in menu_data:
153
  if category == "ALL" or dish["category"] == category:
154
  html_content += f"""
 
160
  </div>
161
  <div style='flex: 1; text-align: center;'>
162
  <img src='{dish['image']}' alt='{dish['name']}' style='width: 120px; height: 80px; object-fit: cover; border-radius: 10px;'>
163
+ <button onclick="showPopup('{dish['name']}', '{dish['description']}', '{dish['price']}', '{dish['image']}')"
164
+ style='margin-top: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer;'>
165
+ Add
166
+ </button>
167
  </div>
168
  </div>
169
  """