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

Update templates/menu_page.html

Browse files
Files changed (1) hide show
  1. templates/menu_page.html +33 -21
templates/menu_page.html CHANGED
@@ -5,15 +5,12 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Menu - Biryani Hub</title>
7
  <style>
8
- /* General Body Styling */
9
  body {
10
  font-family: Arial, sans-serif;
11
  background-color: #f8f8f8;
12
  margin: 0;
13
  padding: 0;
14
  }
15
-
16
- /* Container for the menu */
17
  .menu-container {
18
  max-width: 1200px;
19
  margin: 0 auto;
@@ -23,14 +20,12 @@
23
  border-radius: 8px;
24
  margin-top: 50px;
25
  }
26
-
27
  h1 {
28
  text-align: center;
29
  font-size: 2.5rem;
30
  color: #333;
31
  margin-bottom: 30px;
32
  }
33
-
34
  .menu-item {
35
  border-bottom: 1px solid #eee;
36
  padding: 15px 0;
@@ -38,7 +33,6 @@
38
  justify-content: space-between;
39
  align-items: center;
40
  }
41
-
42
  .order-btn {
43
  padding: 10px 20px;
44
  background-color: #4CAF50;
@@ -47,11 +41,9 @@
47
  border-radius: 5px;
48
  cursor: pointer;
49
  }
50
-
51
  .order-btn:hover {
52
  background-color: #45a049;
53
  }
54
-
55
  #listen-btn {
56
  padding: 10px 20px;
57
  background-color: #4CAF50;
@@ -63,7 +55,6 @@
63
  display: block;
64
  margin: 30px auto;
65
  }
66
-
67
  #listen-btn:hover {
68
  background-color: #45a049;
69
  }
@@ -82,17 +73,19 @@
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;
@@ -111,10 +104,15 @@
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,14 +121,28 @@
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
 
 
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Menu - Biryani Hub</title>
7
  <style>
 
8
  body {
9
  font-family: Arial, sans-serif;
10
  background-color: #f8f8f8;
11
  margin: 0;
12
  padding: 0;
13
  }
 
 
14
  .menu-container {
15
  max-width: 1200px;
16
  margin: 0 auto;
 
20
  border-radius: 8px;
21
  margin-top: 50px;
22
  }
 
23
  h1 {
24
  text-align: center;
25
  font-size: 2.5rem;
26
  color: #333;
27
  margin-bottom: 30px;
28
  }
 
29
  .menu-item {
30
  border-bottom: 1px solid #eee;
31
  padding: 15px 0;
 
33
  justify-content: space-between;
34
  align-items: center;
35
  }
 
36
  .order-btn {
37
  padding: 10px 20px;
38
  background-color: #4CAF50;
 
41
  border-radius: 5px;
42
  cursor: pointer;
43
  }
 
44
  .order-btn:hover {
45
  background-color: #45a049;
46
  }
 
47
  #listen-btn {
48
  padding: 10px 20px;
49
  background-color: #4CAF50;
 
55
  display: block;
56
  margin: 30px auto;
57
  }
 
58
  #listen-btn:hover {
59
  background-color: #45a049;
60
  }
 
73
  <p><strong>Category:</strong> {{ item.category }}</p>
74
  <p class="price">Price: ${{ item.price }}</p>
75
  </div>
76
+ <button class="order-btn" onclick="addToCart('{{ item.name }}', '{{ item.price }}')">Order</button>
77
  </div>
78
  {% endfor %}
79
 
 
80
  <button id="listen-btn">Say "Order" to order an item</button>
81
  </div>
82
 
83
  <script>
84
  const listenButton = document.getElementById("listen-btn");
85
  const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
86
+ let cart = [];
87
+ let currentCategory = null;
88
+ let currentItem = null;
89
 
90
  recognition.lang = "en-US";
91
  recognition.interimResults = false;
 
104
  const command = event.results[0][0].transcript.toLowerCase();
105
  console.log("User said:", command);
106
 
107
+ if (command.includes("appetizer") || command.includes("main course")) {
108
+ currentCategory = command.includes("appetizer") ? "Appetizer" : "Main Course";
109
+ speak(`You selected ${currentCategory}. Here are the items in this category.`);
110
+ document.location.href = `/category/${currentCategory}`;
111
+ }
112
+
113
  if (command.includes("order")) {
114
+ speak("Which item would you like to order?");
115
+ // After identifying the item, ask for quantity and proceed with adding to cart
116
  }
117
  };
118
 
 
121
  speak("Sorry, I couldn't understand that. Please try again.");
122
  };
123
 
124
+ function addToCart(itemName, itemPrice) {
125
+ currentItem = itemName;
126
+ speak(`How many quantities of ${itemName} would you like?`);
127
+ }
128
+
129
+ function updateCart(itemName, quantity) {
130
+ cart.push({ name: itemName, quantity: quantity });
131
+ speak(`Added ${quantity} of ${itemName} to your cart.`);
132
+ }
133
+
134
+ function removeItem(itemName) {
135
+ cart = cart.filter(item => item.name !== itemName);
136
+ speak(`Removed ${itemName} from your cart.`);
137
+ }
138
+
139
+ // Add cart summary voice feedback after each update
140
+ function cartSummary() {
141
+ let summary = "Your cart contains: ";
142
+ cart.forEach(item => {
143
+ summary += `${item.quantity} x ${item.name}, `;
144
  });
145
+ speak(summary);
146
  }
147
  </script>
148