-
Notifications
You must be signed in to change notification settings - Fork 0
/
sale.js
608 lines (583 loc) · 28.1 KB
/
sale.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
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
let salesBanners=["https://modesens.com/banner/14188/getimg/?img=%2Fbanner%2F20221208-modesens-SSENSE-550x275-EN_1670407738.jpg",
"https://modesens.com/banner/14100/getimg/?img=%2Fbanner%2F20221205-modesens-Italist-550x275-EN_1670226052.jpg",
"https://modesens.com/banner/14353/getimg/?img=%2Fbanner%2F20221203-modesens-Mytheresa-550x275-EN_1669878967.jpg",
"https://modesens.com/banner/14190/getimg/?img=%2Fbanner%2F20221121-modesens-Antonioli-550x275-EN_1669015263.jpg",
"https://modesens.com/banner/14206/getimg/?img=%2Fbanner%2F20221122-modesens-d2-550x275-EN_1669103155.jpg",
"https://modesens.com/banner/14355/getimg/?img=%2Fbanner%2F20221212-modesens-LVR-550x275-F-EN_1670581285.jpg",
"https://modesens.com/banner/14243/getimg/?img=%2Fbanner%2F20221128Montblanc-Modesens550x275_1669620217.png",
"https://modesens.com/banner/14245/getimg/?img=%2Fbanner%2F20221125-modesens-Dorothee-550x275-F-EN_1669195516.jpg",
"https://modesens.com/banner/14311/getimg/?img=%2Fbanner%2F20221129-modesens-SlamJam-550x275-M-EN_1669700129.jpg",
"https://modesens.com/banner/14484/getimg/?img=%2Fbanner%2F20221212-modesens-Harrods-550x275-EN_1670581283.jpg",
"https://modesens.com/banner/14486/getimg/?img=%2Fbanner%2F20221212-modesens-Harvey-550x275-F-EN_1670581284.jpg",
"https://modesens.com/banner/14402/getimg/?img=%2Fbanner%2F20221205-modesens-Tessabit-550x275-EN_1670226055.jpg",
"https://modesens.com/banner/14460/getimg/?img=%2Fbanner%2F20221210-modesens-Modes-550x275-EN_1670490354.jpg",
"https://modesens.com/banner/14102/getimg/?img=%2Fbanner%2F20221201-modesens-Wanan-550x275-EN_1669782640.jpg",
"https://modesens.com/banner/14404/getimg/?img=%2Fbanner%2F20221205-modesens-Sugar-550x275-F-EN_1670226054.jpg",
"https://modesens.com/banner/14341/getimg/?img=%2Fbanner%2F20221201-modesens-TheDoubleF-550x275-EN_1669782639.jpg",
"https://modesens.com/banner/14406/getimg/?img=%2Fbanner%2F20221205-modesens-Oluxury-550x275-F-EN_1670226053.jpg",
"https://modesens.com/banner/14359/getimg/?img=%2Fbanner%2F20221203-modesens-Michele-550x275-EN_1669878966.jpg"
];
let bestSellers=[
{
"title": "SSENSE",
"avatar": "https://cdn.modesens.com/merchant/ssense-logo.png?w=400",
"description": "Enjoy up to 60% off select styles.",
"id": "1",
"exclusive": false
},
{
"title": "GUCCI",
"avatar": "https://cdn.modesens.com/merchant/Gucci-1509699111?w=400",
"description": "Shop Gucci gift guide.",
"id": "2",
"exclusive": false
},
{
"title": "NORDSTROM",
"avatar": "https://cdn.modesens.com/merchant/nordstrom-1470104252?w=400",
"description": "Enjoy up to 25% off Nike styles.",
"id": "3",
"exclusive": false
},
{
"title": "NetAPorter",
"avatar": "https://cdn.modesens.com/merchant/NAP.jpg?w=400",
"description": "Enjoy up to 60% off select styles.",
"id": "4",
"exclusive": true
},
{
"title": "CETTIRE",
"avatar": "https://cdn.modesens.com/merchant/cettire.png?w=400",
"description": "Enjoy up to 50% off FW22 items.",
"id": "5",
"exclusive": false
},
{
"title": "MYTHERESA",
"avatar": "https://cdn.modesens.com/merchant/mytheresa.png?w=400",
"description": "Jacquemus Private Sale! Enjoy up to 30% off select styles.",
"id": "6",
"exclusive": false
},
{
"title": "FARFETCH",
"avatar": "https://cdn.modesens.com/merchant/farfetch-logo.jpg?w=400",
"description": "Enjoy up to 50% off select styles.",
"id": "7",
"exclusive": false
},
{
"title": "ALLSAINTS",
"avatar": "https://cdn.modesens.com/merchant/allsaints-logo.png?w=400",
"description": "Take advantage of free shipping.",
"id": "8",
"exclusive": false
},
{
"title": "VERSACE",
"avatar": "https://cdn.modesens.com/merchant/versace.jpg?w=400",
"description": "Order by December 20th for delivery by December 24th.",
"id": "9",
"exclusive": true
},
{
"title": "LULULEMON",
"avatar": "https://cdn.modesens.com/logo/lululemon-logo.png?w=400",
"description": "Holiday Shipping cut off.",
"id": "10",
"exclusive": false
},
{
"title": "NEIMANMARCUS",
"avatar": "https://cdn.modesens.com/merchant/neiman_marcus-1470104251?w=400",
"description": "Take advantage of 2 days free shipping. Use code NMHURRY",
"id": "11",
"exclusive": false
},
{
"title": "HARRODS",
"avatar": "https://cdn.modesens.com/merchant/harrods-1470104242?w=400",
"description": "Enjoy 30% off select styles.",
"id": "12",
"exclusive": false
},
{
"title": "THEOUTNET",
"avatar": "https://cdn.modesens.com/merchant/the-outnet_20181229.png?w=400",
"description": "Enjoy up to 70% off select styles.",
"id": "13",
"exclusive": true
},
{
"title": "SHOPBOP",
"avatar": "https://cdn.modesens.com/merchant/shopbop.png?w=400",
"description": "Take advantage of free shipping.",
"id": "14",
"exclusive": false
},
{
"title": "SAKS",
"avatar": "https://cdn.modesens.com/merchant/saks_newlogo.png?w=400",
"description": "Enjoy $50 off every $200 purchase + 15% off Beauty. Use code GET50SF",
"id": "15",
"exclusive": false
},
{
"title": "RAMYBROOK",
"avatar": "https://cdn.modesens.com/merchant/RamyBrookLogo.png?w=400",
"description": "Shop Holiday Party Dresses.",
"id": "16",
"exclusive": false
},
{
"title": "ROBERTGRAHAM",
"avatar": "https://cdn.modesens.com/merchant/robert-graham.png?w=400",
"description": "Enjoy 60% off select styles + surprise gift with $300+ purchase.",
"id": "17",
"exclusive": false
},
{
"title": "TORYBURCH",
"avatar": "https://cdn.modesens.com/merchant/TB_S17_LOGO_125X125.jpg?w=400",
"description": "Enjoy up to 50% off select styles.",
"id": "18",
"exclusive": true
},
{
"title": "ITALIST",
"avatar": "https://cdn.modesens.com/merchant/italist_logo.png?w=400",
"description": "Take advantage of free shipping.",
"id": "19",
"exclusive": false
},
{
"title": "LACOSTE",
"avatar": "https://cdn.modesens.com/merchant/lacoste-logo.jpg?w=400",
"description": "Enjoy up to 50% off sitewide + free shipping.",
"id": "20",
"exclusive": false
},
{
"title": "FRYE",
"avatar": "https://cdn.modesens.com/merchant/frye-logo.jpeg?w=400",
"description": "Enjoy 15% off your first order.",
"id": "21",
"exclusive": true
},
{
"title": "ETRO",
"avatar": "https://cdn.modesens.com/merchant/etro--logo.png?w=400",
"description": "Enjoy €/£/$300 off your purchase on orders of €/£/$900. Use code DOUBLE300",
"id": "22",
"exclusive": false
},
{
"title": "MACYS",
"avatar": "https://cdn.modesens.com/merchant/macy%27s-1471663845?w=400",
"description": "Enjoy 10% off your purchase on orders of $200+. Use code DEC10US.",
"id": "23",
"exclusive": false
},
{
"title": "MRPORTER",
"avatar": "https://cdn.modesens.com/merchant/mr_porter-1473686485?w=400",
"description": "Enjoy up to 50% off select styles.",
"id": "24",
"exclusive": false
},
{
"title": "BERNARDELLI",
"avatar": "https://cdn.modesens.com/merchant/bernardelli_logo.png?w=400",
"description": "Enjoy 20% off sitewide. Excluded (★) labelled and New items. Use code FH20",
"id": "25",
"exclusive": true
},
{
"title": "BELSTAFF",
"avatar": "https://cdn.modesens.com/merchant/belstaff-logo.png?w=400",
"description": "Enjoy up to 40% off select styles.",
"id": "26",
"exclusive": false
},
{
"title": "NIKE",
"avatar": "https://cdn.modesens.com/merchant/nike-1473686485?w=400",
"description": "Enjoy up to 50% off select styles.",
"id": "27",
"exclusive": false
},
{
"title": "BOMBAS",
"avatar": "https://cdn.modesens.com/merchant/bombas_logo.jpg?w=400",
"description": "Enjoy 20% off your first order. Use code FH20.",
"id": "28",
"exclusive": true
},
{
"title": "FINISHLINE",
"avatar": "https://cdn.modesens.com/merchant/finish_line.png?w=400",
"description": "Enjoy 30% off select styles. Use code CYBER30.",
"id": "29",
"exclusive": false
},
{
"title": "DIOR",
"avatar": "https://cdn.modesens.com/merchant/dior_logo.jpeg?w=400",
"description": "Enjoy up to 50% off sitewide + free shipping.",
"id": "30",
"exclusive": false
},
{
"title": "SSENSE",
"avatar": "https://cdn.modesens.com/merchant/ssense-logo.png?w=400",
"description": "Take advantage of free shipping on orders of $300+.",
"id": "31",
"exclusive": false
},
{
"title": "GUCCI",
"avatar": "https://cdn.modesens.com/merchant/Gucci-1509699111?w=400",
"description": "Enjoy 20% off your first order. Use code FH20.",
"id": "32",
"exclusive": false
},
{
"title": "NORDSTROM",
"avatar": "https://cdn.modesens.com/merchant/nordstrom-1470104252?w=400",
"description": "Take advantage of free shipping on selected full-price styles.",
"id": "33",
"exclusive": false
},
{
"title": "NetAPorter",
"avatar": "https://cdn.modesens.com/merchant/NAP.jpg?w=400",
"description": "Shop the holiday gift collection.",
"id": "34",
"exclusive": false
},
{
"title": "CETTIRE",
"avatar": "https://cdn.modesens.com/merchant/cettire.png?w=400",
"description": "Enjoy up to 50% off FW22 items.",
"id": "35",
"exclusive": true
},
{
"title": "MYTHERESA",
"avatar": "https://cdn.modesens.com/merchant/mytheresa.png?w=400",
"description": "Enjoy up to 50% off select womenswear.",
"id": "36",
"exclusive": false
},
{
"title": "FARFETCH",
"avatar": "https://cdn.modesens.com/merchant/farfetch-logo.jpg?w=400",
"description": "Enjoy $40 off your purchase on orders of $500. Use code 40AFFBF22",
"id": "37",
"exclusive": false
},
{
"title": "ALLSAINTS",
"avatar": "https://cdn.modesens.com/merchant/allsaints-logo.png?w=400",
"description": "Take advantage of free shipping.",
"id": "38",
"exclusive": false
},
{
"title": "VERSACE",
"avatar": "https://cdn.modesens.com/merchant/versace.jpg?w=400",
"description": "Enjoy up to 50% off select styles.",
"id": "39",
"exclusive": false
},
{
"title": "LULULEMON",
"avatar": "https://cdn.modesens.com/logo/lululemon-logo.png?w=400",
"description": "Enjoy up to 50% off select Men's shoes & accessories.",
"id": "40",
"exclusive": true
},
{
"title": "NEIMANMARCUS",
"avatar": "https://cdn.modesens.com/merchant/neiman_marcus-1470104251?w=400",
"description": "Get up to a $300 gift card with your select reg-price purchase of $200. Use code BONUS",
"id": "41",
"exclusive": false
},
{
"title": "HARRODS",
"avatar": "https://cdn.modesens.com/merchant/harrods-1470104242?w=400",
"description": "Enjoy up to 25% off select styles + 20% off select items.",
"id": "42",
"exclusive": false
},
{
"title": "THEOUTNET",
"avatar": "https://cdn.modesens.com/merchant/the-outnet_20181229.png?w=400",
"description": "Enjoy an extra 15% off your first clothing orders. Use code FIRST15",
"id": "43",
"exclusive": false
},
{
"title": "SHOPBOP",
"avatar": "https://cdn.modesens.com/merchant/shopbop.png?w=400",
"description": "Take advantage of free shipping.",
"id": "44",
"exclusive": true
},
{
"title": "SAKS",
"avatar": "https://cdn.modesens.com/merchant/saks_newlogo.png?w=400",
"description": "Saks Holiday Gift Guide: Brilliant Gifts for Everyone.",
"id": "45",
"exclusive": false
},
{
"title": "RAMYBROOK",
"avatar": "https://cdn.modesens.com/merchant/RamyBrookLogo.png?w=400",
"description": "Enjoy an extra 10% off sale styles. Use code EXTRA10",
"id": "46",
"exclusive": false
},
{
"title": "ROBERTGRAHAM",
"avatar": "https://cdn.modesens.com/merchant/robert-graham.png?w=400",
"description": "Take advantage of free shipping.",
"id": "47",
"exclusive": false
},
{
"title": "TORYBURCH",
"avatar": "https://cdn.modesens.com/merchant/TB_S17_LOGO_125X125.jpg?w=400",
"description": "Shop the holiday collection.",
"id": "48",
"exclusive": false
},
{
"title": "ITALIST",
"avatar": "https://cdn.modesens.com/merchant/italist_logo.png?w=400",
"description": "Save up to 65% off on FW22 collections. Limited time only.",
"id": "49",
"exclusive": false
},
{
"title": "LACOSTE",
"avatar": "https://cdn.modesens.com/merchant/lacoste-logo.jpg?w=400",
"description": "Enjoy up to 50% off sitewide + free shipping.",
"id": "50",
"exclusive": true
},
{
"title": "FRYE",
"avatar": "https://cdn.modesens.com/merchant/frye-logo.jpeg?w=400",
"description": "Enjoy up to 50% off sitewide + free shipping.",
"id": "51",
"exclusive": false
},
{
"title": "STUARTWIETZMAN",
"avatar": "https://cdn.modesens.com/merchant/sw_logo.jpg?w=400",
"description": "Enjoy an extra 20% off sale styles + free shipping. Use code OUTLETHOLIDAY20",
"id": "52",
"exclusive": false
},
{
"title": "MACYS",
"avatar": "https://cdn.modesens.com/merchant/macy%27s-1471663845?w=400",
"description": "Get a free 5-pc gift set with any $50 Lancôme purchase.",
"id": "53",
"exclusive": false
},
{
"title": "MRPORTER",
"avatar": "https://cdn.modesens.com/merchant/mr_porter-1473686485?w=400",
"description": "Enjoy up to 50% off select styles.",
"id": "54",
"exclusive": false
},
{
"title": "BERNARDELLI",
"avatar": "https://cdn.modesens.com/merchant/bernardelli_logo.png?w=400",
"description": "Take advantage of free shipping.",
"id": "55",
"exclusive": true
},
{
"title": "BELSTAFF",
"avatar": "https://cdn.modesens.com/merchant/belstaff-logo.png?w=400",
"description": "Enjoy up to 60% off select styles.",
"id": "56",
"exclusive": false
},
{
"title": "NIKE",
"avatar": "https://cdn.modesens.com/merchant/nike-1473686485?w=400",
"description": "Enjoy an extra 15% off sitewide. Use code EXTRA15",
"id": "57",
"exclusive": true
},
{
"title": "BOMBAS",
"avatar": "https://cdn.modesens.com/merchant/bombas_logo.jpg?w=400",
"description": "Take advantage of free shipping on orders of $70+, and free returns on all orders.",
"id": "58",
"exclusive": false
},
{
"title": "FINISHLINE",
"avatar": "https://cdn.modesens.com/merchant/finish_line.png?w=400",
"description": "Enjoy 15% off your first order. Use code HELLO15",
"id": "59",
"exclusive": false
},
{
"title": "DIOR",
"avatar": "https://cdn.modesens.com/merchant/dior_logo.jpeg?w=400",
"description": "Take advantage of free shipping on orders of $99+.",
"id": "60",
"exclusive": true
}
];
let giftDealContainer= document.querySelector(".gift-deals");
let bestSellersContainer= document.querySelector(".best-sellers-data");
window.addEventListener("load", ()=>{
renderGiftDeals(salesBanners);
renderBestSellers(bestSellers);
});
function renderGiftDeals(data) {
giftDealContainer.innerHTML="";
let newBannerData=data.map((item)=>{
return `
<div class="gift-deals-div hover-pointer">
<img
src=${item}
alt="Banner"
/>
</div>
`
});
giftDealContainer.innerHTML= newBannerData.join("");
};
function renderBestSellers(data){
bestSellersContainer.innerHTML="";
let newBestSellerData=data.map((item)=>{
return `
<div class="seller-div hover-pointer">
<div class="seller-logo">
<img alt="SELLER LOGO" src=${item.avatar}/>
</div>
<div class="seller-desc">
<div>
<h5>${item.description}</h5>
</div>
<div class="seller-desc-buttons">
<div>
${item.exclusive ? `<button class="hover-pointer"> EXCLUSIVE </button>`: ""}
</div>
<div>
<button class="hover-pointer"> SHOP NOW </button>
<button class="hover-pointer share-click">
<img alt="SHARE LOGO" src="https://cdn.modesens.com/static/img/20190805Vector.svg" />
</button>
</div>
</div>
</div>
</div>
`
});
bestSellersContainer.innerHTML= newBestSellerData.join("");
/*----------------------Share popup Functionality----------------------*/
let shareBtns=document.querySelectorAll(".share-click");
for(let shareBtn of shareBtns){
shareBtn.addEventListener("click", (e)=>{
let sharePopup=document.querySelector(".share-popup");
sharePopup.classList.remove("share-popup-hide");
})
}
let shareClose=document.querySelector(".share-popup-close");
shareClose.addEventListener("click",(e)=>{
let sharePopup=document.querySelector(".share-popup");
sharePopup.classList.add("share-popup-hide");
})
}
/*---------------------Div switch functionality------------------*/
let giftDealsClick=document.querySelector(".gift-deals-click");
giftDealsClick.addEventListener("click",(e)=>{
//console.log(e);
e.target.classList.add("gift-header-default");
e.path[1].children[1].classList.remove("gift-header-default");
e.path[2].children[1].children[1].classList.add("gift-hide");
e.path[2].children[1].children[0].classList.remove("gift-hide");
})
let giftGuideClick=document.querySelector(".gift-guide-click");
giftGuideClick.addEventListener("click",(e)=>{
//console.log(e);
e.target.classList.add("gift-header-default");
e.path[1].children[0].classList.remove("gift-header-default");
e.path[2].children[1].children[0].classList.add("gift-hide");
e.path[2].children[1].children[1].classList.remove("gift-hide");
})
/*----------------------Search Functionality----------------------*/
let searchTag=document.querySelector(".search-div>input");
let exclusiveData,filteredData;
searchTag.addEventListener("input",()=>{
let inputValue=searchTag.value;
if(exclusiveData){
filteredData=exclusiveData.filter((item)=>{
return item.title.toLowerCase().includes(inputValue.toLowerCase());
})
}else{
filteredData=bestSellers.filter((item)=>{
return item.title.toLowerCase().includes(inputValue.toLowerCase());
})
}
renderBestSellers(filteredData);
});
searchTag.addEventListener("click", (e)=>{
//console.log(e);
let searchdiv=e.path[1];
if(searchdiv.classList[1]){
searchdiv.classList.remove("box-shadow");
}else{
searchdiv.classList.add("box-shadow");
}
})
/*----------------------Filter Functionality----------------------*/
let filterBtn=document.querySelector(".exc-filter");
let click=0;
filterBtn.addEventListener("click",(e)=>{
//console.log(e);
click++;
if(filteredData){
exclusiveData=filteredData.filter((item)=>{
return item.exclusive;
})
}else{
exclusiveData=bestSellers.filter((item)=>{
return item.exclusive;
})
}
if(click%2==1){
e.path[0].innerHTML=`
EXCLUSIVE OFFERS
<img alt="filter logo" src="https://cdn.modesens.com/static/img/checkmark.svg"/>
`
filterBtn.style.backgroundColor="red";
filterBtn.style.border="none";
renderBestSellers(exclusiveData);
}else{
e.path[0].innerHTML=`
EXCLUSIVE OFFERS
<img alt="filter logo" src="https://cdn.modesens.com/static/img/filter_icon.svg"/>
`
filterBtn.style.backgroundColor="white";
filterBtn.style.border="1px solid black";
exclusiveData=[...bestSellers];
if(filteredData){
renderBestSellers(filteredData);
}else{
renderBestSellers(bestSellers);
}
}
});