Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
<
|
| 107 |
-
|
| 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 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 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;">×</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;">×</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()
|