forked from MingshuoYu/SkincareMaster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWrinklesList.html
255 lines (229 loc) · 11.1 KB
/
WrinklesList.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Skincare Master</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.2/css/all.css" integrity="sha384-/rXc/GQVaYpyDdyxK+ecHPVYJSN9bmVFBvjA/9eOB+pb3F2w2N6fc5qB9Ew5yIns"
crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script src="https://use.fontawesome.com/releases/v5.0.8/js/all.js"></script>
</head>
<body>
<!--Nav bar-->
<div>
<div id="mySidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<p>REVIEW</p>
<p class="inSidenav">Product Type</p>
<a class="innerSidenav" href="cleanserList.html">cleanser</a>
<a class="innerSidenav" href="moisturizerList.html">moisturizer</a>
<a class="innerSidenav" href="bodyLotionList.html">body lotion</a>
<p class="inSidenav">Skin Concern</p>
<a class="innerSidenav" href="AcneList.html">Acne</a>
<a class="innerSidenav" href="BlackheadsList.html">Blackheads</a>
<a class="innerSidenav" href="WrinklesList.html">Wrinkles</a>
<p>ARTICLE</p>
<a class="innerSidenav" href="DIYSkincareList.html">DIY Skincare</a>
<a class="innerSidenav" href="NutritionList.html">Nutrition</a>
<a class="innerSidenav" href="ExpertAdviceList.html">Expert Advice</a>
<a href="myAccountPage.html">MY ACCOUNT</a>
<button type="button" class="btn btn-dark" id="signOutBtn" onclick="signOut()" style="visibility: hidden;margin-left:150px">Sign
Out</button>
</div>
<a class="backBtn" href="javascript:history.back()">
<i class="fas fa-chevron-left" style='font-size:24px'></i>
</a>
<a class="title justify-content-center" href="index.html">SkincareMaster</a>
<span class="manuButton" style="font-size:30px;cursor:pointer" onclick="openNav()">☰ </span>
</div>
<!-- Search form -->
<div class="row justify-content-center">
<form class="example col-10">
<input type="text" placeholder="Search.." name="search" id="searchField">
<button type="button"><i class="fa fa-search" onclick="search()"></i></button>
</form>
</div>
<div class="row container-fluid justify-content-end">
<p id="sortBy"></p>
<div class="dropdown" style="padding-left: 10px">
<button class="btn btn-secondary btn-sm dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false" id="sortByBtn">
Sort by
</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" onclick="sortByRating()">Top-Rated</a>
<a class="dropdown-item" onclick="sortByFav()">Most popular</a>
<a class="dropdown-item" onclick="sortByPrice()">Price low-high</a>
</div>
</div>
</div>
<!--
<script id="entry-template" type="text/x-handlebars-template">
<div class="card col-5" style="margin: 0.5rem">
<a href="productDetail.html?type=wrinkle&product={{productName}}">
<img class="card-img-top img-fluid" src="{{picture}}" alt="#">
<div class="card-body" style="padding: 0rem">
<p class="card-title font-weight-bold">{{company}}</p>
<p class="card-text text-truncate">{{productName}}</p>
<p class="card-text text-truncate">Rating: {{rating}}</p>
<p class="card-text text-truncate">Favorites: {{fav}} k</p>
<p class="card-text text-truncate">${{price}}</p>
</div>
</a>
</div>
</script>
-->
<script id="entry-template" type="text/x-handlebars-template">
<a href="productDetail.html?type=wrinkle&product={{productName}}">
<div class="card" style="margin: 0.5rem;border: 1px solid rgba(0,0,0,.125);border-radius: .25rem;padding: 10px;">
<div class="row">
<div class="col-3">
<img class="card-img-top" src="{{picture}}" alt="#">
</div>
<div class="col-9">
<div class="card-body" style="padding: 0rem">
<p class="card-title font-weight-bold">{{company}}</p>
<p class="card-text text-truncate">{{productName}}</p>
<p class="card-text text-truncate">Rating: {{rating}}</p>
<p class="card-text text-truncate">Favorites: {{fav}} k</p>
<p class="card-text text-truncate">${{price}}</p>
</div>
</div>
</div>
</div>
</a>
</script>
<div class="container-fluid" id="content">
<div class="row justify-content-center" id="templatedProducts">
</div>
</div>
<script>
var wrinkle = [
{ 'company': 'ESTEE LAUDER', 'productName': 'Advanced Night Repair Recovery', 'picture': 'img/Wrinkle1.JPG', 'rating': 3, 'fav': 30, 'price': 98 },
{ 'company': 'KATE SOMERVILLE', 'productName': 'Instant Detox Mask', 'picture': 'img/Wrinkle2.JPG', 'rating': 4, 'fav': 40, 'price': 60 },
{ 'company': 'ESTEE LAUDER', 'productName': 'Perfectionist CPR Wrinkle Lifting', 'picture': 'img/wrinkle3.png', 'rating': 3, 'fav': 50, 'price': 98 },
{ 'company': 'DR. DENNIS GROSS SKINCARE', 'productName': 'Retinol Wrinkle Recovery Overnight Serum', 'picture': 'img/wrinkle4.png', 'rating': 5, 'fav': 60, 'price': 88 }
]
$(document).ready(function () {
// compile the template
var source = $("#entry-template").html();
var template = Handlebars.compile(source);
var parentDiv = $("#templatedProducts");
// now iterate through the complexData list and keep appending:
for (var i = 0; i < wrinkle.length; i++) {
var curData = wrinkle[i];
var curHtml = template(curData);
parentDiv.append(curHtml);
}
if (sessionStorage.getItem("isLoggedIn") == "yes") {
document.getElementById("signOutBtn").style.visibility = "visible";
}
});
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
}
function favFunction(x) {
x.classList.toggle("fas");
}
function search() {
var input = document.getElementById("searchField").value;
var productList = JSON.parse(localStorage.getItem("productList"));
var typeList = JSON.parse(localStorage.getItem("typeList"));
var foundProduct = false;
var foundType = false;
var link;
var product;
for (var i = 0; i < productList.length; i++) {
var currData = productList[i];
if (currData.toUpperCase() === input.toUpperCase()) {
foundProduct = true;
product = productList[i];
}
}
if (!foundProduct) {
for (var i = 0; i < typeList.length; i++) {
var currType = typeList[i].type;
if (currType.toUpperCase() === input.toUpperCase()) {
foundType = true;
link = typeList[i].link;
}
}
}
if (foundProduct) {
window.location = "productDetail.html?product=" + product;
}
else if (foundType) {
window.location = link;
}
else {
alert("Sorry, item is not found :(");
}
}
function sortByRating() {
document.getElementById("sortBy").innerHTML = "Top-Rated";
wrinkle.sort(function (a, b) {
return b.rating - a.rating;
});
document.getElementById('templatedProducts').innerHTML = "";
var source = $("#entry-template").html();
var template = Handlebars.compile(source);
var parentDiv = $("#templatedProducts");
// now iterate through the complexData list and keep appending:
for (var i = 0; i < wrinkle.length; i++) {
var curData = wrinkle[i];
var curHtml = template(curData);
parentDiv.append(curHtml);
}
}
function sortByFav() {
document.getElementById("sortBy").innerHTML = "Most Popular";
wrinkle.sort(function (a, b) {
return b.fav - a.fav;
});
document.getElementById('templatedProducts').innerHTML = "";
var source = $("#entry-template").html();
var template = Handlebars.compile(source);
var parentDiv = $("#templatedProducts");
// now iterate through the complexData list and keep appending:
for (var i = 0; i < wrinkle.length; i++) {
var curData = wrinkle[i];
var curHtml = template(curData);
parentDiv.append(curHtml);
}
}
function sortByPrice() {
document.getElementById("sortBy").innerHTML = "Price low-high";
wrinkle.sort(function (a, b) {
return a.price - b.price;
});
document.getElementById('templatedProducts').innerHTML = "";
var source = $("#entry-template").html();
var template = Handlebars.compile(source);
var parentDiv = $("#templatedProducts");
// now iterate through the complexData list and keep appending:
for (var i = 0; i < wrinkle.length; i++) {
var curData = wrinkle[i];
var curHtml = template(curData);
parentDiv.append(curHtml);
}
}
function signOut() {
sessionStorage.setItem("isLoggedIn", "no");
sessionStorage.setItem("currentUser", "");
window.location = 'myAccountPage.html';
}
</script>
<script src="https://code.jquery.com/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/handlebars-v4.0.11.js"></script>
</body>
</html>