-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
228 lines (213 loc) · 7 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<!-- Bootstrap CSS -->
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn"
crossorigin="anonymous"
/>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css"
/>
<title>kitchen Chefs</title>
<style>
@import url("https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css");
body {
background-color: #f0f0f0;
}
.menu-header div {
cursor: pointer;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container">
<a class="navbar-brand" href="index.html">Chefs Kitchen</a>
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="/">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/featured">Featured</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input
class="form-control mr-sm-2"
type="search"
id="searchInput"
placeholder="Search"
aria-label="Search"
/>
<button class="btn btn-outline-success my-2 my-sm-0" type="buttn">
Search
</button>
</form>
</div>
</div>
</nav>
<div class="container mt-2 border-bottom">
<div class="row menu-header">
<div onclick="search('egg')" class="col-4 col-2 col-md-2 text-center">
<i class="bi bi-egg-fried"></i>
<p>Eggs</p>
</div>
<div onclick="search('salad')" class="col-4 col-2 col-md-2 text-center">
<i class="bi bi-apple"></i>
<p>Fruits / Salad</p>
</div>
<div onclick="search('pizza')" class="col-4 col-2 col-md-2 text-center">
<img src="images/pizza.png" width="24px" />
<p>Pizza</p>
</div>
<div onclick="search('burger')" class="col-4 col-2 col-md-2 text-center">
<img src="images/burguer.jpg" width="24px" />
<p>Burguer</p>
</div>
<div onclick="search('Japanese')" class="col-4 col-md-2 text-center">
<img src="images/japa.png" width="24px" />
<p>Japanese</p>
</div>
<div onclick="search('Italian')" class="col-4 col-md-2 text-center">
<img src="images/pasta.png" width="24px" />
<p>Italian</p>
</div>
</div>
</div>
<div class="container">
<div class="row mt-5 results"></div>
</div>
<script
src="https://code.jquery.com/jquery-3.6.0.min.js"
crossorigin="anonymous"
></script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-fQybjgWLrvvRgtW6bFlB7jaZrFsaBXjsOMm/tB9LTS58ONXgqbR9W8oWht/amnpF"
crossorigin="anonymous"
></script>
<script>
function openModal(ob) {
let data = localStorage.getItem("data");
data = JSON.parse(data)[ob];
console.log(data[ob]);
let menu = "";
for (let z = 0; z < data.menu.length; z++) {
const mn = data.menu[z];
menu += mn + ", ";
}
$("#modalTitle, #modalCaption").text(data.name);
$("#modalFigure").attr("src", data.imageURL);
$("#modalPrice").text("$" + data.price);
$("#modalDescription").text(data.description);
$("#modalMenu").html("Menu: <i>" + menu.slice(0, -2) + "");
$("#exampleModal").modal("show");
}
function search(str) {
$(".results").empty();
let postData = {
str: str,
};
$.post("/php-test/data.php", postData, function (data) {
// console.log(data);
localStorage.setItem("data", data);
let dados = JSON.parse(data);
if (dados.length > 0) {
let grid = "";
for (let i = 0; i < dados.length; i++) {
const ob = dados[i];
let menu = "";
for (let z = 0; z < ob.menu.length; z++) {
const mn = ob.menu[z];
menu += mn + ", ";
}
grid += '<div class="col-md-3 mb-3">';
grid += '<div class="card">';
grid +=
'<a href="javascript: void(0)" onclick="openModal(' + i + ')">';
grid +=
"<img class='w-100 rounded-lg' src='" + ob.imageURL + "'/>";
grid += "</a>";
grid += '<div class="p-2">';
grid += "<h5>" + ob.name + "</h5>";
grid += "<p><b>$" + ob.price + "</b></p>";
grid += "Menu: <i>" + menu.slice(0, -2) + "</i>";
grid += "</div>";
grid += "</div>";
grid += "</div>";
}
$(".results").append(grid);
} else {
let noResults =
'<div class="col-md-12 bg-light text-center border p-3"><h3>No results found: ' +
str +
"</h3></div>";
$(".results").append(noResults);
}
});
}
$(document).ready(function () {
$("form").submit(function (e) {
console.log($("#searchInput").val());
e.preventDefault();
search($("#searchInput").val());
});
search("");
});
</script>
<div
class="modal fade"
id="exampleModal"
tabindex="-1"
aria-labelledby="exampleModalLabel"
aria-hidden="true"
>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div>
<img src="" class="w-100" id="modalFigure" />
</div>
<h4 id="modalCaption" class="mt-2"></h4>
<h5 id="modalPrice"></h5>
<div id="modalMenu"></div>
<hr />
<div id="modalDescription"></div>
</div>
</div>
</div>
</div>
</body>
</html>