-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
322 lines (250 loc) · 11.2 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
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
<!DOCTYPE html>
<html>
<head>
<title> Endagered Foods </title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Karma">
<style>
body,
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: "Karma", sans-serif
}
.w3-bar-block .w3-bar-item {
padding: 20px
}
</style>
<div>
<head>
<style>
/* Header/Logo Title */
.header {
padding: 250px;
text-align: center;
color: black;
font-size: 100px;
background-image: url(https://static.onecms.io/wp-content/uploads/sites/37/2015/06/16012245/fruits-vegetables-legumes-blue-background-8a6d17df.jpg);
}
/* Page Content */
.content {
padding: 20px;
}
</style>
</head>
<body>
<div class="header">
<h1 style="font-size:5pc; font-weight: 800;"> Endangered Foods</h1>
</div>
<body>
<!-- Sidebar (hidden by default) -->
<nav class="w3-sidebar w3-bar-block w3-card w3-top w3-xlarge w3-animate-left"
style="display:none;z-index:2;width:20%;min-width:100px" id="mySidebar">
<a href="javascript:void(0)" onclick="w3_close()" class="w3-bar-item w3-button">Close Menu</a>
<a href="#food" onclick="w3_close()" class="w3-bar-item w3-button">Current Foods</a>
<a href="#about" onclick="w3_close()" class="w3-bar-item w3-button">Recipes</a>
</nav>
<!-- Top menu -->
<div class="w3-top">
<div class="w3-white w3-xlarge" style="max-width:1200px;margin:auto;opacity: 0.5;">
<div class="w3-button w3-padding-16 w3-left" onclick="w3_open()">☰</div>
<div class="w3-center w3-padding-16"></div>
</div>
</div>
<!-- !PAGE CONTENT! -->
<div class="w3-main w3-content w3-padding" style="max-width:1200px;margin-top:100px">
<!-- Almost Expired Food -->
<hr id="foods">
<style>
.btn {
border: none;
background-color: inherit;
padding: 14px 28px;
font-size: 40px;
cursor: pointer;
display: inline-block;
}
/* Green */
.success {
color: green;
}
.success:hover {
background-color: #4CAF50;
color: white;
}
/* Red */
.danger {
color: red;
}
.danger:hover {
background: #f44336;
color: white;
}
</style>
</head>
<body>
<h2>Select the Category</h2>
<p style="font-size: medium;"> Press the green button, to see the foods that may be almost
expired.<br></br> Press the red button to see the foods that have expired </p>
<button class="btn success" , onclick="get_soon()">Warning: Might be expired soon</button>
<button class="btn danger" , onclick="get_expired()">Danger: Expired </button>
</body>
<!-- Recipes -->
<hr id="about">
<div>
<style>
body {
text-align: center;
}
#main-pane {
padding: 5px;
}
.food-info {
width: 150px;
height: 250px;
margin: 8px;
}
.btn-food {
width: 150 px;
height: 100%;
}
#placeholder {
display: flex;
width: 80vw;
}
</style>
<h1> Recipes </h1>
<div class="w3-row-padding w3-padding-16 w3-center" id="food">
<div class="w3-quarter">
<style>
* {
box-sizing: border-box;
}
.row {
display: flex;
}
/* Create two equal columns that sits next to each other */
.column {
flex: 50%;
padding: 10px;
height: 300px;
/* Should be removed. Only for demonstration */
}
.wrap-highlight {
background-color: tomato;
}
</style>
</head>
<script id="expired-template" type="text/x-handlebars-template">
{{#each (expired data)}}
<div class="food-info" style="width:200px">
<button class="btn-food" id="food-{{this.name}}" onclick="toggle_button('{{this.name}}')">
<img src={{this.pic}} alt={{this.name}} style="width:100%"/>
<p>{{this.name}} : ({{this.quantity}})</p>
</button>
</div>
{{/each}}
</script>
<script id="soon-template" type="text/x-handlebars-template">
{{#each (soon data)}}
<div class="food-info" style="width:200px">
<button class="btn-food" id="food-{{this.name}}" onclick="toggle_button('{{this.name}}')">
<img src={{this.pic}} alt={{this.name}} style="width:100%"/>
<p>{{this.name}} : ({{this.quantity}})</p>
<p>{{this.calories}} cals</p>
</button>
</div>
{{/each}}
</script>
<div class="content-pane" id="main-pane">
</div>
</div>
</div>
<!-- End page content -->
</div>
<script>
// Script to open and close sidebar
function w3_open() {
document.getElementById("mySidebar").style.display = "block";
}
function w3_close() {
document.getElementById("mySidebar").style.display = "none";
}
function get_soon() {
taken = [];
for (i = 0; i < data.length; i++) {
taken.push(false);
}
/*document.getElementById("main-pane").innerHTML =
"<div class=\"row\">" +
"<div class=\"column\" style=\"background-color:white;\">" +
"<p><img src=\"Milk.png\" alt=\"Milk\" style=\"width:100%;\"></p>" +
"</div>" +
"<div class=\"column\" style=\"background-color:white; \">" +
"<h2>Instruction</h2>" +
"<p>List the instructions</p>" +
"</div>" +
"</div>";*/
document.getElementById("main-pane").innerHTML = `<div id=\"placeholder\" >TEST</div>` +
'<button id=\'recipes\' onclick=\'get_recipe()\'>Get Recipes</button>';
replaceHTMLSoonTemplate();
}
function get_expired() {
taken = [];
for (i = 0; i < data.length; i++) {
taken.push(false);
}
/*document.getElementById("main-pane").innerHTML =
"<script id=\"expired-template\" type=\"text/x-handlebars-template\">" +
"<div class=\"food-info\" id=\"food-{{this.name}}\">" +
"<button onclick=\"toggle_button(\"food-{{this.name}}\")\">" +
"<img src={{this.pic}} alt={{this.name}}/>" +
"<p>{{this.name}} : ({{this.quantity}})</p>" +
"</div>" +
"{{/each}}" +
"<\/script>";*/
document.getElementById("main-pane").innerHTML = `<div id=\"placeholder\" >TEST</div>`;
replaceHTMLProductTemplate();
}
function toggle_button(str) {
document.getElementById("food-" + str).classList.toggle("wrap-highlight");
for (i = 0; i < data.length; i++) {
if (data[i].name == str) {
file = data[i];
if (taken[i]) {
taken[i] = false;
for (j = 0; j < responce.length; j++) {
if (responce[j].name == str) {
responce.splice(j, 1);
}
}
} else {
responce.push(file);
taken[i] = true;
}
}
}
}
function get_recipe() {
recipes = sendResponce();
//TODO GET THE RECIPIES
}
/*function replaceHTMLProductTemplate() {
let source = document.getElementById("expired-template").innerHTML;
let template = Handlebars.compile(source);
let context = { data: data };
let html = template(context);
document.getElementById("placeholder").innerHTML = html;
}
replaceHTMLProductTemplate();*/
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0/handlebars.js"></script>
<script src="index.js"></script>
</body>
</body>
</html>