Spaces:
Sleeping
Sleeping
Update static/script.js
Browse files- static/script.js +17 -1
static/script.js
CHANGED
|
@@ -361,7 +361,22 @@ function displayOptions(options) {
|
|
| 361 |
conversation.push({ role: 'user', message: opt.text });
|
| 362 |
chatMessages.innerHTML = '';
|
| 363 |
conversation.forEach(msg => addMessage(msg.role, msg.message));
|
| 364 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
};
|
| 366 |
chatMessages.appendChild(button);
|
| 367 |
});
|
|
@@ -380,6 +395,7 @@ function displayOptions(options) {
|
|
| 380 |
chatMessages.appendChild(backButton);
|
| 381 |
}
|
| 382 |
|
|
|
|
| 383 |
document.getElementById('userInput').addEventListener('keypress', function(e) {
|
| 384 |
if (e.key === 'Enter') {
|
| 385 |
sendMessage();
|
|
|
|
| 361 |
conversation.push({ role: 'user', message: opt.text });
|
| 362 |
chatMessages.innerHTML = '';
|
| 363 |
conversation.forEach(msg => addMessage(msg.role, msg.message));
|
| 364 |
+
|
| 365 |
+
if (opt.text === 'Yes') {
|
| 366 |
+
// When 'Yes' is clicked, fetch both vegetarian and non-vegetarian ingredients
|
| 367 |
+
fetchIngredients('both');
|
| 368 |
+
} else if (opt.text === 'No') {
|
| 369 |
+
// When 'No' is clicked, proceed as before (e.g., add item to cart)
|
| 370 |
+
addToCart(selectedMenuItem);
|
| 371 |
+
addMessage('bot', 'Item added to cart! Would you like to order more?');
|
| 372 |
+
const options = [
|
| 373 |
+
{ text: 'Yes', class: 'green' },
|
| 374 |
+
{ text: 'No', class: 'red' }
|
| 375 |
+
];
|
| 376 |
+
displayOptions(options);
|
| 377 |
+
selectedMenuItem = null;
|
| 378 |
+
selectedIngredients = [];
|
| 379 |
+
}
|
| 380 |
};
|
| 381 |
chatMessages.appendChild(button);
|
| 382 |
});
|
|
|
|
| 395 |
chatMessages.appendChild(backButton);
|
| 396 |
}
|
| 397 |
|
| 398 |
+
|
| 399 |
document.getElementById('userInput').addEventListener('keypress', function(e) {
|
| 400 |
if (e.key === 'Enter') {
|
| 401 |
sendMessage();
|