geethareddy commited on
Commit
611193f
Β·
verified Β·
1 Parent(s): ca494e8

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +37 -34
static/script.js CHANGED
@@ -1,5 +1,5 @@
1
  let conversation = [
2
- { role: 'bot', message: 'Hi there! I\'m Chef Bot! May I know your name?' }
3
  ];
4
 
5
  function addMessage(role, message) {
@@ -41,41 +41,44 @@ function handleResponse(userInput) {
41
  let botResponse = '';
42
  let options = [];
43
 
44
- if (conversation.length === 2) { // After name input
45
- botResponse = `Nice to meet you, ${userInput}! 😊 Let's create your perfect meal! What type of food would you prefer?`;
46
  options = [
47
- { text: 'Vegetarian', class: 'green' },
48
- { text: 'Non-Vegetarian', class: 'red' }
49
  ];
50
  } else if (lastMessage.includes('vegetarian')) {
51
- botResponse = 'Great choice! 🍽️ We have some amazing vegetarian options! What\'s your dietary preference?';
52
  options = [
53
- { text: 'Vegan', class: '' },
54
- { text: 'Gluten-Free', class: '' },
55
- { text: 'Vegetarian', class: '' },
56
- { text: 'Low Carb', class: '' },
57
- { text: 'Dairy-Free', class: '' },
58
- { text: 'Keto', class: '' },
59
- { text: 'Halal', class: '' }
60
  ];
61
  } else if (lastMessage.includes('non-vegetarian')) {
62
- botResponse = 'Great choice! 🍽️ We have some amazing non-vegetarian options! What\'s your dietary preference?';
63
  options = [
64
- { text: 'Low Carb', class: '' },
65
- { text: 'Dairy-Free', class: '' },
66
- { text: 'Keto', class: '' },
67
- { text: 'Halal', class: '' }
68
- ];
69
- } else if (lastMessage.includes('low carb') || lastMessage.includes('dairy-free') || lastMessage.includes('keto') || lastMessage.includes('halal') || lastMessage.includes('gluten-free') || lastMessage.includes('vegan')) {
70
- botResponse = 'Wonderful choice! 😊 Let\'s pick your favorite ingredients:';
71
- options = [
72
- { text: 'Potatoes', class: '' },
73
- { text: 'Tomatoes', class: '' },
74
- { text: 'Spinach', class: '' },
75
- { text: 'Cauliflower', class: '' },
76
- { text: 'Paneer', class: '' },
77
- { text: 'Tofu', class: '' }
78
  ];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
80
 
81
  addMessage('bot', botResponse);
@@ -92,14 +95,14 @@ function displayOptions(options) {
92
  }
93
  options.forEach(opt => {
94
  const button = document.createElement('button');
95
- button.textContent = opt.text;
96
- button.className = `option-button ${opt.class}`;
97
  button.onclick = () => {
98
- addMessage('user', opt.text);
99
- conversation.push({ role: 'user', message: opt.text });
100
  chatMessages.innerHTML = ''; // Clear previous messages
101
  conversation.forEach(msg => addMessage(msg.role, msg.message));
102
- setTimeout(() => handleResponse(opt.text), 500);
103
  };
104
  chatMessages.appendChild(button);
105
  });
@@ -124,4 +127,4 @@ document.getElementById('userInput').addEventListener('keypress', function(e) {
124
  });
125
 
126
  // Initial load check
127
- console.log('Script loaded successfully');
 
1
  let conversation = [
2
+ { role: 'bot', message: 'Hello! πŸ‘‹ Welcome to Chef Bot! 😊 I can help you create a perfect meal. First, what type of food would you prefer today?' }
3
  ];
4
 
5
  function addMessage(role, message) {
 
41
  let botResponse = '';
42
  let options = [];
43
 
44
+ if (conversation.length === 2) { // After name input or initial greeting
45
+ botResponse = `Nice to meet you! πŸ˜„ What type of meal are you in the mood for? Please choose an option below:`;
46
  options = [
47
+ { text: 'Vegetarian πŸ†', class: 'green' },
48
+ { text: 'Non-Vegetarian πŸ—', class: 'red' }
49
  ];
50
  } else if (lastMessage.includes('vegetarian')) {
51
+ botResponse = 'Great choice! 🍽️ Here are some tasty vegetarian dishes:';
52
  options = [
53
+ { text: 'Vegetable Biryani', class: '' },
54
+ { text: 'Paneer Butter Masala', class: '' },
55
+ { text: 'Palak Paneer', class: '' }
 
 
 
 
56
  ];
57
  } else if (lastMessage.includes('non-vegetarian')) {
58
+ botResponse = 'Yum! Here are some delicious non-vegetarian dishes:';
59
  options = [
60
+ { text: 'Chicken Curry', class: '' },
61
+ { text: 'Mutton Korma', class: '' },
62
+ { text: 'Fish Tikka', class: '' }
 
 
 
 
 
 
 
 
 
 
 
63
  ];
64
+ } else if (['vegetable biryani', 'paneer butter masala', 'palak paneer'].includes(lastMessage)) {
65
+ botResponse = `Great choice! Here are the ingredients for ${lastMessage}:`;
66
+ if (lastMessage === 'Vegetable Biryani') {
67
+ options = ['Rice', 'Carrots', 'Potatoes', 'Green Beans', 'Onions', 'Spices'];
68
+ } else if (lastMessage === 'Paneer Butter Masala') {
69
+ options = ['Paneer', 'Butter', 'Tomatoes', 'Onions', 'Spices', 'Cream'];
70
+ } else if (lastMessage === 'Palak Paneer') {
71
+ options = ['Spinach', 'Paneer', 'Onions', 'Garlic', 'Spices'];
72
+ }
73
+ } else if (['chicken curry', 'mutton korma', 'fish tikka'].includes(lastMessage)) {
74
+ botResponse = `Yum! Here are the ingredients for ${lastMessage}:`;
75
+ if (lastMessage === 'Chicken Curry') {
76
+ options = ['Chicken', 'Tomatoes', 'Onions', 'Garlic', 'Ginger', 'Spices'];
77
+ } else if (lastMessage === 'Mutton Korma') {
78
+ options = ['Mutton', 'Onions', 'Tomatoes', 'Yogurt', 'Spices'];
79
+ } else if (lastMessage === 'Fish Tikka') {
80
+ options = ['Fish', 'Yogurt', 'Spices', 'Lemon', 'Onions'];
81
+ }
82
  }
83
 
84
  addMessage('bot', botResponse);
 
95
  }
96
  options.forEach(opt => {
97
  const button = document.createElement('button');
98
+ button.textContent = opt;
99
+ button.className = 'option-button';
100
  button.onclick = () => {
101
+ addMessage('user', opt);
102
+ conversation.push({ role: 'user', message: opt });
103
  chatMessages.innerHTML = ''; // Clear previous messages
104
  conversation.forEach(msg => addMessage(msg.role, msg.message));
105
+ setTimeout(() => handleResponse(opt), 500);
106
  };
107
  chatMessages.appendChild(button);
108
  });
 
127
  });
128
 
129
  // Initial load check
130
+ console.log('Script loaded successfully');