-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
629 lines (532 loc) · 25.5 KB
/
script.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
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
let num_cards_GLOBAL = 13;
let cards = [
{
background:
"https://dnm.nflximg.net/api/v6/6gmvu2hxdfnQ55LZZjyzYR4kzGk/AAAABSYU9D1vUihV9T-ytOeuk19uG6brgkHBSBpQ4NH9PgkPakFTSwOaXCpjm8Iie9kUuBLJzWrXF5bUBjDSJ9fA1dVoqgUetFXLzbZ9eWaLEj7bh8sz6hzMex1Fsr9VIbJd15VC_Q.jpg?r=545",
display_background:
"//external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fhdqwalls.com%2Fdownload%2Finterstellar-gargantua-u4-1920x1080.jpg&f=1&nofb=1",
title: "Heart of stone",
description:
"Watch this incredible film made by some incredible people!"
},
{
background: "https://images.alphacoders.com/586/thumb-1920-586902.jpg",
display_background:
"//external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fimages2.alphacoders.com%2F845%2F84502.jpg&f=1&nofb=1",
title: "Inception",
description: "Top 10 in Films in 93 countries on Netflix"
},
{
background:
"https://dnm.nflximg.net/api/v6/6gmvu2hxdfnQ55LZZjyzYR4kzGk/AAAABZ5l6n7RDUh96fXwby3sSanvLiB0QVo6uzJB3-sJhGu3LcVueTIBZ3Iq8PQujZvYYTDOmiOv9W2HjY4HSK-qSROR8DVhiwL7YvXRdUle7gPpp5KLvZAehtwLP8m_S8sEoRblNw.jpg?r=5d9",
display_background:
"//external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fimages7.alphacoders.com%2F990%2F990610.jpg&f=1&nofb=1",
title: "The Monkey King",
description: "Top 10 in Films in 25 countries on Netflix"
},
{
background:
"//external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fimages.wallpapersden.com%2Fimage%2Fdownload%2Fjoker-2019-movie_66632_1920x1080.jpg&f=1&nofb=1",
display_background:
"//external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fimages.wallpapersden.com%2Fimage%2Fdownload%2Fjoker-stair-dance_68124_1920x1080.jpg&f=1&nofb=1",
title: "Joker",
description:
"Watch this incredible film made by some incredible people!"
},
{
background:
"https://dnm.nflximg.net/api/v6/6gmvu2hxdfnQ55LZZjyzYR4kzGk/AAAABfrvcpx-Q9U2aKoSRl3SQ3QVlz0rj-OpcD8OdhMQ59zmWgixgP_Tou697lJYzXXLmvzVVggLiFTlC2iH-OJJm0OD6l0Brca2QysB.jpg?r=947",
title: "The Pope's Exorcist",
description: "Top 10 in Films in 60 countries on Netflix"
},
{
background:
"https://dnm.nflximg.net/api/v6/6gmvu2hxdfnQ55LZZjyzYR4kzGk/AAAABfGb_wbvARRan1YHi8E3mCm-r2Zt2shb4565Z8UF6s6mQee3v1AfZCm53SgJg2XfdoIuhgmjUSN4gQ7RG5-3GnUB6A6UIxBm_eeP.jpg?r=e9c",
title: "Half Brothers",
description:
"Watch this incredible film made by some incredible people!"
},
{
background:
"https://dnm.nflximg.net/api/v6/6gmvu2hxdfnQ55LZZjyzYR4kzGk/AAAABQ3qYic28AqhCjFiSskhK3aHx9UP69-lXbifQF7B_Fo4gveIK6D2nAvz2HP87HTNOryk7Aqn-0HHw6RiqYY4XAev9pjnAXnrNLAH.jpg?r=136",
title: "Hidden Strike",
description:
"Watch this incredible film made by some incredible people!"
},
{
background:
"https://dnm.nflximg.net/api/v6/6gmvu2hxdfnQ55LZZjyzYR4kzGk/AAAABfh2CnqaJOjlCx5u3Zr_X40zkgsRE-rk0fbXxD2bhouuqzRmCo89S8FPFre8xdH0iteatSRj4WUeOQTBufg0vZ4q_FaImHVl6G22wLipYghcZuuIBZiku6-0Tu100eXRdItQuA.jpg?r=fb9",
title: "Miraculous: Ladybug & Cat Noir, The Movie",
description:
"Watch this incredible film made by some incredible people!"
},
{
background:
"https://dnm.nflximg.net/api/v6/6gmvu2hxdfnQ55LZZjyzYR4kzGk/AAAABXUB1iiHrbXy1jSa4Plx4a2EKs88e2NBtUZGu-NS7o4cUMA71u4PSZbAR04nV1TQsPyBGgiBIPu9VcU4Umx0xruelFvVjASIgJ10.jpg?r=0b5",
title: "What Men Want",
description:
"Watch this incredible film made by some incredible people!"
},
{
background:
"https://dnm.nflximg.net/api/v6/BvVbc2Wxr2w6QuoANoSpJKEIWjQ/AAAAQR-450XxrmmWOXwRWX_XdMJ4LOBoXhP-jbqRydNaODbNoAtQ7KWyVGd3h0LRT6eHwS-NTonfEVGGf2HLciCpvIdvItbDk90QEE-Fv0eiAuYNuZkBK1SXcE6cE6MvDBGaDkWIBTi7_4A5f_Oj70iZPwILQYs.jpg?r=f2e",
title: "Emily in Paris",
description:
"Watch this incredible film made by some incredible people!"
},
{
background:
"https://dnm.nflximg.net/api/v6/BvVbc2Wxr2w6QuoANoSpJKEIWjQ/AAAAQVWa2OZ5w6Zl1djw1yE4n_8NCqh2dcKXGZWYfZuFTd3HD53LwLdB_XAoRf3apPfKvzF8GuSQO4V9Ub2Qg_MtiT4pjHSWn8gZBk5i986IpiD8GiCmIGpyJ4bfWfVPk6z77tNrFb1CDWMH_8r9LwvSPRMY558.jpg?r=c9d",
title: "The Witcher",
description:
"Watch this incredible film made by some incredible people!"
},
{
background:
"https://dnm.nflximg.net/api/v6/BvVbc2Wxr2w6QuoANoSpJKEIWjQ/AAAAQZgwCOJGI1jJ_brmLfmfnPGWTiUwyKZpfsIwQJeulV6xqi2ln0yvzjqzRQHylRq6M7hAQFr_eSDpdbfh33ETdPVU_p5pNzZv7gC90olgS9J-RCuoIAGNj-YohuD3BVBQz9u3XWZu4U8oSoU-1qfeoD9zzgQ.jpg?r=7e0",
title: "The Lincoln Lawyer",
description:
"Watch this incredible film made by some incredible people!"
},
{
background:
"https://dnm.nflximg.net/api/v6/6gmvu2hxdfnQ55LZZjyzYR4kzGk/AAAABUbKiSxf1KHLIn3uteualUubd_VeRSbYbHJfNmIb6JeSkVKpiLXCTZZuX7wfKJww3cs2nYmVmxrLJKKHE6AYb2bfA96jxaVuUrEw6rn2V0X2ZZ2TgbeuESpsmUq2EpBVxX0_PA.jpg?r=f79",
title: "Untold: Hall of Shame",
description:
"Watch this incredible film made by some incredible people!"
}
];
let cast = [
{
picture:
"//external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fi.scdn.co%2Fimage%2F338040ea81df8012c152cfa65a4c1b440a94a1bc&f=1&nofb=1",
square: 1000,
name: "Will Smith"
},
{
picture:
"//external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fsiskiyou.sou.edu%2Fwp-content%2Fuploads%2F2014%2F10%2FRobin.jpg&f=1&nofb=1",
square: 2000,
name: "Robin Williams"
},
{
picture:
"//external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fwww.byrdie.com%2Fthmb%2FaSjYcUqubm-ucpugLMuN8m-nvdU%3D%2F796x700%2Ffilters%3Ano_upscale()%3Amax_bytes(150000)%3Astrip_icc()%2Fcdn.cliqueinc.com__cache__posts__237400__jennifer-lawrence-hairstyles-237400-1506716140954-main.700x0c-af3f438528ea44f0aa9c3c1fe3ef8c64.jpg&f=1&nofb=1",
square: 700,
name: "Jennifer Lawrence"
}
];
const IsMobile = () => {
let width =
window.innerWidth ||
document.documentElement.clientWidth ||
document.getElementsByTagName("body")[0].clientWidth;
if (width <= 736) {
return true;
} else {
return false;
}
};
const CheckSizeAttributes = () => {
let width =
window.innerWidth ||
document.documentElement.clientWidth ||
document.getElementsByTagName("body")[0].clientWidth;
let carousels = document.getElementsByClassName("card-carousel");
let old_num_cards = num_cards_GLOBAL;
let new_num_cards;
if (width > 1501) {
new_num_cards = 6;
} else if (width <= 1500 && width > 1100) {
new_num_cards = 5;
} else if (width <= 1100 && width > 520) {
new_num_cards = 4;
} else if (width <= 520) {
new_num_cards = 4;
}
for (let i = 0; i < carousels.length; i++) {
if (carousels[i].children.length > 2) {
for (let j = 1; j < carousels[i].children.length - 1; j++) {
carousels[i].children[j].style.display = "none";
}
for (let j = 1; j < new_num_cards + 1; j++) {
carousels[i].children[j].style.display = "flex";
}
}
}
num_cards_GLOBAL = new_num_cards;
};
const ResizeHeader = () => {
let width =
window.innerWidth ||
document.documentElement.clientWidth ||
document.getElementsByTagName("body")[0].clientWidth;
if (width <= 815) {
if (document.getElementsByClassName("hamburger").length <= 0) {
let header = document.getElementsByClassName("header")[0];
let main_nav = header.getElementsByClassName("main-nav")[0];
let right_nav = header.getElementsByClassName("right-nav")[0];
let hamburger = document.createElement("div");
hamburger.classList.add("hamburger");
hamburger.innerHTML = `<svg fill="currentColor" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5z"/>
</svg>`;
main_nav.remove();
right_nav.remove();
let bottom_header = document.createElement("div");
bottom_header.classList.add("header-bottom");
bottom_header.append(main_nav, right_nav);
bottom_header.style.display = "none";
hamburger.addEventListener("click", function () {
if (bottom_header.style.display == "none") {
bottom_header.style.display = "flex";
header.style.paddingBottom = "9px";
header.style.paddingTop = "9px";
} else {
bottom_header.style.display = "none";
header.style.paddingBottom = "0px";
header.style.paddingTop = "0px";
}
});
header.classList.add("header-change");
let top_header = document.createElement("div");
top_header.classList.add("header-top");
top_header.append(header.children[0], hamburger);
header.innerHTML = "";
header.append(top_header, bottom_header);
}
} else {
if (document.getElementsByClassName("hamburger").length > 0) {
let header = document.getElementsByClassName("header")[0];
let main_nav = header.getElementsByClassName("main-nav")[0];
let right_nav = header.getElementsByClassName("right-nav")[0];
let brand = header.getElementsByClassName("brand")[0];
header.classList.remove("header-change");
header.children[0].remove();
header.children[0].remove();
header.append(brand, main_nav, right_nav);
}
}
};
const AddCards = () => {
let carousel_width = document.getElementsByClassName("card-carousel")[0]
.clientWidth;
let btn_width =
document.getElementsByClassName("carousel-btn")[0].clientWidth +
document.getElementsByClassName("carousel-btn")[1].clientWidth;
let num_cards = num_cards_GLOBAL;
let card_margin = 2;
let initial_width = 1920;
let initial_height = 1080;
let scale =
(100 * ((carousel_width - btn_width) / num_cards - card_margin * 2)) /
initial_width;
let content_titles = document.getElementsByClassName("content-title");
for (let i = 0; i < content_titles.length; i++) {
content_titles[i].style.marginLeft = `${card_margin}px`;
}
let carousels = document.getElementsByClassName("card-carousel");
for (let i = 0; i < carousels.length; i++) {
let not_chosen = [];
for (let c = 0; c < cards.length; c++) {
not_chosen.push(c);
}
for (let j = 0; j < cards.length; j++) {
let chosen_index = Math.floor(Math.random() * not_chosen.length);
let chosen_card = cards[not_chosen[chosen_index]];
not_chosen.splice(chosen_index, 1);
let card = document.createElement("div");
card.classList.add("card");
card.style.backgroundImage = `url(${chosen_card.background})`;
//If image doesn't load
card.style.backgroundColor = `#333`;
card.style.width = initial_width * (scale / 100) + "px";
card.style.height = initial_height * (scale / 100) + "px";
card.style.margin = `0px ${card_margin}px`;
card.style.minWidth = initial_width * (scale / 100) + "px";
card.style.minHeight = initial_height * (scale / 100) + "px";
let overlay = document.createElement("div");
overlay.classList.add("overlay");
let title = document.createElement("h4");
title.innerText = chosen_card.title;
let description = document.createElement("p");
description.innerText = "1h 25m";
let button_container = document.createElement("div");
button_container.classList.add("button-container");
let button1 = document.createElement("div");
button1.innerHTML = `<svg fill="currentColor" viewBox="0 0 16 16">
<path d="m11.596 8.697-6.363 3.692c-.54.313-1.233-.066-1.233-.697V4.308c0-.63.692-1.01 1.233-.696l6.363 3.692a.802.802 0 0 1 0 1.393z"/>
</svg>`;
button1.classList.add("watch");
let button2 = document.createElement("div");
button2.innerHTML = `<svg fill="currentColor" viewBox="0 0 16 16">
<path d="M8 3.5a.5.5 0 0 0-1 0V9a.5.5 0 0 0 .252.434l3.5 2a.5.5 0 0 0 .496-.868L8 8.71V3.5z"/>
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm7-8A7 7 0 1 1 1 8a7 7 0 0 1 14 0z"/>
</svg>`;
button2.classList.add("queue");
button2.addEventListener("click", function () {
ToggleWatchLater(`${chosen_card.title}`);
});
let button3 = document.createElement("div");
button3.innerHTML = `<svg fill="currentColor" viewBox="0 0 16 16">
<path d="M3.612 15.443c-.386.198-.824-.149-.746-.592l.83-4.73L.173 6.765c-.329-.314-.158-.888.283-.95l4.898-.696L7.538.792c.197-.39.73-.39.927 0l2.184 4.327 4.898.696c.441.062.612.636.282.95l-3.522 3.356.83 4.73c.078.443-.36.79-.746.592L8 13.187l-4.389 2.256z"/>
</svg>`;
button3.classList.add("star");
button3.classList.add("queue");
button3.addEventListener("click", function () {
if (button3.children[0].style.color != "rgb(255, 255, 87)") {
button3.children[0].style.color = "rgb(255, 255, 87)";
} else {
button3.children[0].style.color = "white";
}
});
let button4 = document.createElement("div");
button4.innerHTML = `<svg fill="currentColor" viewBox="0 0 16 16">
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
<path d="m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"/>
</svg>`;
button4.classList.add("star");
button4.classList.add("queue");
button4.addEventListener("click", function () {
if (document.getElementsByClassName("movie-desc").length > 0) {
// If the modal exists
document.getElementsByClassName("movie-desc")[0].remove();
} else {
let modal = document.createElement("div");
modal.classList.add("movie-desc");
let modal_content = document.createElement("div");
modal_content.classList.add("modal-content");
let bg_image = document.createElement("div");
bg_image.classList.add("desc-image");
bg_image.style.backgroundImage = `url(${chosen_card.background})`;
let image_cover = document.createElement("div");
let close_btn = document.createElement("div");
close_btn.classList.add("close-btn");
close_btn.innerHTML = `<svg fill="currentColor" viewBox="0 0 16 16">
<path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"/>
</svg>`;
close_btn.addEventListener("click", function () {
this.parentElement.parentElement.parentElement.parentElement.remove();
});
image_cover.append(close_btn);
bg_image.append(image_cover);
let top_info = document.createElement("div");
top_info.classList.add("desc-top");
let title = document.createElement("h1");
title.innerText = chosen_card.title;
let btn_selection = document.createElement("div");
btn_selection.classList.add("button-selection");
btn_selection.innerHTML = `
<div class="watch">
<h3>Play</h3>
<svg fill="currentColor" viewBox="0 0 16 16">
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z" />
<path d="M6.271 5.055a.5.5 0 0 1 .52.038l3.5 2.5a.5.5 0 0 1 0 .814l-3.5 2.5A.5.5 0 0 1 6 10.5v-5a.5.5 0 0 1 .271-.445z" />
</svg>
</div>
<div class="queue" onclick="ToggleWatchLater('${chosen_card.title}');">
<h3>Watch Later</h3>
<svg fill="currentColor" viewBox="0 0 16 16">
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z" />
<path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z" />
</svg>
</div>`;
top_info.append(title, btn_selection);
let mid_info = document.createElement("div");
mid_info.classList.add("desc-mid");
mid_info.innerHTML = `<p>${chosen_card.description}</p>`;
let bottom_info = document.createElement("div");
bottom_info.classList.add("desc-bottom");
let cast_slider = document.createElement("div");
cast_slider.classList.add("cast");
bottom_info.append(cast_slider);
modal_content.append(
bg_image,
top_info,
mid_info,
bottom_info
);
modal.append(modal_content);
document.body.append(modal);
document.body.addEventListener("click", function (event) {
if (!event.target.classList.contains("modal-content")) {
//modal.remove();
console.log(1);
}
});
// Set the height for the modal image
let total_width = document.getElementsByClassName(
"modal-content"
)[0].clientWidth;
let large_scale = (100 * total_width) / 1920;
document.getElementsByClassName(
"desc-image"
)[0].style.height = `${1080 * (large_scale / 100)}px`;
// Set image for cast
for (let c = 0; c < cast.length; c++) {
let cast_block = document.createElement("div");
cast_block.classList.add("cast-card");
cast_block.style.backgroundImage = `url("${cast[c].picture}")`;
cast_block.style.width = 100 / cast.length - 5 + "%";
cast_block.style.height = `calc(${
document.getElementsByClassName("cast")[0]
.clientWidth / cast.length
}"px" - 5%)`;
cast_slider.append(cast_block);
}
}
});
button_container.append(button1, button2, button3, button4);
overlay.append(title, description, button_container);
card.append(overlay);
if (j < num_cards) {
carousels[i].insertBefore(
card,
carousels[i].children[carousels[i].children.length - 1]
);
} else {
card.style.display = "none";
carousels[i].insertBefore(
card,
carousels[i].children[carousels[i].children.length - 1]
);
}
}
}
};
const CheckCards = () => {
let carousels = document.getElementsByClassName("card-carousel");
for (let i = 0; i < carousels.length; i++) {
let carousel_width = carousels[i].clientWidth;
let btn_width =
carousels[i].getElementsByClassName("carousel-btn")[0].clientWidth +
carousels[i].getElementsByClassName("carousel-btn")[1].clientWidth;
let num_cards = num_cards_GLOBAL;
let card_margin = 2;
let initial_width = 1920;
let initial_height = 1080;
let scale =
(100 *
((carousel_width - btn_width) / num_cards - card_margin * 2)) /
initial_width;
let cards = carousels[i].getElementsByClassName("card");
for (let i = 0; i < cards.length; i++) {
cards[i].style.width = initial_width * (scale / 100) + "px";
cards[i].style.height = initial_height * (scale / 100) + "px";
cards[i].style.margin = `0px ${card_margin}px`;
cards[i].style.minWidth = initial_width * (scale / 100) + "px";
cards[i].style.minHeight = initial_height * (scale / 100) + "px";
}
if (IsMobile()) {
carousels[i].style.height =
1.6 * (initial_height * (scale / 100)) + "px";
} else {
carousels[i].style.height = "auto";
}
}
};
const AddCarouselButtons = () => {
let carousels = document.getElementsByClassName("card-carousel");
for (let i = 0; i < carousels.length; i++) {
let btn1 = document.createElement("div");
btn1.classList.add("carousel-btn");
btn1.innerHTML = `<svg fill="currentColor" viewBox="0 0 16 16" onclick="Previous(this);">
<path fill-rule="evenodd" d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z"/>
</svg>`;
let btn2 = document.createElement("div");
btn2.classList.add("carousel-btn");
btn2.innerHTML = `<svg fill="currentColor" viewBox="0 0 16 16" onclick="Next(this);">
<path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/>
</svg>`;
carousels[i].append(btn1, btn2);
}
};
const ScrollFunction = () => {
let header = document.getElementsByClassName("header")[0];
if (document.documentElement.scrollTop > 1) {
header.classList.add("header-active");
} else {
header.classList.remove("header-active");
}
};
const MakeJumbotron = () => {
let height =
window.innerHeight ||
document.documentElement.clientHeight ||
document.getElementsByTagName("body")[0].clientHeight;
document.getElementsByClassName("top")[0].style.height = `${height}px`;
};
let slide_index = 0;
const AutoSlideShow = () => {
let slide_area = document.getElementsByClassName("top")[0];
let container = slide_area.children[0];
container.classList.add("fadeIn");
let bg_display = [];
for (let i = 0; i < cards.length; i++) {
if (cards[i].display_background) {
bg_display.push(i);
}
}
slide_index++;
if (slide_index > bg_display.length - 1) {
slide_index = 0;
}
slide_area.style.backgroundImage = `url("${
cards[bg_display[slide_index]].display_background
}")`;
slide_area.getElementsByTagName("h1")[0].innerHTML =
cards[bg_display[slide_index]].title;
slide_area.getElementsByTagName("p")[0].innerHTML =
cards[bg_display[slide_index]].description;
container.classList.add("fadeOut");
setTimeout(AutoSlideShow, 2000);
};
const SmoothScroll = (id) => {
let element = document.getElementById(id);
element.scrollIntoView({ behavior: "smooth", block: "center" });
};
const Next = (elem) => {
let carousel = elem.parentElement.parentElement;
let first_elem = carousel.children[1];
let next_elem;
for (let i = 0; i < carousel.children.length; i++) {
if (carousel.children[i].style.display == "none") {
next_elem = carousel.children[i];
break;
}
}
first_elem.style.display = "none";
first_elem.remove();
carousel.insertBefore(
first_elem,
carousel.children[carousel.children.length - 1]
);
next_elem.style.display = "flex";
};
const Previous = (elem) => {
let carousel = elem.parentElement.parentElement;
let last_display_item;
let prev_elem = carousel.children[carousel.children.length - 2];
for (let i = 0; i < carousel.children.length; i++) {
if (
carousel.children[i].style.display != "none" &&
!carousel.children[i].classList.contains("carousel-btn")
) {
last_display_item = carousel.children[i];
}
}
last_display_item.style.display = "none";
carousel.insertBefore(prev_elem, carousel.children[1]);
prev_elem.style.display = "flex";
};
const ToggleWatchLater = (movie = "", activate = true) => {
let modal = document.getElementsByClassName("watch-later-modal")[0];
if (movie != "") {
modal.getElementsByClassName("movie")[0].innerText = movie;
}
if (activate) {
modal.style.display = "flex";
} else {
modal.style.display = "none";
}
};