-
Notifications
You must be signed in to change notification settings - Fork 0
/
skin.js
303 lines (281 loc) · 10.2 KB
/
skin.js
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
let loginBtn = document.querySelector("#login");
console.log(loginBtn);
let isAuth = localStorage.getItem("isAuth") || "Not Authenticated";
if(isAuth !== "Authenticated"){
window.location.href ="./login.html";
}else{
loginBtn.innerText = "Logout";
loginBtn.addEventListener("click",function(){
localStorage.setItem("isAuth", "Not Authenticated");
window.location.reload();
})
}
let arrData = [
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/NicoLips_f3481a6f-0bc2-49fc-b035-fd7fa47c96cb.jpg?v=1693827867&width=250",
title: "LIP BRIGHTENING, NOURISHING & REPAIRING",
name: "Nicolips Lip Brightening Scrub - 20gm",
rating: 4.8,
price: 249.00,
strikedPrice: 450.00
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/eyelift-website.jpg?v=1696575192&width=250",
title: "UNDER EYE CREAM FOR WOMEN AND MEN",
name: "Eyelift Under Eye Cream - 20gms",
rating: 4.6,
price: 240.00,
strikedPrice: 325.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/C-GlowFaceWash.jpg?v=1693827395&width=250",
title: "DE-TAN & BRIGHTENING",
name: "C-Glow Face Wash - 100ml",
rating: 4.8,
price: 175.00,
strikedPrice: 249.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/Exfoliate.jpg?v=1693827497&width=250",
title: "GENTLE EXFOLIATION, NOURISHING & SKIN BRIGHTENING",
name: "Exfoliate Face And Body Scrub Grit - 75gm",
rating: 4.9,
price: 99.00,
strikedPrice: 275.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/C-GlowFaceCream-50ml.jpg?v=1694079553&width=250",
title: "BRIGHTENING & ANTI PIGMENTATION",
name: "C-Glow Face Cream - 50ml",
rating: 4.2,
price: 249.00,
strikedPrice: 375.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/NaturalAntiPollutionCombo.jpg?v=1693922247&width=250",
title: "C-GLOW FACE WASH & EXFOLIATE FACE & BODY SCRUB",
name: "Natural Anti Pollution Combo",
rating: 4.6,
price: 249.00,
strikedPrice: 524.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/C-GlowFacePack_1723f778-80d9-4715-ba0b-7362fcf86574.jpg?v=1693919932&width=250",
title: "SKIN BRIGHTENING & ANTI BLEMISH",
name: "C-Glow Face Pack - 100gm",
rating: 4.6,
price: 249.00,
strikedPrice: 399.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/insta-bright-website.jpg?v=1696575493&width=250",
title: "TAN REMOVAL FACE PACK FOR WOMEN AND MEN",
name: "De Tan Face Pack For Glowing Skin - 100gm",
rating: 4.7,
price: 271.00,
strikedPrice: 399.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/AntiAcneNeemCombo.jpg?v=1693921602&width=250",
title: "DEEP CLEANSES, CONTROLS ACNE MARKS, REDUCES EXCESS OIL PRODUCTION",
name: "Anti Acne Neem Combo ",
rating: 4.7,
price: 299.00,
strikedPrice: 668.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/KumkumadiBrighteningCombo.jpg?v=1693922064&width=250",
title: "DEEP CLEANSES, REJUVENATES AND NOURISHES",
name: "Kumkumadi Brightening Combo",
rating: 4.6,
price: 249.00,
strikedPrice: 948.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/AntiAcneFaceWash.jpg?v=1693921385&width=250",
title: "DEEP CLEANSER, SPOT TREATMENT & PIMPLE REPAIR",
name: "Anti Acne Face Wash - 100ml ",
rating: 4.9,
price: 149.00,
strikedPrice: 299.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/products/NoseGlow-01.jpg?v=1652169791&width=250",
title: "DEEP CLEANSING & CLARIFYING",
name: "Noseglow Nose Scrub - 20gm",
rating: 3.7,
price: 198.00,
strikedPrice: 325.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/products/654.jpg?v=1668147215&width=250",
title: "PIMPLE SCAR REMOVAL & SKIN CLARIFYING",
name: "Anti Acne, Pimple Scar Spots Removal Gel For Men & Women - 50gm ",
rating: 4.9,
price: 249.00,
strikedPrice: 399.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/CEOMan500mlShowerGel-01.jpg?v=1692770100&width=250",
title: "BODY WASH FOR MEN",
name: "CEO Man Shower Gel - 500ml",
rating: 4.8,
price: 335.00,
strikedPrice: 499.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/SkaiAquatic500mlShowerGel-01.jpg?v=1694604006&width=250",
title: "SKAI AQUATIC SHOWER GEL",
name: "SKAI Aquatic Shower Gel - 500 ml",
rating: 4.7,
price: 335.00,
strikedPrice: 499.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/Skai-Travel-pouch-10_2.jpg?v=1695300843&width=250",
title: "BATH AND BODY TRAVEL KIT FOR MEN AND WOMEN",
name: "SKAI Aquatic Travel Minis Kit - 275ml",
rating: 4.9,
price: 599.00,
strikedPrice: 869.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/DateWoman-01.jpg?v=1695109179&width=250",
title: "DATE SHOWER GEL FOR WOMEN",
name: "DATE WOMAN Shower Gel - 500ml",
rating: 4.7,
price: 335.00,
strikedPrice: 499.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/NaturalRadianceCombo.jpg?v=1693922321&width=250",
title: "DEEP CLEANS, REPLENISHES, REJUVENATES",
name: "Natural Radiance Combo",
rating: 4.4,
price: 699.00,
strikedPrice: 997.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/products/682.jpg?v=1668763806&width=250",
title: "MOISTURIZING & NOURISHING",
name: "Glowtion - Face & Body Lotion - 100m",
rating: 4.7,
price: 199.00,
strikedPrice: 299.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/Tinty-Pomegranate-8gm.jpg?v=1694008819&width=250",
title: "3 IN 1 LIP CHEEK & EYE TINT",
name: "Tinty - Pomegranate Maroon - 8gm",
rating: 4.9,
price: 149.00,
strikedPrice: 349.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/Tinty-PeachyPeach-8gm.jpg?v=1693921845&width=250",
title: "3 IN 1 LIP CHEEK & EYE TINT",
name: "Tinty - Peachy Peach - 8gm",
rating: 4.8,
price: 149.00,
strikedPrice: 349.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/products/CelebshineGold-01_e00fff97-54c2-489f-b054-88b90a7e8cac.jpg?v=1652176140&width=250",
title: "ILLUMINATE, MOISTURISE, NOURISH",
name: "Celebshine Body Lotion Gold - 50ml",
rating: 4.5,
price: 199.00,
strikedPrice: 499.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/products/Herbal-Sindoor-Red-01.jpg?v=1651698315&width=250",
title: "LONG LASTING & SMUDGE PROOF",
name: "Herbal Sindoor - Red - 5ml",
rating: 4.8,
price: 129.00,
strikedPrice: 149.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/products/2.FOP-NoseStrips-Women-6Strips_3632f3f1-01bd-47be-bd37-de64ed7c3feb.jpg?v=1665837737&width=250",
title: "PAINLESS & INSTANT REMOVAL OF BLACKHEADS, WHITEHEADS, OIL & DIRT",
name: "Blackhead Remover Strips For Women - 6 Strips ",
rating: 1.0,
price: 199.00,
strikedPrice: 230.00,
},
{
imageUrl: "https://bellavitaorganic.com/cdn/shop/files/Dategiftset-01.jpg?v=1705563221&width=250",
title: "BATH AND BODY GIFT SET FOR WOMEN",
name: "DATE Woman Premium Gift Set",
rating: 5.0,
price: 1320.00,
strikedPrice: 1949.00,
},
];
let container = document.querySelector("#content");
let productNumber = document.querySelector("#productNumber");
productNumber.innerText = `${arrData.length} products`;
function appendData(arrData){
container.innerHTML = "";
arrData.forEach(function(el){
// console.log(el);
let productDiv = document.createElement("div");
let img = document.createElement("img")
img.src=el.imageUrl;
img.style.cursor = "pointer";
img.addEventListener("click",function(){
showProduct(el);
// console.log(el);
})
let p1 = document.createElement("p")
p1.innerText = el.title
let h4 = document.createElement("h4");
h4.innerText = el.name;
h4.setAttribute("class","hide-text")
let ratingDiv = document.createElement("div");
ratingDiv.setAttribute("class","rating")
let ratingP = document.createElement("p");
ratingP.setAttribute("class","material-icons")
ratingP.innerText = "star"
let p2 = document.createElement("p");
p2.innerText = el.rating;
let span1 = document.createElement("span");
span1.innerText = `₹${el.price}`
let span2 = document.createElement("span");
span2.innerText = `₹${el.strikedPrice}`;
span2.style.textDecoration = "line-through";
let btn = document.createElement("button")
btn.innerText = "ADD TO CART";
btn.addEventListener("click",function(){
alert("Added to cart");
addToCart(el);
})
ratingDiv.append(ratingP,p2)
productDiv.append(img,p1,h4,ratingDiv,span1,span2,btn);
container.append(productDiv);
})
}
appendData(arrData)
let select = document.querySelector("#sort");
select.addEventListener("change",function(){
arrData.sort(function(a,b){
if(select.value == "lowToHigh"){
return(a.price - b.price)
}
else if(select.value == "highToLow"){
return(b.price - a.price);
}
})
appendData(arrData);
})
function showProduct(el){
localStorage.setItem("showProduct",JSON.stringify(el));
window.location.href = "./showProduct.html";
}
function addToCart(el){
// console.log(el);
let cartArr = JSON.parse(localStorage.getItem("cartItems")) || [];
cartArr.push(el);
localStorage.setItem("cartItems",JSON.stringify(cartArr));
}
// console.log(newArr)