lokesh341 commited on
Commit
d1dea61
·
verified ·
1 Parent(s): b28006b

Create search.html

Browse files
Files changed (1) hide show
  1. templates/search.html +234 -0
templates/search.html ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Search - Menu</title>
7
+ <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
8
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
9
+ <style>
10
+ /* Reuse styles from menu.html */
11
+ body {
12
+ font-family: Arial, sans-serif;
13
+ background-color: #fdf4e3;
14
+ margin: 0;
15
+ padding: 0;
16
+ display: flex;
17
+ flex-direction: column;
18
+ padding-bottom: 70px;
19
+ }
20
+ .fixed-top-bar {
21
+ position: relative;
22
+ top: 0;
23
+ left: 0;
24
+ width: 100%;
25
+ height: 54px;
26
+ background: linear-gradient(45deg, #FFA07A, #FFB347);
27
+ color: white;
28
+ padding: 15px;
29
+ display: flex;
30
+ justify-content: space-between;
31
+ align-items: center;
32
+ z-index: 1000;
33
+ }
34
+ .search-bar-container {
35
+ position: absolute;
36
+ left: 20px;
37
+ top: 50%;
38
+ transform: translateY(-50%);
39
+ display: flex;
40
+ align-items: center;
41
+ width: 300px;
42
+ max-width: 90%;
43
+ position: relative;
44
+ }
45
+ .search-bar-container input {
46
+ width: 100%;
47
+ padding: 8px 40px 8px 40px;
48
+ font-size: 16px;
49
+ border-radius: 25px;
50
+ border: none;
51
+ background-color: #fff;
52
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
53
+ outline: none;
54
+ }
55
+ .search-icon {
56
+ position: absolute;
57
+ left: 15px;
58
+ font-size: 18px;
59
+ color: #888;
60
+ }
61
+ .mic-icon {
62
+ position: absolute;
63
+ right: 15px;
64
+ font-size: 18px;
65
+ color: #888;
66
+ cursor: pointer;
67
+ }
68
+ .autocomplete-suggestions {
69
+ position: absolute;
70
+ top: 100%;
71
+ left: 0;
72
+ width: 100%;
73
+ max-height: 200px;
74
+ overflow-y: auto;
75
+ background-color: #fff;
76
+ border: 1px solid #ddd;
77
+ border-radius: 5px;
78
+ box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
79
+ z-index: 1000;
80
+ display: none;
81
+ }
82
+ .autocomplete-suggestions .suggestion-item {
83
+ padding: 8px 15px;
84
+ cursor: pointer;
85
+ font-size: 14px;
86
+ color: #333;
87
+ }
88
+ .autocomplete-suggestions .suggestion-item:hover {
89
+ background-color: #f1f1f1;
90
+ }
91
+ .container {
92
+ max-width: 900px;
93
+ margin-top: 20px;
94
+ }
95
+ .menu-card {
96
+ /* Copy relevant styles from menu.html */
97
+ max-width: 350px;
98
+ border-radius: 15px;
99
+ overflow: hidden;
100
+ background-color: #fff;
101
+ margin: auto;
102
+ display: flex;
103
+ flex-direction: column;
104
+ box-shadow: 0 4px 8px rgba(0,0,0,0.1);
105
+ }
106
+ /* Add other necessary styles from menu.html */
107
+ </style>
108
+ </head>
109
+ <body>
110
+ <div class="fixed-top-bar">
111
+ <div class="search-bar-container">
112
+ <input type="text" id="searchBar" class="form-control" placeholder="Search items or sections..." autocomplete="off">
113
+ <i class="bi bi-search search-icon"></i>
114
+ <i class="bi bi-mic mic-icon" id="micIcon"></i>
115
+ <div id="autocompleteSuggestions" class="autocomplete-suggestions"></div>
116
+ </div>
117
+ </div>
118
+
119
+ <div class="container">
120
+ <h2>Search Results</h2>
121
+ <div id="searchResults" class="row">
122
+ {% for item in all_items %}
123
+ <div class="col-md-6 mb-4 search-item" data-name="{{ item.Name | lower }}" data-section="{{ item.Section__c | lower }}">
124
+ <div class="card menu-card">
125
+ <video
126
+ class="card-img-top menu-video"
127
+ muted
128
+ loop
129
+ preload="auto"
130
+ data-src="{{ item.Video1__c }}"
131
+ poster="{{ item.Image1__c | default('/static/placeholder.jpg') }}"
132
+ width="350"
133
+ height="200"
134
+ onmouseover="this.play()"
135
+ onmouseout="this.pause(); this.currentTime = 0;">
136
+ <source src="{{ item.Video1__c }}" type="video/mp4">
137
+ </video>
138
+ <div class="card-body">
139
+ <h5 class="card-title">{{ item.Name }}</h5>
140
+ <p class="card-text price">${{ item.Price__c }}</p>
141
+ <button class="btn btn-primary"
142
+ data-bs-toggle="modal"
143
+ data-bs-target="#itemModal"
144
+ onclick="showItemDetails('{{ item.Name | e }}', '{{ item.Price__c }}', '{{ item.Image2__c | default(item.Image1__c) | default('/static/placeholder.jpg') }}', '{{ item.Description__c | e }}', '{{ item.IngredientsInfo__c | default('Not specified') | e }}', '{{ item.NutritionalInfo__c | default('Not available') | e }}', '{{ item.Allergens__c | default('None listed') | e }}', '{{ item.Section__c | e }}', 'All')">
145
+ ADD
146
+ </button>
147
+ </div>
148
+ </div>
149
+ </div>
150
+ {% endfor %}
151
+ </div>
152
+ </div>
153
+
154
+ <!-- Item Modal (copied from menu.html) -->
155
+ <div class="modal fade" id="itemModal" tabindex="-1" aria-labelledby="itemModalLabel" aria-hidden="true">
156
+ <!-- Same modal content as in menu.html -->
157
+ </div>
158
+
159
+ <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
160
+ <script>
161
+ const menuItems = [
162
+ {% for item in all_items %}
163
+ "{{ item.Name | e }}",
164
+ {% endfor %}
165
+ ];
166
+
167
+ function sanitizeInput(input) {
168
+ const div = document.createElement('div');
169
+ div.textContent = input;
170
+ return div.innerHTML;
171
+ }
172
+
173
+ document.addEventListener('DOMContentLoaded', function () {
174
+ const searchBar = document.getElementById('searchBar');
175
+ const suggestionsContainer = document.getElementById('autocompleteSuggestions');
176
+ const searchResults = document.getElementById('searchResults');
177
+
178
+ function filterSearch() {
179
+ const input = sanitizeInput(searchBar.value.trim().toLowerCase());
180
+ const items = document.querySelectorAll('.search-item');
181
+
182
+ items.forEach(item => {
183
+ const itemName = item.getAttribute('data-name');
184
+ const itemSection = item.getAttribute('data-section');
185
+ if (itemName.includes(input) || itemSection.includes(input)) {
186
+ item.style.display = 'block';
187
+ } else {
188
+ item.style.display = 'none';
189
+ }
190
+ });
191
+
192
+ if (!input) {
193
+ items.forEach(item => item.style.display = 'block');
194
+ }
195
+ }
196
+
197
+ searchBar.addEventListener('input', function () {
198
+ const input = sanitizeInput(this.value.trim().toLowerCase());
199
+ suggestionsContainer.innerHTML = '';
200
+ suggestionsContainer.style.display = 'none';
201
+
202
+ if (input) {
203
+ const filteredItems = menuItems.filter(item =>
204
+ item.toLowerCase().includes(input)
205
+ );
206
+ if (filteredItems.length > 0) {
207
+ filteredItems.forEach(item => {
208
+ const suggestionDiv = document.createElement('div');
209
+ suggestionDiv.classList.add('suggestion-item');
210
+ suggestionDiv.innerText = item;
211
+ suggestionDiv.addEventListener('click', function () {
212
+ searchBar.value = item;
213
+ suggestionsContainer.style.display = 'none';
214
+ filterSearch();
215
+ });
216
+ suggestionsContainer.appendChild(suggestionDiv);
217
+ });
218
+ suggestionsContainer.style.display = 'block';
219
+ }
220
+ }
221
+ filterSearch();
222
+ });
223
+
224
+ document.addEventListener('click', function (event) {
225
+ if (!searchBar.contains(event.target) && !suggestionsContainer.contains(event.target)) {
226
+ suggestionsContainer.style.display = 'none';
227
+ }
228
+ });
229
+
230
+ // Add your showItemDetails function and other necessary JavaScript from menu.html
231
+ });
232
+ </script>
233
+ </body>
234
+ </html>