-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathskincare.js
578 lines (555 loc) · 19.3 KB
/
skincare.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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
var skincare_array = [
//MOISTURIZERS
{
tag : "MOISTURIZERS",
image_url : "https://cdn02.nnnow.com/web-images/medium/styles/EEC0JNQHILF/1604298678086/1.jpg",
brand : "Clinique",
description : "Moisture Surge™ Intense 72H Lipid-Replenishing Hydrator",
price : 1899,
gender : "Female",
skin_type : "Normal",
},
{
tag : "MOISTURIZERS",
image_url : "https://cdn17.nnnow.com/web-images/medium/styles/T1CA0US0QOH/1614353172645/1.jpg",
brand : "Forest Essentials",
description : "Soundarya Radiance Cream With 24 Karat Gold And SPF 25",
price : 2099,
gender : "Female",
skin_type : "Normal",
},
{
tag : "MOISTURIZERS",
image_url : "https://cdn18.nnnow.com/web-images/medium/styles/0B1WN63C5F7/1487240983367/1.jpg",
brand : "Clinique",
description : "Even Better Skin Tone Correcting MOISTURIZERS SPF 20",
price : 2999,
gender : "Female",
skin_type : "Normal",
},
{
tag : "MOISTURIZERS",
image_url : "https://cdn11.nnnow.com/web-images/medium/styles/8KBXRZQGXX7/1636699226904/1.jpg",
brand : "Mario Badescu",
description : "Buttermilk MOISTURIZERS",
price : 1599,
gender : "Female",
skin_type : "Oily",
},
{
tag : "MOISTURIZERS",
image_url : "https://cdn06.nnnow.com/web-images/medium/styles/LEBUDDYXJG9/1636700669414/1.jpg",
brand : "Mario Badescu",
description : "Facial Spray With Aloe, Herbs And Rosewater",
price : 999,
gender : "Female",
skin_type : "Oily",
},
{
tag : "MOISTURIZERS",
image_url : "https://cdn02.nnnow.com/web-images/medium/styles/KN9EL2PAM3Y/1612250574433/1.jpg",
brand : "Forest Essentials",
description : "Eladi Teenage Day Cream With SPF",
price : 1399,
gender : "Female",
skin_type : "Oily",
},
{
tag : "MOISTURIZERS",
image_url : "https://cdn15.nnnow.com/web-images/medium/styles/VC95H9UINJ3/1585571862868/1.jpg",
brand : "Pixi",
description : "Rose Glow Mist",
price : 1199,
gender : "Male",
skin_type : "Dry",
},
{
tag : "MOISTURIZERS",
image_url : "https://cdn19.nnnow.com/web-images/medium/styles/U6MDI8RFII5/1585571862867/1.jpg",
brand : "Pixi",
description : "Hydrating Milky Mist",
price : 3999,
gender : "Male",
skin_type : "Dry",
},
{
tag : "MOISTURIZERS",
image_url : "https://cdn07.nnnow.com/web-images/medium/styles/F4TXVHMNKHB/1566551690915/1.jpg",
brand : "Sephora Collection",
description : "All Dry Hydrator",
price : 499,
gender : "Male",
skin_type : "Combination",
},
{
tag : "MOISTURIZERS",
image_url : "https://cdn00.nnnow.com/web-images/medium/styles/ZQ7Q6LNI8TE/1652089092179/1.jpg",
brand : "Sephora Collection",
description : "Nourishing MOISTURIZERS with prebiotics",
price : 899,
gender : "Male",
skin_type : "Combination",
},
//CLEANSERS
{
tag : "CLEANSERS",
image_url : "https://cdn09.nnnow.com/web-images/medium/styles/9NY0C83T5FJ/1593084196288/1.jpg",
brand : "Clinique",
description : "Take the day off cleansing balm",
price : 1199,
gender : "Female",
skin_type : "Normal",
},
{
tag : "CLEANSERS",
image_url : "https://cdn15.nnnow.com/web-images/medium/styles/G9J0XP7L5IK/1494572046858/1.jpg",
brand : "Clinique",
description : "Liquid facial soap - Combination oily to oliy",
price : 1499,
gender : "Female",
skin_type : "Normal",
},
{
tag : "CLEANSERS",
image_url : "https://cdn18.nnnow.com/web-images/medium/styles/X55FUUTFIBV/1585571862872/1.jpg",
brand : "Pixi",
description : "Glow tonic",
price : 1299,
gender : "Female",
skin_type : "Normal",
},
{
tag : "CLEANSERS",
image_url : "https://cdn01.nnnow.com/web-images/medium/styles/ITXIPNQAWY8/1585571862845/1.jpg",
brand : "Pixi",
description : "Peel & Polish Resurfacing concentrate",
price : 2199,
gender : "Female",
skin_type : "Oily",
},
{
tag : "CLEANSERS",
image_url : "https://cdn10.nnnow.com/web-images/medium/styles/J6QHNF8V3R4/1626067212265/1.jpg",
brand : "Sephora Collection",
description : "Smoothing Cleanser",
price : 1200,
gender : "Female",
skin_type : "Oily",
},
{
tag : "CLEANSERS",
image_url : "https://cdn02.nnnow.com/web-images/medium/styles/USW3I7NTGRE/1583393866808/1.jpg",
brand : "Sephora Collection",
description : "Organic Cotton pads",
price : 319,
gender : "Female",
skin_type : "Dry",
},
{
tag : "CLEANSERS",
image_url : "https://cdn09.nnnow.com/web-images/medium/styles/KG8JJIY4Y7C/1593757512690/1.jpg",
brand : "Forest Essentials",
description : "Refreshing cleansing water",
price : 1199,
gender : "Male",
skin_type : "Dry",
},
{
tag : "CLEANSERS",
image_url : "https://cdn09.nnnow.com/web-images/medium/styles/LK8JYTR9UEY/1593684983302/1.jpg",
brand : "Forest Essentials",
description : "Waso quick gentle Cleanser",
price : 1999,
gender : "Male",
skin_type : "Dry"
},
{
tag : "CLEANSERS",
image_url : "https://cdn08.nnnow.com/web-images/medium/styles/UD015JZXBCL/1637558111457/1.jpg",
brand : "Dior",
description : "Capture total super potent cleanser",
price : 4999,
gender : "Male",
skin_type : "Combination",
},
{
tag : "CLEANSERS",
image_url : "https://cdn17.nnnow.com/web-images/medium/styles/CUV1ZK7TXO2/1637555492181/1.jpg",
brand : "Dior",
description : "Hydra life lotion to foam - fresh cleanser",
price : 3299,
gender : "Male",
skin_type : "Combination",
},
{
tag : "CLEANSERS",
image_url : "https://cdn17.nnnow.com/web-images/medium/styles/CUV1ZK7TXO2/1637555492181/1.jpg",
brand : "Dior",
description : "Hydra life lotion to foam - fresh cleanser",
price : 3299,
gender : "Male",
skin_type : "Combination",
},
//TREATMENT & HIGH TECH TOOLS
{
tag : "TREATMENT & HIGH TECH TOOLS",
image_url : "https://cdn17.nnnow.com/web-images/medium/styles/K3VYOYGWCJY/1604478015053/1.jpg",
brand : "Sephora Collection",
description : "Face mask - pineapple",
price : 359,
gender : "Female",
skin_type : "Normal",
},
{
tag : "TREATMENT & HIGH TECH TOOLS",
image_url : "https://cdn18.nnnow.com/web-images/medium/styles/D0KN0LPAQC7/1606376778875/1.jpg",
brand : "Sephora Collection",
description : "Lips scrub - dragon fruit",
price : 499,
gender : "Female",
skin_type : "Normal",
},
{
tag : "TREATMENT & HIGH TECH TOOLS",
image_url : "https://cdn12.nnnow.com/web-images/medium/styles/VXHK10O6MEY/1637558489590/1.jpg",
brand : "Dior",
description : "Capture totale eye cream",
price : 4999,
gender : "Female",
skin_type : "Oily",
},
{
tag : "TREATMENT & HIGH TECH TOOLS",
image_url : "https://cdn15.nnnow.com/web-images/medium/styles/TWAFUPITHAC/1637558111494/1.jpg",
brand : "Dior",
description : "Hydra life cooling hydration sorbet eye",
price : 2499,
gender : "Female",
skin_type : "Oily",
},
{
tag : "TREATMENT & HIGH TECH TOOLS",
image_url : "https://cdn05.nnnow.com/web-images/medium/styles/E5UZP44SGKD/1661238431370/1.jpg",
brand : "Forest Essentials",
description : "Kisskiss bee glow tint lip balm",
price : 3999,
gender : "Female",
skin_type : "Dry",
},
{
tag : "TREATMENT & HIGH TECH TOOLS",
image_url : "https://cdn05.nnnow.com/web-images/medium/styles/DN2S33UD07V/1661238431340/1.jpg",
brand : "Forest Essentials",
description : "Abeille Royale advanced youth oil",
price : 2399,
gender : "Male",
skin_type : "Dry",
},
{
tag : "TREATMENT & HIGH TECH TOOLS",
image_url : "https://cdn11.nnnow.com/web-images/medium/styles/6W70Z8802VL/1620198731364/1.jpg",
brand : "Clinique",
description : "Blanc Divine intense brightnening spot corrector",
price : 2199,
gender : "Male",
skin_type : "Combination",
},
{
tag : "TREATMENT & HIGH TECH TOOLS",
image_url : "https://cdn15.nnnow.com/web-images/medium/styles/R57CWX4E4DS/1620198775946/1.jpg",
brand : "Clinique",
description : "Lintemporel blossom glow boosting mask",
price : 2299,
gender : "Male",
skin_type : "Combination",
},
//"MASKS
{
tag : "MASKS",
image_url : "https://cdn13.nnnow.com/web-images/medium/styles/CYQ6YM3FRPY/1604477899654/1.jpg",
brand : "Sephora Collection",
description : "Foot mask - coconut",
price : 420,
gender : "Female",
skin_type : "Normal",
},
{
tag : "MASKS",
image_url : "https://cdn17.nnnow.com/web-images/medium/styles/S1FZOVGS9T4/1604478015072/1.jpg",
brand : "Sephora Collection",
description : "Charcoal Nose strip",
price : 600,
gender : "Female",
skin_type : "Normal",
},
{
tag : "MASKS",
image_url : "https://cdn03.nnnow.com/web-images/medium/styles/KISBCXPBVUB/1585571862851/1.jpg",
brand : "Pixi",
description : "FortifEYE firming eye patches",
price : 2499,
gender : "Female",
skin_type : "Oily",
},
{
tag : "MASKS",
image_url : "https://cdn04.nnnow.com/web-images/medium/styles/546DCOPEHVB/1591862447401/1.jpg",
brand : "Pixi",
description : "Glow glycolic boots - brightening infusion sheet mask",
price : 1099,
gender : "Female",
skin_type : "Dry",
},
{
tag : "MASKS",
image_url : "https://cdn11.nnnow.com/web-images/medium/styles/IYQXAT62ASG/1636700669798/1.jpg",
brand : "Mario Badescu",
description : "Super collagen mask",
price : 399,
gender : "Male",
skin_type : "Combination",
},
{
tag : "MASKS",
image_url : "https://cdn13.nnnow.com/web-images/medium/styles/75FMGM1LRF7/1636699889207/1.jpg",
brand : "Mario Badescu",
description : "Healing & soothing mask",
price : 999,
gender : "Male",
skin_type : "Dry",
},
//Bath & Shower
{
tag : "BATH & SHOWER",
image_url : "https://cdn01.nnnow.com/web-images/medium/styles/QERTLLK6BCJ/1612251897120/1.jpg",
brand : "Forest Essentials",
description : "Silkening shower wash - mashobara wild honey",
price : 999,
gender : "Female",
skin_type : "Normal",
},
{
tag : "BATH & SHOWER",
image_url : "https://cdn05.nnnow.com/web-images/medium/styles/O0NNBGX3A4P/1612250574420/1.jpg",
brand : "Forest Essentials",
description : "Ultra rich body lotion",
price : 899,
gender : "Female",
skin_type : "Dry",
},
{
tag : "BATH & SHOWER",
image_url : "https://cdn11.nnnow.com/web-images/medium/styles/TU5S1MDMTKQ/1615874938098/1.jpg",
brand : "Forest Essentials",
description : "Ultra rich body milk - oudh & green Tea",
price : 1099,
gender : "Female",
skin_type : "Oily",
},
{
tag : "BATH & SHOWER",
image_url : "https://cdn14.nnnow.com/web-images/medium/styles/EEIJ27BZZTL/1636699241571/1.jpg",
brand : "Mario Badescu",
description : "Drying lotion",
price : 1999,
gender : "Male",
skin_type : "Oily",
},
{
tag : "BATH & SHOWER",
image_url : "https://cdn13.nnnow.com/web-images/medium/styles/MNVR2ADSC9A/1636700674036/1.jpg",
brand : "Mario Badescu",
description : "Rose body soap",
price : 999,
gender : "Male",
skin_type : "Combination",
},
{
tag : "BATH & SHOWER",
image_url : "https://cdn15.nnnow.com/web-images/medium/styles/9INB4DV33LY/1636699226813/1.jpg",
brand : "Mario Badescu",
description : "",
price : 999,
gender : "Male",
skin_type : "Combination",
},
//BODY MOISTURIZERS
{
tag : "BODY MOISTURIZERS",
image_url : "https://cdn15.nnnow.com/web-images/medium/styles/PRTB9W7SXKM/1644914354439/1.jpg",
brand : "Sephora Collection",
description : "Hand balm with shea butter",
price : 2099,
gender : "Female",
skin_type : "Normal",
},
{
tag : "BODY MOISTURIZERS",
image_url : "https://cdn00.nnnow.com/web-images/medium/styles/7DMGGVEBGTG/1533206306028/1.jpg",
brand : "Sephora Collection",
description : "Hand balm almond",
price : 1599,
gender : "Female",
skin_type : "Normal",
},
{
tag : "BODY MOISTURIZERS",
image_url : "https://cdn05.nnnow.com/web-images/medium/styles/O0NNBGX3A4P/1612250574420/1.jpg",
brand : "Forest Essentials",
description : "Ultra rch body lotion",
price : 1299,
gender : "Female",
skin_type : "Dry",
},
{
tag : "BODY MOISTURIZERS",
image_url : "https://cdn11.nnnow.com/web-images/medium/styles/TU5S1MDMTKQ/1615874938098/1.jpg",
brand : "Forest Essentials",
description : "ultra - rich body milk",
price : 3299,
gender : "Female",
skin_type : "Dry",
},
{
tag : "BODY MOISTURIZERS",
image_url : "https://cdn14.nnnow.com/web-images/medium/styles/EEIJ27BZZTL/1636699241571/1.jpg",
brand : "Mario Badescu",
description : "Drying lotion",
price : 999,
gender : "Male",
skin_type : "Oily",
},
{
tag : "BODY MOISTURIZERS",
image_url : "https://cdn15.nnnow.com/web-images/medium/styles/9INB4DV33LY/1636699226813/1.jpg",
brand : "Mario Badescu",
description : "Special cucumber lotion",
price : 899,
gender : "Male",
skin_type : "Combination",
},
//VEGAN
{
tag : "VEGAN",
image_url : "https://cdn02.nnnow.com/web-images/medium/styles/E0ANC9EFYPI/1605193380207/1.jpg",
brand : "Sephora Collection",
description : "Gentle eye and lip makeup remover",
price : 1599,
gender : "Female",
skin_type : "Normal",
},
{
tag : "VEGAN",
image_url : "https://cdn10.nnnow.com/web-images/medium/styles/5CPKFRTG7GD/1604477892837/1.jpg",
brand : "Sephora Collection",
description : "Gentle PH balancing toner",
price : 1399,
gender : "Female",
skin_type : "Normal",
},
];
localStorage.setItem("skincare_products", JSON.stringify(skincare_array));
var skincare_obj = JSON.parse(localStorage.getItem("skincare_products")) || [];
display_skincare(skincare_obj);
function display_skincare(skin_array){
console.log(skin_array);
document.getElementById("product_display").innerHTML = "";
skin_array.map(function(elem,index){
var div2 = document.createElement("div");
var image = document.createElement("img");
image.setAttribute("src",elem.image_url);
image.setAttribute("atl",elem.brand);
var name = document.createElement("h4");
name.innerText = elem.brand;
var info = document.createElement("p");
info.innerText = elem.description;
var div3 = document.createElement("div");
div3.setAttribute("id","rupees_value")
// var rupees = document.createElement("h4");
// rupees.innerText = "Rs. - ";
var value = document.createElement("h4");
value.innerText = "Rs. " + elem.price;
// div3.append(rupees,value);
var add_to_cart = document.createElement("button");
add_to_cart.innerText = "Add to Cart";
add_to_cart.setAttribute("class","cart_bag");
add_to_cart.addEventListener("click",function(){
add_pro_cart_fun(elem);
});
var add_to_bag = document.createElement("button");
add_to_bag.innerText = "Add to Bag";
add_to_bag.addEventListener("click",function(){
add_pro_bag_fun(elem);
});
add_to_bag.setAttribute("class","cart_bag");
div2.append(image,name,info,value,add_to_cart);
document.getElementById("product_display").append(div2);
});
}
var cartProducts = JSON.parse(localStorage.getItem("cart_products"))|| [];
function add_pro_cart_fun(elem){
cartProducts.push(elem);
localStorage.setItem("cart_products",JSON.stringify(cartProducts));
}
var bagProducts = JSON.parse(localStorage.getItem("bag_products"))|| [];
function add_pro_bag_fun(elem){
bagProducts.push(elem);
localStorage.setItem("bag_products",JSON.stringify(bagProducts));
}
function filter_fun(){
filter_gender_fun();
filter_brand_fun();
filter_skintype_fun();
sort_price_fun();
var gender_filtered = skincare_obj;
function filter_gender_fun(){
selected_gender = document.getElementById("filter_gender").value;
gender_filtered = skincare_obj.filter(function(elem){
if(selected_gender === "all"){
return 1;
}
return elem.gender === selected_gender;
});
//display_skincare(gender_filtered);
}
var brand_filtered = gender_filtered;
function filter_brand_fun(){
var selected_brand = document.getElementById("filter_brand").value;
brand_filtered = gender_filtered.filter(function(elem){
if(selected_brand === "all"){
return 1;
}
return elem.brand === selected_brand;
});
//console.log(brand_filtered);
}
//display_skincare(brand_filtered);
var skintype_filtered = brand_filtered;
function filter_skintype_fun(){
var selected_skintype = document.getElementById("filter_skin_type").value;
skintype_filtered = brand_filtered.filter(function(elem){
if(selected_skintype === "all"){
return 1;
}
return elem.skin_type === selected_skintype;
});
//display_skincare(skintype_filtered);
}
function sort_price_fun(){
if(document.getElementById("sort_price").value == 'high'){
skintype_filtered.sort(function(a,b){
if(parseInt(a.price)>parseInt(b.price)) return -1;
if(parseInt(a.price)<parseInt(b.price)) return 1;
return 0;
});
}
if(document.getElementById("sort_price").value == 'low'){
skintype_filtered.sort(function(a,b){
if(parseInt(a.price)>parseInt(b.price)) return 1;
if(parseInt(a.price)<parseInt(b.price)) return -1;
return 0;
});
}
display_skincare(skintype_filtered);
}
}