forked from MingshuoYu/SkincareMaster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDIYSkincareList.html
154 lines (139 loc) · 7.2 KB
/
DIYSkincareList.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
<!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=DIY&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 DIY = [
{ 'title': 'The Calming Honey Mask', 'picture': 'img/honey.jpg', 'text': " 2 tablespoons of pure honey 1 teaspoon of cinnamon 1 wedge of fresh lemon. Warm the honey in the microwave for a few seconds, then combine it with the cinnamon and the juice of a lemon wedge into a small bowl. Cinnamon is known to reduce inflammation and redness—plus, it sops up excess oil when applied topically. Lemon acid not only helps exfoliate your skin, but can minimize the appearance of dark spots, too. Gently massage the mixture onto your face and leave on for about 15-20 minutes, then rinse off." },
{ 'title': 'The Exfoliating Brown Sugar Scrub Mask', 'picture': 'img/exfoliate.jpg', 'text': '2 tablespoons of brown sugar 2 tablespoons of virgin coconut oil. Brown sugar sloughs off dead skin while coconut oil packs it with moisture. The result? A soft and glowy finish. Use equal parts brown sugar and coconut oil to form an easy scrub, apply it on your face in gentle circular motions, let it sink in for a few minutes and wash it off with warm water.' }
]
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 < DIY.length; i++) {
var curData = DIY[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>