Spaces:
Sleeping
Sleeping
Update static/script.js
Browse files- static/script.js +8 -6
static/script.js
CHANGED
|
@@ -44,12 +44,12 @@ function handleResponse(userInput) {
|
|
| 44 |
options = [
|
| 45 |
{ text: 'Vegetarian', class: 'green' },
|
| 46 |
{ text: 'Non-Vegetarian', class: 'red' },
|
| 47 |
-
{ text: 'Both', class: 'gray' }
|
| 48 |
];
|
| 49 |
} else if (lastMessage.includes('vegetarian') || lastMessage.includes('non-vegetarian') || lastMessage.includes('both')) {
|
| 50 |
-
botResponse = `Great choice! 🍽️ These are the available ingredients for ${lastMessage}:`;
|
| 51 |
-
fetchIngredients(lastMessage.toLowerCase());
|
| 52 |
-
return;
|
| 53 |
}
|
| 54 |
|
| 55 |
addMessage('bot', botResponse);
|
|
@@ -75,6 +75,8 @@ function fetchIngredients(dietaryPreference) {
|
|
| 75 |
addMessage('bot', 'Great choice! These are available ingredients:');
|
| 76 |
displayIngredientsList(ingredients);
|
| 77 |
displaySelectedIngredients();
|
|
|
|
|
|
|
| 78 |
}
|
| 79 |
})
|
| 80 |
.catch(error => {
|
|
@@ -105,7 +107,7 @@ function displayIngredientsList(ingredients) {
|
|
| 105 |
img.src = ingredient.image_url || 'https://via.placeholder.com/80';
|
| 106 |
img.alt = ingredient.name;
|
| 107 |
const name = document.createElement('div');
|
| 108 |
-
name.textContent = ingredient.name
|
| 109 |
name.style.textAlign = 'center';
|
| 110 |
name.style.marginTop = '5px';
|
| 111 |
name.style.fontSize = '12px';
|
|
@@ -142,7 +144,7 @@ function displaySelectedIngredients() {
|
|
| 142 |
|
| 143 |
selectedIngredients.forEach(ingredient => {
|
| 144 |
const div = document.createElement('div');
|
| 145 |
-
div.textContent = ingredient.name
|
| 146 |
selectedArea.appendChild(div);
|
| 147 |
});
|
| 148 |
}
|
|
|
|
| 44 |
options = [
|
| 45 |
{ text: 'Vegetarian', class: 'green' },
|
| 46 |
{ text: 'Non-Vegetarian', class: 'red' },
|
| 47 |
+
{ text: 'Both', class: 'gray' }
|
| 48 |
];
|
| 49 |
} else if (lastMessage.includes('vegetarian') || lastMessage.includes('non-vegetarian') || lastMessage.includes('both')) {
|
| 50 |
+
botResponse = `Great choice! 🍽️ These are the available ingredients for ${lastMessage} (including any "Both" category):`;
|
| 51 |
+
fetchIngredients(lastMessage.toLowerCase());
|
| 52 |
+
return;
|
| 53 |
}
|
| 54 |
|
| 55 |
addMessage('bot', botResponse);
|
|
|
|
| 75 |
addMessage('bot', 'Great choice! These are available ingredients:');
|
| 76 |
displayIngredientsList(ingredients);
|
| 77 |
displaySelectedIngredients();
|
| 78 |
+
// Log ingredients to console for debugging
|
| 79 |
+
console.log(`Ingredients fetched for ${dietaryPreference}:`, ingredients);
|
| 80 |
}
|
| 81 |
})
|
| 82 |
.catch(error => {
|
|
|
|
| 107 |
img.src = ingredient.image_url || 'https://via.placeholder.com/80';
|
| 108 |
img.alt = ingredient.name;
|
| 109 |
const name = document.createElement('div');
|
| 110 |
+
name.textContent = `${ingredient.name} (Category: ${ingredient.category})`; // Show category for clarity
|
| 111 |
name.style.textAlign = 'center';
|
| 112 |
name.style.marginTop = '5px';
|
| 113 |
name.style.fontSize = '12px';
|
|
|
|
| 144 |
|
| 145 |
selectedIngredients.forEach(ingredient => {
|
| 146 |
const div = document.createElement('div');
|
| 147 |
+
div.textContent = `${ingredient.name} (Category: ${ingredient.category})`;
|
| 148 |
selectedArea.appendChild(div);
|
| 149 |
});
|
| 150 |
}
|