Rammohan0504 commited on
Commit
ee9c531
·
verified ·
1 Parent(s): ce54f5f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +86 -39
app.py CHANGED
@@ -91,46 +91,49 @@ with gr.Blocks() as demo:
91
 
92
  # JavaScript for managing the pop-up
93
  gr.HTML(f"""
94
- <div id="popup" style="display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
95
- background-color: white; padding: 20px; border-radius: 10px;
96
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 500px;">
97
- <span onclick="closePopup()" style="position: absolute; top: 10px; right: 10px; cursor: pointer; font-size: 20px;">&times;</span>
98
-
99
- <img id="popup-image" src="" alt="" style="width: 100%; height: auto; border-radius: 10px;">
100
- <h2 id="popup-title" style="margin-top: 20px; color: #444;"></h2>
101
- <p id="popup-description" style="margin-top: 10px; font-size: 16px; color: #666;"></p>
102
- <p id="popup-price" style="margin-top: 10px; font-size: 16px; color: #444;"></p>
103
-
104
-
105
- <h4 style="text-align: left; margin-top: 20px;">Choose Extras</h4>
106
- <div style="display: flex; flex-wrap: wrap; justify-content: space-between; border: 1px solid #ddd; padding: 10px; border-radius: 5px;">
107
- <!-- Your extras section here -->
108
- </div>
109
-
110
- <button onclick="addToCart(document.getElementById('popup-title').textContent, document.querySelector('input[name=spice]:checked').value)"
111
- style="margin-top: 20px; padding: 10px 20px; background-color: #007bff; color: white; border: none;
112
- border-radius: 5px; cursor: pointer;">Add to Cart</button>
113
-
114
  </div>
115
- <script>
116
- function showPopup(image, title, description, price) {
117
- document.getElementById('popup-image').src = image;
118
- document.getElementById('popup-title').textContent = title;
119
- document.getElementById('popup-description').textContent = description;
120
- document.getElementById('popup-price').textContent = "Price: " + price;
121
-
122
- // Display the popup
123
- document.getElementById('popup').style.display = 'block';
124
- }
125
- function closePopup() {
126
- document.getElementById('popup').style.display = 'none';
127
- }
128
- function addToCart(dishName, spiceLevel) {
129
- const selectedExtras = Array.from(document.querySelectorAll('input[name=extras]:checked')).map(cb => cb.value).join(", ");
130
- alert(dishName + " with " + spiceLevel + " spice level and extras: " + selectedExtras + " has been added to the cart!");
131
- }
132
- </script>
133
- """)
 
 
 
 
 
 
 
 
 
134
 
135
  # Button click events
136
  btn_all.click(
@@ -146,4 +149,48 @@ with gr.Blocks() as demo:
146
  outputs=dish_display
147
  )
148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  demo.launch()
 
91
 
92
  # JavaScript for managing the pop-up
93
  gr.HTML(f"""
94
+ <div id="popup" style="display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
95
+ background-color: white; padding: 20px; border-radius: 10px;
96
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); z-index: 1000; text-align: center; width: 500px;">
97
+ <span onclick="closePopup()" style="position: absolute; top: 10px; right: 10px; cursor: pointer; font-size: 20px;">&times;</span>
98
+
99
+ <img id="popup-image" src="" alt="" style="width: 100%; height: auto; border-radius: 10px;">
100
+ <h2 id="popup-title" style="margin-top: 20px; color: #444;"></h2>
101
+ <p id="popup-description" style="margin-top: 10px; font-size: 16px; color: #666;"></p>
102
+ <p id="popup-price" style="margin-top: 10px; font-size: 16px; color: #444;"></p>
103
+
104
+ <h4 style="text-align: left; margin-top: 20px;">Choose Extras</h4>
105
+ <div style="display: flex; flex-wrap: wrap; justify-content: space-between; border: 1px solid #ddd; padding: 10px; border-radius: 5px;">
106
+ <label style="margin-right: 10px;"><input type="checkbox" name="extras" value="Extra Raitha"> Extra Raitha</label>
107
+ <label style="margin-right: 10px;"><input type="checkbox" name="extras" value="Extra Salan"> Extra Salan</label>
 
 
 
 
 
 
108
  </div>
109
+
110
+ <button onclick="addToCart()"
111
+ style="margin-top: 20px; padding: 10px 20px; background-color: #007bff; color: white; border: none;
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;
119
+ document.getElementById('popup-price').textContent = "Price: " + price;
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
+ demo.launch()
137
 
138
  # Button click events
139
  btn_all.click(
 
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;">&times;</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()