Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -60,50 +60,51 @@ def app():
|
|
60 |
# Modal window
|
61 |
modal_window = gr.HTML("""
|
62 |
<div id="modal" style="display: none; position: fixed; top: 40%; left: 50%; transform: translate(-50%, -40%); width: 50%; background: white; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); padding: 20px; z-index: 1000;">
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
<!-- Biryani Extras -->
|
83 |
-
<label for="biryani-extras">Biryani Extras (Optional - Choose as many as you like):</label>
|
84 |
-
<div id="biryani-extras-options" style="display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0;">
|
85 |
-
<label><input type="checkbox" name="biryani-extra" value="Extra Raitha 4oz" /> Extra Raitha 4oz + $1.00</label>
|
86 |
-
<label><input type="checkbox" name="biryani-extra" value="Extra Raitha 8oz" /> Extra Raitha 8oz + $2.00</label>
|
87 |
-
<label><input type="checkbox" name="biryani-extra" value="Extra Salan 4oz" /> Extra Salan 4oz + $1.00</label>
|
88 |
-
<label><input type="checkbox" name="biryani-extra" value="Extra Salan 8oz" /> Extra Salan 8oz + $2.00</label>
|
89 |
-
<label><input type="checkbox" name="biryani-extra" value="Extra Onion" /> Extra Onion + $1.00</label>
|
90 |
-
<label><input type="checkbox" name="biryani-extra" value="Extra Onion & Lemon" /> Extra Onion & Lemon + $2.00</label>
|
91 |
-
<label><input type="checkbox" name="biryani-extra" value="Extra Fried Onion" /> Extra Fried Onion 4oz + $2.00</label>
|
92 |
-
</div>
|
93 |
-
|
94 |
-
<!-- Quantity and Special Instructions -->
|
95 |
-
<label for="quantity">Quantity:</label>
|
96 |
-
<input type="number" id="quantity" value="1" min="1" style="width: 50px;" />
|
97 |
-
<br><br>
|
98 |
-
<textarea id="special-instructions" placeholder="Add special instructions here..." style="width: 100%; height: 60px;"></textarea>
|
99 |
-
<br><br>
|
100 |
-
|
101 |
-
<!-- Add to Cart Button -->
|
102 |
-
<button style="background-color: #28a745; color: white; border: none; padding: 10px 20px; font-size: 14px; border-radius: 5px; cursor: pointer;">Add to Cart</button>
|
103 |
-
</div>
|
104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
<script>
|
|
|
|
|
|
|
107 |
function openModal(name, image, description, price) {
|
108 |
document.getElementById('modal').style.display = 'block';
|
109 |
document.getElementById('modal-image').src = image;
|
@@ -111,9 +112,44 @@ def app():
|
|
111 |
document.getElementById('modal-description').innerText = description;
|
112 |
document.getElementById('modal-price').innerText = price;
|
113 |
}
|
|
|
114 |
function closeModal() {
|
115 |
document.getElementById('modal').style.display = 'none';
|
116 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
</script>
|
118 |
""")
|
119 |
|
|
|
60 |
# Modal window
|
61 |
modal_window = gr.HTML("""
|
62 |
<div id="modal" style="display: none; position: fixed; top: 40%; left: 50%; transform: translate(-50%, -40%); width: 50%; background: white; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); padding: 20px; z-index: 1000;">
|
63 |
+
<div style="text-align: right;">
|
64 |
+
<button onclick="closeModal()" style="background: none; border: none; font-size: 18px; cursor: pointer;">×</button>
|
65 |
+
</div>
|
66 |
+
<img id="modal-image" style="width: 100%; height: auto; border-radius: 8px; margin-bottom: 20px;" />
|
67 |
+
<h2 id="modal-name"></h2>
|
68 |
+
<p id="modal-description"></p>
|
69 |
+
<p id="modal-price"></p>
|
70 |
+
|
71 |
+
<!-- Spice Levels -->
|
72 |
+
<label for="spice-level">Choose a Spice Level (Required):</label>
|
73 |
+
<div id="spice-level-options" style="display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0;">
|
74 |
+
<label><input type="radio" name="spice-level" value="American Mild" required /> American Mild</label>
|
75 |
+
<label><input type="radio" name="spice-level" value="American Medium" required /> American Medium</label>
|
76 |
+
<label><input type="radio" name="spice-level" value="American Spicy" required /> American Spicy</label>
|
77 |
+
<label><input type="radio" name="spice-level" value="Indian Mild" required /> Indian Mild</label>
|
78 |
+
<label><input type="radio" name="spice-level" value="Indian Medium" required /> Indian Medium</label>
|
79 |
+
<label><input type="radio" name="spice-level" value="Indian Very Spicy" required /> Indian Very Spicy</label>
|
80 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
+
<!-- Biryani Extras -->
|
83 |
+
<label for="biryani-extras">Biryani Extras (Optional - Choose as many as you like):</label>
|
84 |
+
<div id="biryani-extras-options" style="display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0;">
|
85 |
+
<label><input type="checkbox" name="biryani-extra" value="Extra Raitha 4oz" /> Extra Raitha 4oz + $1.00</label>
|
86 |
+
<label><input type="checkbox" name="biryani-extra" value="Extra Raitha 8oz" /> Extra Raitha 8oz + $2.00</label>
|
87 |
+
<label><input type="checkbox" name="biryani-extra" value="Extra Salan 4oz" /> Extra Salan 4oz + $1.00</label>
|
88 |
+
<label><input type="checkbox" name="biryani-extra" value="Extra Salan 8oz" /> Extra Salan 8oz + $2.00</label>
|
89 |
+
<label><input type="checkbox" name="biryani-extra" value="Extra Onion" /> Extra Onion + $1.00</label>
|
90 |
+
<label><input type="checkbox" name="biryani-extra" value="Extra Onion & Lemon" /> Extra Onion & Lemon + $2.00</label>
|
91 |
+
<label><input type="checkbox" name="biryani-extra" value="Extra Fried Onion" /> Extra Fried Onion 4oz + $2.00</label>
|
92 |
+
</div>
|
93 |
|
94 |
+
<!-- Quantity and Special Instructions -->
|
95 |
+
<label for="quantity">Quantity:</label>
|
96 |
+
<input type="number" id="quantity" value="1" min="1" style="width: 50px;" />
|
97 |
+
<br><br>
|
98 |
+
<textarea id="special-instructions" placeholder="Add special instructions here..." style="width: 100%; height: 60px;"></textarea>
|
99 |
+
<br><br>
|
100 |
+
|
101 |
+
<!-- Add to Cart Button -->
|
102 |
+
<button style="background-color: #28a745; color: white; border: none; padding: 10px 20px; font-size: 14px; border-radius: 5px; cursor: pointer;" onclick="addToCart()">Add to Cart</button>
|
103 |
+
</div>
|
104 |
<script>
|
105 |
+
// A placeholder for the cart items
|
106 |
+
let cart = [];
|
107 |
+
|
108 |
function openModal(name, image, description, price) {
|
109 |
document.getElementById('modal').style.display = 'block';
|
110 |
document.getElementById('modal-image').src = image;
|
|
|
112 |
document.getElementById('modal-description').innerText = description;
|
113 |
document.getElementById('modal-price').innerText = price;
|
114 |
}
|
115 |
+
|
116 |
function closeModal() {
|
117 |
document.getElementById('modal').style.display = 'none';
|
118 |
}
|
119 |
+
|
120 |
+
function addToCart() {
|
121 |
+
// Get dish details
|
122 |
+
const name = document.getElementById('modal-name').innerText;
|
123 |
+
const price = document.getElementById('modal-price').innerText;
|
124 |
+
const spiceLevel = document.querySelector('input[name="spice-level"]:checked')?.value || "Not Selected";
|
125 |
+
const quantity = parseInt(document.getElementById('quantity').value) || 1;
|
126 |
+
const instructions = document.getElementById('special-instructions').value;
|
127 |
+
|
128 |
+
// Get selected extras
|
129 |
+
const extras = Array.from(document.querySelectorAll('input[name="biryani-extra"]:checked')).map(extra => extra.value);
|
130 |
+
|
131 |
+
// Create a cart item object
|
132 |
+
const cartItem = {
|
133 |
+
name,
|
134 |
+
price,
|
135 |
+
spiceLevel,
|
136 |
+
quantity,
|
137 |
+
instructions,
|
138 |
+
extras
|
139 |
+
};
|
140 |
+
|
141 |
+
// Add to cart
|
142 |
+
cart.push(cartItem);
|
143 |
+
|
144 |
+
// Update the cart display (for demo purposes, we'll log it in the console)
|
145 |
+
console.log("Cart:", cart);
|
146 |
+
|
147 |
+
// Optionally, show a confirmation message
|
148 |
+
alert(`${name} added to cart!`);
|
149 |
+
|
150 |
+
// Close the modal
|
151 |
+
closeModal();
|
152 |
+
}
|
153 |
</script>
|
154 |
""")
|
155 |
|