geethareddy commited on
Commit
4d0a5a5
·
verified ·
1 Parent(s): 7939980

Update templates/menu_page.html

Browse files
Files changed (1) hide show
  1. templates/menu_page.html +24 -61
templates/menu_page.html CHANGED
@@ -74,44 +74,36 @@
74
  <div class="menu-container">
75
  <h1>Welcome to the Menu</h1>
76
 
77
- <div id="category-selection">
78
- <h2>Please say a category: "Appetizer" or "Main Course"</h2>
79
- </div>
80
-
81
- <div id="menu-items-container" style="display:none;">
82
- <h2>Menu Items</h2>
83
- <div id="menu-items"></div>
 
 
84
  </div>
 
85
 
86
  <!-- Button for triggering voice recognition -->
87
- <button id="listen-btn">Say "Appetizer" or "Main Course"</button>
88
  </div>
89
 
90
  <script>
91
  const listenButton = document.getElementById("listen-btn");
92
  const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
 
93
  recognition.lang = "en-US";
94
  recognition.interimResults = false;
95
 
96
- // Sample menu items data (you can dynamically fetch this from a backend if needed)
97
- const menuData = {
98
- "Appetizer": [
99
- { "name": "Spring Rolls", "price": "$5.99", "ingredients": "Rice Paper, Shrimp, Lettuce" },
100
- { "name": "Chicken Wings", "price": "$7.99", "ingredients": "Chicken, Spices, Garlic" },
101
- ],
102
- "Main Course": [
103
- { "name": "Biryani", "price": "$12.99", "ingredients": "Rice, Chicken, Spices" },
104
- { "name": "Paneer Butter Masala", "price": "$10.99", "ingredients": "Paneer, Butter, Cream" },
105
- ]
106
- };
107
-
108
  function speak(text) {
109
  const msg = new SpeechSynthesisUtterance(text);
110
  window.speechSynthesis.speak(msg);
111
  }
112
 
113
  listenButton.addEventListener("click", () => {
114
- speak("Please say 'Appetizer' or 'Main Course'.");
115
  recognition.start();
116
  });
117
 
@@ -119,12 +111,10 @@
119
  const command = event.results[0][0].transcript.toLowerCase();
120
  console.log("User said:", command);
121
 
122
- if (command.includes("appetizer") || command.includes("main course")) {
123
- // Handle recognized category
124
- handleCategorySelection(command);
125
- } else {
126
- speak("Sorry, I didn't understand. Please say 'Appetizer' or 'Main Course'.");
127
- recognition.start(); // Restart recognition if invalid category
128
  }
129
  };
130
 
@@ -133,42 +123,15 @@
133
  speak("Sorry, I couldn't understand that. Please try again.");
134
  };
135
 
136
- function handleCategorySelection(category) {
137
- const categoryName = category.includes("appetizer") ? "Appetizer" : "Main Course";
138
- const items = menuData[categoryName];
139
-
140
- document.getElementById("category-selection").style.display = "none"; // Hide category prompt
141
- document.getElementById("menu-items-container").style.display = "block"; // Show menu items
142
-
143
- // Display menu items for the selected category
144
- const menuItemsContainer = document.getElementById("menu-items");
145
- menuItemsContainer.innerHTML = ""; // Clear existing items
146
- items.forEach(item => {
147
- const itemElement = document.createElement("div");
148
- itemElement.classList.add("menu-item");
149
- itemElement.innerHTML = `
150
- <div class="details">
151
- <h3>${item.name}</h3>
152
- <p><strong>Ingredients:</strong> ${item.ingredients}</p>
153
- <p class="price">Price: ${item.price}</p>
154
- </div>
155
- <button class="order-btn">Order</button>
156
- `;
157
- menuItemsContainer.appendChild(itemElement);
158
- });
159
-
160
- // Read out the list of items
161
- let itemsText = `The following items are available in the ${categoryName}: `;
162
- items.forEach(item => {
163
- itemsText += item.name + ", ";
164
  });
165
- speak(itemsText); // Speak the items
166
  }
167
-
168
- window.onload = function() {
169
- // Initial page load will prompt for category selection
170
- speak("Welcome to the Menu. Please say 'Appetizer' or 'Main Course'.");
171
- };
172
  </script>
173
 
174
  </body>
 
74
  <div class="menu-container">
75
  <h1>Welcome to the Menu</h1>
76
 
77
+ {% for item in menu_items %}
78
+ <div class="menu-item">
79
+ <div class="details">
80
+ <h3>{{ item.name }}</h3>
81
+ <p><strong>Ingredients:</strong> {{ item.ingredients }}</p>
82
+ <p><strong>Category:</strong> {{ item.category }}</p>
83
+ <p class="price">Price: ${{ item.price }}</p>
84
+ </div>
85
+ <button class="order-btn">Order</button>
86
  </div>
87
+ {% endfor %}
88
 
89
  <!-- Button for triggering voice recognition -->
90
+ <button id="listen-btn">Say "Order" to order an item</button>
91
  </div>
92
 
93
  <script>
94
  const listenButton = document.getElementById("listen-btn");
95
  const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
96
+
97
  recognition.lang = "en-US";
98
  recognition.interimResults = false;
99
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  function speak(text) {
101
  const msg = new SpeechSynthesisUtterance(text);
102
  window.speechSynthesis.speak(msg);
103
  }
104
 
105
  listenButton.addEventListener("click", () => {
106
+ speak("Please say the item you want to order.");
107
  recognition.start();
108
  });
109
 
 
111
  const command = event.results[0][0].transcript.toLowerCase();
112
  console.log("User said:", command);
113
 
114
+ // Add logic to recognize specific items or trigger actions based on the command
115
+ if (command.includes("order")) {
116
+ // For example, navigate or process an order (customize as needed)
117
+ speak("Your order has been placed.");
 
 
118
  }
119
  };
120
 
 
123
  speak("Sorry, I couldn't understand that. Please try again.");
124
  };
125
 
126
+ // Voice reading of menu items on page load
127
+ window.onload = function() {
128
+ const menuItems = document.querySelectorAll('.menu-item h3');
129
+ let itemsText = "The menu includes: ";
130
+ menuItems.forEach(item => {
131
+ itemsText += item.textContent + ", ";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  });
133
+ speak(itemsText); // Speak all the item names
134
  }
 
 
 
 
 
135
  </script>
136
 
137
  </body>