File size: 7,449 Bytes
cd2c91d
7547860
 
 
 
86b7bfb
e748187
1ea5871
 
86b7bfb
 
4539c80
 
1ea5871
 
4539c80
86b7bfb
4539c80
 
 
 
 
1ea5871
 
4539c80
 
1ea5871
86b7bfb
4539c80
 
 
7a88679
4539c80
 
 
7a88679
4539c80
 
 
86b7bfb
4539c80
 
 
 
 
 
 
 
86b7bfb
4539c80
 
7a88679
e8c85cc
b0082be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e8c85cc
b0082be
 
 
 
 
 
 
 
 
e8c85cc
 
 
b0082be
e8c85cc
 
e748187
7547860
8fdce7e
b0082be
4539c80
e8c85cc
b0082be
 
 
 
 
 
e8c85cc
b0082be
3e2a505
b0082be
3e2a505
 
 
 
 
 
 
7a88679
 
b0082be
 
 
 
 
e8c85cc
 
b0082be
 
 
ce5c734
b9a4953
b0082be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b9a4953
b0082be
 
 
 
 
 
 
b9a4953
b0082be
b9a4953
b0082be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b9a4953
b0082be
 
ce5c734
b0082be
7547860
b0082be
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Biryani Hub Menu</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f8f8f8;
            text-align: center;
            margin: 0;
            padding: 20px;
        }
        h1 {
            color: #ff5722;
        }
        .menu-container {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            margin-top: 20px;
        }
        .menu-item {
            background: white;
            padding: 15px;
            margin: 10px;
            border-radius: 8px;
            box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.1);
            width: 300px;
            text-align: left;
        }
        .menu-item h3 {
            margin: 0;
            color: #333;
        }
        .menu-item p {
            margin: 5px 0;
            color: #555;
        }
        .menu-item button {
            background-color: #ff5722;
            color: white;
            border: none;
            padding: 8px;
            cursor: pointer;
            width: 100%;
            border-radius: 5px;
        }
        .menu-item button:hover {
            background-color: #e64a19;
        }
        .cart-container {
            margin-top: 20px;
            padding: 15px;
            background-color: white;
            border: 1px solid #ddd;
            border-radius: 5px;
            width: 50%;
            margin-left: auto;
            margin-right: auto;
            display: none;
        }
        .cart-item {
            display: flex;
            justify-content: space-between;
            padding: 5px;
            border-bottom: 1px solid #ddd;
        }
        .cart-item:last-child {
            border-bottom: none;
        }
        .filter-buttons {
            margin: 15px;
        }
        .filter-buttons button {
            margin: 5px;
            padding: 10px;
            border: none;
            cursor: pointer;
            border-radius: 5px;
            background-color: #007bff;
            color: white;
        }
        .filter-buttons button:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>

    <h1>Restaurant Menu</h1>

    <!-- Filter Buttons -->
    <div class="filter-buttons">
        <button onclick="filterMenu('Veg')">Vegetarian</button>
        <button onclick="filterMenu('Non-Veg')">Non-Vegetarian</button>
    </div>

    <!-- Menu Display -->
    <div class="menu-container" id="menu-list">
        {% for item in menu %}
        <div class="menu-item" data-category="{{ item.category }}">
            <h3>{{ item.name }}</h3>
            <p><strong>Category:</strong> {{ item.category }}</p>
            <p><strong>Price:</strong> ${{ item.price }}</p>
            <p><strong>Ingredients:</strong> {{ item.ingredients }}</p>
            <button onclick="addToCart('{{ item.name }}', {{ item.price }})">Add to Cart</button>
        </div>
        {% endfor %}
    </div>

    <!-- Cart Section -->
    <div class="cart-container" id="cart-container">
        <h2>Your Cart</h2>
        <div id="cart-items"></div>
        <button onclick="checkout()">Checkout</button>
    </div>

    <!-- View Cart Button -->
    <button onclick="viewCart()">View Cart</button>

    <script>
        let cart = [];
        // βœ… Speech Synthesis - Welcome message
        function speak(text, callback) {
            const msg = new SpeechSynthesisUtterance(text);
            msg.onend = callback;
            window.speechSynthesis.speak(msg);
        }
        // βœ… Ask user Veg or Non-Veg
        function askMenuType() {
            speak("Welcome to Biryani Hub Menu. Would you like to see Vegetarian or Non-Vegetarian options?", function() {
                startListening();
            });
        }
        // βœ… Speech Recognition (User says Veg or Non-Veg)
        function startListening() {
            const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
            recognition.lang = "en-US";
            recognition.start();
            recognition.onresult = function(event) {
                const command = event.results[0][0].transcript.toLowerCase();
                if (command.includes("vegetarian") || command.includes("veg")) {
                    filterMenu("Veg");
                } else if (command.includes("non-vegetarian") || command.includes("non veg")) {
                    filterMenu("Non-Veg");
                } else {
                    speak("Sorry, I didn't understand. Please say Vegetarian or Non-Vegetarian.", function() {
                        startListening();
                    });
                }
            };
        }
        // βœ… Function to filter menu by category and speak items
        function filterMenu(type) {
            const allItems = document.querySelectorAll('.menu-item');
            let availableItems = [];
            allItems.forEach(item => {
                const category = item.dataset.category.toLowerCase();
                if (type === "Veg" && (category.includes("veg") || category.includes("paneer") || category.includes("channa"))) {
                    item.style.display = "block";
                    availableItems.push(item.querySelector('h3').innerText);
                } else if (type === "Non-Veg" && (category.includes("chicken") || category.includes("mutton") || category.includes("fish") || category.includes("prawn"))) {
                    item.style.display = "block";
                    availableItems.push(item.querySelector('h3').innerText);
                } else {
                    item.style.display = "none";
                }
            });
            speak("Here are the available items: " + availableItems.join(", "));
        }
        // βœ… Function to add items to cart
        function addToCart(name, price) {
            const existingItem = cart.find(item => item.name === name);
            if (existingItem) {
                existingItem.quantity += 1;
            } else {
                cart.push({ name, price, quantity: 1 });
            }
            speak(name + " added to cart!");
        }
        // βœ… Function to view cart
        function viewCart() {
            const cartContainer = document.getElementById("cart-container");
            const cartItemsContainer = document.getElementById("cart-items");
            cartItemsContainer.innerHTML = "";
            cart.forEach(cartItem => {
                const div = document.createElement("div");
                div.classList.add("cart-item");
                div.innerHTML = `<span>${cartItem.name} (x${cartItem.quantity}) - $${cartItem.price * cartItem.quantity}</span>`;
                cartItemsContainer.appendChild(div);
            });
            cartContainer.style.display = "block";
        }
        // βœ… Function to checkout
        function checkout() {
            if (cart.length > 0) {
                speak("Your order has been placed successfully!");
                cart = [];
                viewCart();
            } else {
                speak("Your cart is empty. Please add items before placing the order.");
            }
        }
        // βœ… Welcome Message on Page Load
        window.onload = askMenuType;
    </script>

</body>
</html>