Spaces:
Runtime error
Runtime error
File size: 9,071 Bytes
d1dea61 34e95e1 d1dea61 34e95e1 0f056d7 34e95e1 5842196 34e95e1 d1dea61 34e95e1 d1dea61 34e95e1 d1dea61 34e95e1 d1dea61 34e95e1 d1dea61 34e95e1 db48a04 d1dea61 34e95e1 db48a04 34e95e1 13a827e 34e95e1 13a827e 34e95e1 13a827e cf7f91b 34e95e1 13a827e d1dea61 34e95e1 5842196 34e95e1 d1dea61 34e95e1 d1dea61 34e95e1 d1dea61 a1eea31 d1dea61 34e95e1 d1dea61 34e95e1 a1eea31 34e95e1 a1eea31 34e95e1 a1eea31 34e95e1 a1eea31 34e95e1 a1eea31 34e95e1 d1dea61 cf7f91b 34e95e1 d1dea61 |
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 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Search - Menu</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
<style>
body {
font-family: Arial, sans-serif;
background-color: #fdf4e3;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
padding-bottom: 70px;
}
.fixed-top-bar {
position: relative;
top: 0;
left: 0;
width: 100%;
height: 54px;
background: linear-gradient(45deg, #FFA07A, #FFB347);
color: white;
padding: 15px;
display: flex;
align-items: center;
z-index: 1000;
}
.orange-label {
background-color: #FFA500;
padding: 5px 10px;
border-radius: 5px;
display: flex;
align-items: center;
position: absolute;
left: 10px;
top: 50%;
transform: translateY(-50%);
}
.back-button {
background-color: black;
color: white;
border: none;
border-radius: 50%;
width: 25px;
height: 25px;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
cursor: pointer;
margin-right: 10px;
}
.search-bar-container {
position: fixed;
bottom: 10px;
left: 50%;
transform: translateX(-50%);
display: flex;
align-items: center;
width: 300px;
max-width: 90%;
z-index: 1000;
}
.search-bar-container input {
width: 100%;
padding: 8px 40px 8px 40px;
font-size: 16px;
border-radius: 25px;
border: none;
background-color: #fff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
outline: none;
}
.search-icon {
position: absolute;
left: 15px;
font-size: 18px;
color: #888;
}
.mic-icon {
position: absolute;
right: 15px;
font-size: 18px;
color: #888;
cursor: pointer;
}
.autocomplete-suggestions {
position: absolute;
bottom: 100%;
left: 0;
width: 100%;
max-height: 200px;
overflow-y: auto;
background-color: #fff;
border: 1px solid #ddd;
border-radius: 5px;
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
z-index: 1000;
display: none;
}
.autocomplete-suggestions .suggestion-item {
padding: 8px 15px;
cursor: pointer;
font-size: 14px;
color: #333;
}
.autocomplete-suggestions .suggestion-item:hover {
background-color: #f1f1f1;
}
.container {
max-width: 900px;
margin-top: 20px;
margin-bottom: 70px;
}
.search-item {
cursor: pointer;
}
.menu-card {
max-width: 350px;
border-radius: 15px;
overflow: hidden;
background-color: #fff;
margin: auto;
display: flex;
flex-direction: column;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
transition: transform 0.2s;
}
.menu-card:hover {
transform: scale(1.05);
}
.menu-video {
height: 200px;
width: 100%;
object-fit: cover;
border-radius: 15px 15px 0 0;
}
.card-body {
padding: 10px;
text-align: center;
}
.card-title {
font-size: 1.2rem;
font-weight: 600;
margin: 0;
color: #333333;
}
</style>
</head>
<body>
<div class="fixed-top-bar">
<div class="orange-label">
<button class="back-button" onclick="window.location.href='/menu'"><</button>
<span>Search</span>
</div>
</div>
<div class="container">
<h2>Search Results</h2>
<div id="searchResults" class="row">
{% for item in all_items %}
<div class="col-md-6 mb-4 search-item" data-name="{{ item.Name | lower }}" data-section="{{ item.Section__c | lower }}"
onclick="window.location.href='/menu?highlight={{ item.Name | urlencode }}'">
<div class="card menu-card">
<img src="{{ item.Image2__c | default(item.Image1__c) | default('/static/placeholder.jpg') }}"
class="card-img-top menu-video" alt="{{ item.Name }}" style="height: 200px; object-fit: cover;">
<div class="card-body">
<h5 class="card-title">{{ item.Name }}</h5>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
<div class="search-bar-container">
<input type="text" id="searchBar" class="form-control" placeholder="Search items or sections..." autocomplete="off">
<i class="bi bi-search search-icon"></i>
<i class="bi bi-mic mic-icon" id="micIcon"></i>
<div id="autocompleteSuggestions" class="autocomplete-suggestions"></div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
<script>
const menuItems = [
{% for item in all_items %}
"{{ item.Name | e }}",
{% endfor %}
];
function sanitizeInput(input) {
const div = document.createElement('div');
div.textContent = input;
return div.innerHTML;
}
document.addEventListener('DOMContentLoaded', function () {
const searchBar = document.getElementById('searchBar');
const suggestionsContainer = document.getElementById('autocompleteSuggestions');
const searchResults = document.getElementById('searchResults');
function filterSearch() {
const input = sanitizeInput(searchBar.value.trim().toLowerCase());
const items = document.querySelectorAll('.search-item');
items.forEach(item => {
const itemName = item.getAttribute('data-name');
const itemSection = item.getAttribute('data-section');
if (itemName.includes(input) || itemSection.includes(input)) {
item.style.display = 'block';
} else {
item.style.display = 'none';
}
});
if (!input) {
items.forEach(item => item.style.display = 'block');
}
}
searchBar.addEventListener('input', function () {
const input = sanitizeInput(this.value.trim().toLowerCase());
suggestionsContainer.innerHTML = '';
suggestionsContainer.style.display = 'none';
if (input) {
const filteredItems = menuItems.filter(item =>
item.toLowerCase().includes(input)
);
if (filteredItems.length > 0) {
filteredItems.forEach(item => {
const suggestionDiv = document.createElement('div');
suggestionDiv.classList.add('suggestion-item');
suggestionDiv.innerText = item;
suggestionDiv.addEventListener('click', function () {
searchBar.value = item;
suggestionsContainer.style.display = 'none';
filterSearch();
});
suggestionsContainer.appendChild(suggestionDiv);
});
suggestionsContainer.style.display = 'block';
}
}
filterSearch();
});
document.addEventListener('click', function (event) {
if (!searchBar.contains(event.target) && !suggestionsContainer.contains(event.target)) {
suggestionsContainer.style.display = 'none';
}
});
});
</script>
</body>
</html> |