forked from MingshuoYu/SkincareMaster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExpertAdviceList.html
157 lines (139 loc) · 7.29 KB
/
ExpertAdviceList.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
<!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>
<!-- articles -->
<script id="entry-template" type="text/x-handlebars-template">
<div class="container-fluid">
<a href="articleDetail.html?type=advice&title={{title}}">
<div class="card" style="margin:1rem">
<img class="card-img-top" src="{{picture}}" alt="Card image cap">
<div class="card-body">
<h6 class="card-text">{{title}}</h6>
</div>
</div>
</a>
</div>
</script>
<div class="container-fluid">
<div id="templatedArticles">
</div>
</div>
<script>
var advice = [
{ 'title': 'Always Double Cleanse', 'picture': 'img/cleanFace.jpg', 'text': "Why? Double cleansing means washing your face twice because one wash just isn’t enough. Whether you wear a ton of makeup or not, double cleansing at the end of the day is essential to remove all of the makeup, dirt, grime, and pollution that builds up on your skin. Washing your face once will only remove the surface dirt, but a second cleanse will actually be able to penetrate your pores, sweeping away any sebum and leftover dirt or makeup. It also means your following skincare steps will be able to penetrate your skin better." },
{ 'title': 'Layer Your Products the Right Way', 'picture': 'img/applyLotion.jpg', 'text': 'Why? Layering your skincare in the wrong order means that some of your products won’t be able to absorb into your skin properly. For example, if you apply a moisturizer before your eye cream, because moisturizers have occlusives in (ingredients that create a barrier on your skin), the potent ingredients in your eye cream wouldn’t get a chance to penetrate your skin properly and work their magic.' }
]
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
}
// Call this function when the page loads (the "ready" event)
$(document).ready(function () {
// compile the template
var source = $("#entry-template").html();
var template = Handlebars.compile(source);
var parentDiv = $("#templatedArticles");
// now iterate through the complexData list and keep appending:
for (var i = 0; i < advice.length; i++) {
var curData = advice[i];
var curHtml = template(curData);
parentDiv.append(curHtml);
}
if(sessionStorage.getItem("isLoggedIn") == "yes"){
document.getElementById("signOutBtn").style.visibility="visible";
}
});
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 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>