-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathskilljar-theme-v2.js
3479 lines (3036 loc) · 126 KB
/
skilljar-theme-v2.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
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
let currentView = "";
let isCatalogPage,
isCurriculumPage,
isCourseDetailsPage,
isPageDetailPath,
isPageCatalogPath,
isLessonsPage,
isLoginPage,
isSignUpPage;
let initialLoadComplete = false;
let globalCurriculumSection, globalAboutSection;
function checkWindowWidth() {
return (
window.innerWidth ||
document.documentElement.clientWidth ||
document.body.clientWidth
);
}
function getCurrentPage() {
//THIS FUNCTION SEEMS TO JUST REWRITE THE GLOBAL VARS
isCatalogPage = document.querySelector(
".sj-page-catalog.sj-page-catalog-root"
)
? true
: false;
isCurriculumPage = document.querySelector(".sj-page-curriculum")
? true
: false;
isCourseDetailsPage = document.querySelector(
".sj-page-detail.sj-page-detail-course"
)
? true
: false;
isLessonsPage = document.querySelector(".sj-page-lesson") ? true : false;
isLoginPage = document.querySelector(".sj-page-login") ? true : false;
isSignUpPage = document.querySelector(".sj-page-signup") ? true : false;
//PATH PAGES
isPageDetailPath = document.querySelector(
".sj-page-detail.sj-page-detail-bundle.sj-page-detail-path"
)
? true
: false;
isPageCatalogPath = document.querySelector(
".sj-page-catalog.sj-page-series.sj-page-path"
)
? true
: false;
}
function getWidthAndCurrentPage() {
return {
width: checkWindowWidth(),
currentPage: getCurrentPage(),
};
}
function makeContentVisible() {
const body = document.querySelector("body");
if (!body.classList.contains("sj-page-catalog")) {
body.setAttribute(
"style",
"visibility: visible !important; opacity: 1 !important"
);
}
}
function insertFooter(isLessonsPage = false) {
const footerEl = document.getElementById("footer-container");
let contentContainer;
if (isLessonsPage) {
contentContainer = document.querySelector(".sj-page-lesson");
if (currentView === "mobile") {
footerEl.style.display = "none";
} else {
footerEl.style.display = "flex";
}
} else {
contentContainer = document.getElementById("skilljar-content");
footerEl.style.display = "flex";
}
contentContainer.append(footerEl);
}
function removeSJFooter(isLessonsPage = false) {
if (!isLessonsPage) {
document.getElementById("ep-footer").style.display = "none";
}
}
//DESTOP VIEW STYLINGS
function desktopCatalogPageStyling() {
//grab variables
const catalogBodyParentContainer = document.getElementById("catalog-content");
const catalogContainer = document.getElementById("catalog-courses");
if (!initialLoadComplete) {
//create container div for courses catalog list
const catalogContentContainer = document.createElement("div");
catalogContentContainer.style.maxWidth = "min(1232px, 90%)";
catalogContentContainer.style.margin = "96px auto";
//create header for list
const allCoursesHeader = document.createElement("h2");
allCoursesHeader.textContent = "All Courses";
allCoursesHeader.style.fontSize = "48px";
allCoursesHeader.style.marginBottom = "38px";
catalogContentContainer.append(allCoursesHeader, catalogContainer);
catalogBodyParentContainer.append(catalogContentContainer);
initialLoadComplete = true;
}
}
function desktopCourseDetailsPageStyling() {
const headerContainer = document.querySelector(
".top-row-grey.top-row-white-v2.padding-top.padding-side.row-v2"
);
const headerFlexContainer = document.querySelector(".row.dp-row-flex-v2");
const headingFloaterText = document.querySelector(".sj-floater-text");
const mainHeading = document.querySelector(".break-word");
const registerBtn = document.getElementById("purchase-button-wrapper-large");
const mainHeadingContainer = document.querySelector(
".columns.text-center.large-6.dp-summary-wrapper.text-left-v2"
);
const mainVideoContainer = document.querySelector(
".columns.large-6.text-center.dp-promo-image-wrapper"
);
const backToCatalogBtn = document.querySelector(".back-to-catalog");
const videoContainer = document.querySelector(".video-max");
const mainInfoCardContained = document.querySelector(
".sj-course-info-wrapper"
);
const headingParagraph = mainInfoCardContained.querySelector("h2");
//SIGN IN VARIABLES (WHEN USER NOT LOGGED IN)
const signInHeaderText = document.querySelector(".signin");
const signInBtn = document.querySelector(
".header-link.login-link.sj-text-sign-in.focus-link-v2"
);
////BODY VARIABLES
const bodyContainer = document.getElementById("dp-details");
const mobileBodyContent = document.querySelector(".row.show-for-small");
const secondaryBodyContainer = document.querySelector(
".row.hide-for-small.padded-side-bottom"
);
const bodyColumns = secondaryBodyContainer.querySelectorAll(".columns");
const curriculumListContainer = document.querySelector(".dp-curriculum"); //NOTE: THERE ARE 2 DP-CURRICULUMS. ONE IS DESKTOP AND OTHER IS FOR MOBILE (STILL TABED)!
const curriculumListHeader = curriculumListContainer
.closest(".sj-curriculum-wrapper")
.querySelector("h3");
const curriculumList = curriculumListContainer.querySelectorAll("li");
////CARD VARIABLES
const courseDetailCardContainer = secondaryBodyContainer.querySelector(
".course-details-card"
);
let courseDetailCardListItems;
if (courseDetailCardContainer) {
courseDetailCardListItems =
courseDetailCardContainer.querySelectorAll("li");
}
const checkboxIcon = document.querySelector(".checkbox-icon");
const registerBtnLink = document
.getElementById("purchase-button")
.getAttribute("href");
const registerBtnText = document.querySelector(
".purchase-button-full-text"
).textContent;
const courseDetailsCardLink = document.querySelector(
".course-details-card-link"
);
backToCatalogBtn.style.display = "none";
mobileBodyContent.style.display = "none";
if (signInHeaderText) {
signInHeaderText.style.display = "none";
signInBtn.style.backgroundColor = "transparent";
signInBtn.style.padding = "8px 12px";
signInBtn.style.marginRight = "24px";
signInBtn.style.borderColor = "#3443F4";
signInBtn.style.border = "2px solid #3443F4";
signInBtn.style.borderRadius = "999px";
signInBtn.style.fontSize = "14px";
signInBtn.style.fontFamily = "Space Mono";
signInBtn.style.fontWeight = "700";
signInBtn.style.lineHeight = "20px";
}
headerContainer.style.backgroundColor = "#D0CFEE";
headerContainer.style.margin = "0";
headerContainer.style.maxWidth = "none";
headerContainer.style.paddingTop = "96px";
headerContainer.style.paddingBottom = "96px";
headerContainer.style.border = "0";
headerFlexContainer.style.flexDirection = "row-reverse";
headerFlexContainer.style.flexWrap = "nowrap";
headerFlexContainer.style.justifyContent = "start";
headerFlexContainer.style.gap = "24px";
headerFlexContainer.style.maxWidth = "1188px";
//RENDERING OF COURSE DETAILS PAGE TEXT HEADING ON LEFT
mainHeadingContainer.style.border = "0";
mainHeadingContainer.style.maxWidth = "564px";
mainInfoCardContained.style.display = "none";
headingFloaterText.style.display = "block";
headingFloaterText.style.marginBottom = "24px";
mainHeading.style.margin = "0 0 12px 0";
mainHeading.style.fontSize = "36px";
mainHeading.style.fontWeight = "600";
mainHeading.style.lineHeight = "43.2px";
mainHeading.style.letterSpacing = "-.02em";
headingParagraph.style.display = "block";
headingParagraph.style.margin = "0 0 24px 0";
mainHeadingContainer.append(
headingFloaterText,
mainHeading,
headingParagraph,
registerBtn
);
//VIDEO STYLING
if (videoContainer && videoContainer.style) {
videoContainer.style.maxWidth = "none";
}
//COURSE DETAILS PAGE BODY STYLING
bodyContainer.style.padding = "0";
bodyContainer.style.margin = "96px auto 46px auto";
bodyContainer.style.maxWidth = "min(1152px, 90%)";
bodyContainer.style.display = "grid";
bodyContainer.style.gridTemplateColumns =
"minmax(100px, 760px) minmax(100px, 368px)";
bodyContainer.style.columnGap = "24px";
secondaryBodyContainer.style.padding = "0";
secondaryBodyContainer.style.maxWidth = "760px";
bodyColumns.forEach((column) => {
column.style.float = "none";
column.style.padding = "0";
column.style.width = "100%";
column.style.display = "block";
column.querySelector("h3").style.fontWeight = "600";
if (column.classList.contains("large-7")) {
column.style.marginBottom = "48px";
}
const innerCol = column.querySelector(".dp-curriculum");
if (innerCol) {
innerCol.style.margin = "0";
}
});
//COURSE DETAILS CURRICULUM STYLING
if (!initialLoadComplete) {
let groupIsOpen = false;
// Check if course has Sections/Modules/Parts
const hasSections = curriculumListContainer.querySelector(".section")
? true
: false;
let curContainer = document.createElement("li");
if (!hasSections) {
styleGroupContainer(curContainer);
}
// const startingGroup = document.createElement("div");
// styleGroupHeading(startingGroup);
// curContainer.append(startingGroup);
function styleGroupContainer(container) {
container.style.border = "2px solid #3443F4";
container.style.borderRadius = "8px";
container.style.marginBottom = "48px";
container.style.padding = "0";
}
function styleListItem(lessonItem, isLastChild) {
//display none for icon w/ class 'type-icon'
const icon = lessonItem.querySelector(".type-icon");
icon.style.display = "none";
const lessonItemText = lessonItem.querySelector(".lesson-wrapper");
lessonItemText.style.padding = "24px";
lessonItemText.style.fontSize = "16px";
lessonItemText.style.fontWeight = "400";
lessonItemText.style.lineHeight = "150%";
if (!isLastChild) {
lessonItemText.style.borderBottom = "2px solid #3443F4";
}
}
function styleGroupHeading(groupHeading) {
// console.log('groupHeading: ', groupHeading)
groupHeading.textContent = groupHeading?.textContent?.trim();
groupHeading.style.fontSize = "16px";
groupHeading.style.fontWeight = "500";
groupHeading.style.lineHeight = "125%";
// groupHeading.style.letterSpacing = "-.16px";
groupHeading.style.fontFamily = "Fusiona";
groupHeading.style.padding = "24px";
groupHeading.style.borderBottom = "2px solid #3443F4";
curContainer.append(groupHeading);
}
curriculumList.forEach((curListItem, i, arr) => {
//first check if current item contains 'section' class
if (curListItem.classList.contains("section")) {
//Yes? push curContainer into curriculumListContainer
curriculumListContainer.append(curContainer);
//reset curContainer while pushing current 'section' in there for the next iteration
curContainer = document.createElement("li");
styleGroupContainer(curContainer);
const newGroupHeading = document.createElement("div");
newGroupHeading.innerHTML = curListItem.innerHTML;
styleGroupHeading(newGroupHeading);
curContainer.append(newGroupHeading);
} else {
// else, normal/expected behaviour
//transfer inner html of current list item to new created div
const newListItem = document.createElement("div");
newListItem.innerHTML = curListItem.innerHTML;
styleListItem(
newListItem,
arr[i + 1] ? arr[i + 1].classList.contains("section") : true
);
curContainer.append(newListItem);
}
curListItem.style.display = "none";
});
//LAST, unpushed SECTION; push it out to curriculumListContainer
curriculumListContainer.append(curContainer);
curriculumListHeader.style.display = "none";
curriculumListContainer.style.padding = "0";
}
//COURSE DETAILS GRID STRUCTURE STYLING - ADDING DETAILS CARD ON RIGHT SIDE
if (courseDetailCardContainer) {
bodyContainer.append(courseDetailCardContainer);
courseDetailCardContainer.style.margin = "0 0 46px 0";
courseDetailCardContainer.style.justifySelf = "center";
courseDetailCardListItems.forEach((li) => {
const iconClone = checkboxIcon.cloneNode(true);
iconClone.style.display = "block";
iconClone.style.flexShrink = "0";
li.prepend(iconClone);
});
}
if (courseDetailsCardLink) {
courseDetailsCardLink.textContent = registerBtnText;
courseDetailsCardLink.setAttribute("href", registerBtnLink);
}
}
function desktopPathCourseDetailsPageStyling() {
const headerContainer = document.querySelector(
".top-row-grey.top-row-white-v2.padding-top.padding-side.row-v2"
);
const headerFlexContainer = document.querySelector(".row.dp-row-flex-v2");
const headingFloaterText = document.querySelector(".sj-floater-text");
const mainHeading = document.querySelector(".break-word");
const registerBtn = document.getElementById("purchase-button-wrapper-large");
const registerBtnAnchor = document.getElementById("purchase-button");
const mainHeadingContainer = document.querySelector(
".columns.text-center.large-6.dp-summary-wrapper.text-left-v2"
);
// const mainVideoContainer = document.querySelector(
// ".columns.large-6.text-center.dp-promo-image-wrapper"
// );
const backToCatalogBtn = document.querySelector(".back-to-catalog");
// const videoContainer = document.querySelector(".video-max");
const mainInfoCardContained = document.querySelector(
".sj-course-info-wrapper"
);
const headingParagraph = mainInfoCardContained.querySelector("h2");
//SIGN IN VARIABLES (WHEN USER NOT LOGGED IN)
const signInHeaderText = document.querySelector(".signin");
const signInBtn = document.querySelector(
".header-link.login-link.sj-text-sign-in.focus-link-v2"
);
////BODY VARIABLES
const bodyContainer = document.getElementById("dp-details-bundle");
const catalogContainer = document.getElementById("catalog-courses");
// const mobileBodyContent = document.querySelector(".row.show-for-small");
// const secondaryBodyContainer = document.querySelector(
// ".row.hide-for-small.padded-side-bottom"
// );
// const bodyColumns = secondaryBodyContainer.querySelectorAll(".columns");
// const curriculumListContainer = document.querySelector(".dp-curriculum"); //NOTE: THERE ARE 2 DP-CURRICULUMS. ONE IS DESKTOP AND OTHER IS FOR MOBILE (STILL TABED)!
// const curriculumListHeader = curriculumListContainer
// .closest(".sj-curriculum-wrapper")
// .querySelector("h3");
// const curriculumList = curriculumListContainer.querySelectorAll("li");
////CARD VARIABLES
// const courseDetailCardContainer = secondaryBodyContainer.querySelector(
// ".course-details-card"
// );
// let courseDetailCardListItems;
// if (courseDetailCardContainer) {
// courseDetailCardListItems =
// courseDetailCardContainer.querySelectorAll("li");
// }
// const checkboxIcon = document.querySelector(".checkbox-icon");
// const registerBtnLink = document
// .getElementById("purchase-button")
// .getAttribute("href");
// const registerBtnText = document.querySelector(
// ".purchase-button-full-text"
// ).textContent;
// const courseDetailsCardLink = document.querySelector(
// ".course-details-card-link"
// );
backToCatalogBtn.style.display = "none";
// mobileBodyContent.style.display = "none";
if (signInHeaderText) {
signInHeaderText.style.display = "none";
signInBtn.style.backgroundColor = "transparent";
signInBtn.style.padding = "8px 12px";
signInBtn.style.marginRight = "24px";
signInBtn.style.borderColor = "#3443F4";
signInBtn.style.border = "2px solid #3443F4";
signInBtn.style.borderRadius = "999px";
signInBtn.style.fontSize = "14px";
signInBtn.style.fontFamily = "Space Mono";
signInBtn.style.fontWeight = "700";
signInBtn.style.lineHeight = "20px";
}
// headerContainer.style.backgroundColor = "#D0CFEE";
headerContainer.style.background =
"url(https://images.ctfassets.net/l47ir7rfykkn/5zE7elBMFe1MmuhPIeWd9G/e09a10e4d4c081b9ca86a879b6984049/Main_BG.png)";
headerContainer.style.backgroundSize = "cover";
headerContainer.style.backgroundPosition = "center";
headerContainer.style.backgroundRepeat = "no-repeat";
headerContainer.style.margin = "0";
headerContainer.style.maxWidth = "none";
headerContainer.style.paddingTop = "96px";
headerContainer.style.paddingBottom = "96px";
headerContainer.style.border = "0";
headerFlexContainer.style.flexDirection = "row-reverse";
headerFlexContainer.style.flexWrap = "nowrap";
headerFlexContainer.style.justifyContent = "start";
headerFlexContainer.style.gap = "24px";
headerFlexContainer.style.maxWidth = "1188px";
// //RENDERING OF COURSE DETAILS PAGE TEXT HEADING ON LEFT
mainHeadingContainer.style.border = "0";
mainHeadingContainer.style.maxWidth = "600px";
mainInfoCardContained.style.display = "none";
headingFloaterText.textContent = "Learning Path";
headingFloaterText.style.color = "#7AF0FE";
headingFloaterText.style.display = "block";
headingFloaterText.style.marginBottom = "24px";
mainHeading.style.color = "#fff";
mainHeading.style.margin = "0 0 12px 0";
mainHeading.style.fontSize = "36px";
mainHeading.style.fontWeight = "600";
mainHeading.style.lineHeight = "43.2px";
mainHeading.style.letterSpacing = "-.02em";
headingParagraph.style.color = "#fff";
headingParagraph.style.display = "block";
headingParagraph.style.margin = "0 0 24px 0";
registerBtnAnchor.style.borderColor = "#7AF0FE";
registerBtnAnchor.style.color = "#fff";
mainHeadingContainer.append(
headingFloaterText,
mainHeading,
headingParagraph,
registerBtn
);
// //VIDEO STYLING
// if (videoContainer && videoContainer.style) {
// videoContainer.style.maxWidth = "none";
// }
// //COURSE DETAILS PAGE BODY STYLING
bodyContainer.style.padding = "0";
bodyContainer.style.margin = "96px auto 46px auto";
bodyContainer.style.maxWidth = "min(1152px, 90%)";
catalogContainer.style.marginBottom = "85px";
// bodyContainer.style.display = "grid";
// bodyContainer.style.gridTemplateColumns =
// "minmax(100px, 760px) minmax(100px, 368px)";
// bodyContainer.style.columnGap = "24px";
// secondaryBodyContainer.style.padding = "0";
// secondaryBodyContainer.style.maxWidth = "760px";
// bodyColumns.forEach((column) => {
// column.style.float = "none";
// column.style.padding = "0";
// column.style.width = "100%";
// column.style.display = "block";
// column.querySelector("h3").style.fontWeight = "600";
// if (column.classList.contains("large-7")) {
// column.style.marginBottom = "48px";
// }
// const innerCol = column.querySelector(".dp-curriculum");
// if (innerCol) {
// innerCol.style.margin = "0";
// }
// });
// //COURSE DETAILS CURRICULUM STYLING
// if (!initialLoadComplete) {
// let groupIsOpen = false;
// let curContainer = document.createElement("li");
// styleGroupContainer(curContainer);
// const startingGroup = document.createElement("div");
// styleGroupHeading(startingGroup);
// curContainer.append(startingGroup);
// function styleGroupContainer(container) {
// container.style.border = "2px solid #3443F4";
// container.style.borderRadius = "8px";
// container.style.marginBottom = "48px";
// container.style.padding = "0";
// }
// function styleListItem(lessonItem, isLastChild) {
// //display none for icon w/ class 'type-icon'
// const icon = lessonItem.querySelector(".type-icon");
// icon.style.display = "none";
// const lessonItemText = lessonItem.querySelector(".lesson-wrapper");
// lessonItemText.style.padding = "24px";
// lessonItemText.style.fontSize = "16px";
// lessonItemText.style.fontWeight = "400";
// lessonItemText.style.lineHeight = "150%";
// if (!isLastChild) {
// lessonItemText.style.borderBottom = "2px solid #3443F4";
// }
// }
// function styleGroupHeading(groupHeading) {
// // console.log('groupHeading: ', groupHeading)
// groupHeading.textContent =
// groupHeading?.textContent?.trim() === ""
// ? "Introduction"
// : groupHeading?.textContent?.trim();
// groupHeading.style.fontSize = "16px";
// groupHeading.style.fontWeight = "500";
// groupHeading.style.lineHeight = "125%";
// // groupHeading.style.letterSpacing = "-.16px";
// groupHeading.style.fontFamily = "Fusiona";
// groupHeading.style.padding = "24px";
// groupHeading.style.borderBottom = "2px solid #3443F4";
// curContainer.append(groupHeading);
// }
// curriculumList.forEach((curListItem, i, arr) => {
// //first check if current item contains 'section' class
// if (curListItem.classList.contains("section")) {
// //Yes? push curContainer into curriculumListContainer
// curriculumListContainer.append(curContainer);
// //reset curContainer while pushing current 'section' in there for the next iteration
// curContainer = document.createElement("li");
// styleGroupContainer(curContainer);
// const newGroupHeading = document.createElement("div");
// newGroupHeading.innerHTML = curListItem.innerHTML;
// styleGroupHeading(newGroupHeading);
// curContainer.append(newGroupHeading);
// } else {
// // else, normal/expected behaviour
// //transfer inner html of current list item to new created div
// const newListItem = document.createElement("div");
// newListItem.innerHTML = curListItem.innerHTML;
// styleListItem(
// newListItem,
// arr[i + 1] ? arr[i + 1].classList.contains("section") : true
// );
// curContainer.append(newListItem);
// }
// curListItem.style.display = "none";
// });
// //LAST, unpushed SECTION; push it out to curriculumListContainer
// curriculumListContainer.append(curContainer);
// curriculumListHeader.style.display = "none";
// curriculumListContainer.style.padding = "0";
// }
// //COURSE DETAILS GRID STRUCTURE STYLING - ADDING DETAILS CARD ON RIGHT SIDE
// if (courseDetailCardContainer) {
// bodyContainer.append(courseDetailCardContainer);
// courseDetailCardContainer.style.margin = "0 0 46px 0";
// courseDetailCardContainer.style.justifySelf = "center";
// courseDetailCardListItems.forEach((li) => {
// const iconClone = checkboxIcon.cloneNode(true);
// iconClone.style.display = "block";
// iconClone.style.flexShrink = "0";
// li.prepend(iconClone);
// });
// }
// if (courseDetailsCardLink) {
// courseDetailsCardLink.textContent = registerBtnText;
// courseDetailsCardLink.setAttribute("href", registerBtnLink);
// }
console.log("reached end of path func");
}
function desktopPathCatalogPageStyling() {
const backArrowBtn = document.querySelector(".back-to-catalog");
const mainContentContainer = document.getElementById("catalog-content");
const topContentContainer = mainContentContainer.querySelector(
".path-curriculum-resume-wrapper"
);
const coursesList = document
.getElementById("catalog-courses")
.querySelectorAll(".coursebox-container");
coursesList.forEach((course) => {
//Outter border
course.style.border = "2px solid #D0CFEE";
course.style.borderRadius = "20px";
//inner border
const innerContainer = course.querySelector(".course-overview");
if (innerContainer) {
innerContainer.style.borderTop = "2px solid #D0CFEE";
}
course.addEventListener("mouseover", () => {
course.style.borderColor = "#3443f4";
if (innerContainer) {
innerContainer.style.borderColor = "#3443f4";
}
});
course.addEventListener("mouseout", () => {
course.style.borderColor = "#D0CFEE";
if (innerContainer) {
innerContainer.style.borderColor = "#D0CFEE";
}
});
});
//PAGE NAV STYLING
backArrowBtn.style.display = "none";
//MAIN CONTENT STYLING
mainContentContainer.style.margin = "96px auto";
topContentContainer.style.display = "none";
}
function desktopLessonPageStyling() {
const logoImg = document.querySelector(".header-center-img");
const leftNav = document.getElementById("lp-left-nav");
const mainLessonContentContainer = document.getElementById("lp-wrapper");
const mainLessonContentSubContainer = document.getElementById("lp-content");
const mainLessonInnerContainer = document.getElementById("lesson-body");
const mainLessonMainContainer = document.getElementById("lesson-main");
const lessonFooter = document.getElementById("lp-footer");
const navOpenIcon = document.getElementById("left-nav-button");
const hamburgerIcon = navOpenIcon.querySelector(".fa.fa-bars");
const xIcon = navOpenIcon.querySelector(".fa.fa-times");
const leftNavMobileOverlay = document.getElementById("lpLeftNavBackground");
const fullScreenBtn = document.querySelector(
".toggle-fullscreen.focus-link-v2 "
);
/// LESSON BODY VARS
const lessonInnerContainer = document.getElementById("lesson-main-inner");
const quizPage = document.querySelector(
".course-scrollable-content.course-text-content.quiz"
);
const copyIcon = document.querySelector(".copy-icon");
const lessonContentContainer = document.querySelector(
"sjwc-lesson-content-item"
);
const codeBlocks = lessonContentContainer.querySelectorAll("pre");
//FOOTER VARS
const footerContainer = document.getElementById("footer-container");
const footerCols = footerContainer.querySelectorAll(".global-footer-column");
///////STYLE LOGO
logoImg.style.height = "24px";
lessonInnerContainer.style.maxWidth = "712px";
lessonInnerContainer.style.margin = "0 auto";
mainLessonContentContainer.append(lessonFooter);
mainLessonInnerContainer.prepend(navOpenIcon);
//STYLING TO ALIGN NAV ICON TO LEFT CORNER AND STICKY
mainLessonContentContainer.style.position = "relative";
mainLessonContentContainer.style.display = "flex";
mainLessonContentContainer.style.flexDirection = "column";
mainLessonContentContainer.style.justifyContent = "space-between";
mainLessonContentSubContainer.style.height = "auto";
mainLessonInnerContainer.style.margin = "0";
mainLessonInnerContainer.style.maxWidth = "none";
mainLessonMainContainer.style.position = "relative";
mainLessonMainContainer.style.zIndex = "0";
mainLessonMainContainer.style.paddingTop = "0";
navOpenIcon.style.position = "sticky";
navOpenIcon.style.top = "12px";
navOpenIcon.style.zIndex = "1";
hamburgerIcon.style.padding = "12px";
xIcon.style.padding = "12px";
navOpenIcon.style.float = "none";
[hamburgerIcon, xIcon].forEach((el) => {
xIcon.style.padding = "12px";
el.style.padding = "12px";
el.style.border = "none";
el.style.borderRadius = "8px";
el.style.background = "rgba(255, 255, 255, .8)";
el.style.backdropFilter = "blur(1.5px)";
});
///////////////////////////////
lessonFooter.style.position = "relative";
lessonFooter.style.border = "0";
lessonFooter.style.backgroundColor = "transparent";
//lessonFooter.style.backgroundColor = "red";
leftNav.style.position = "absolute";
leftNav.style.backgroundColor = "#f9f9f9";
leftNav.style.width = "320px";
leftNav.style.marginBottom = "0px";
// leftNav.style.height = "100%";
// leftNav.style.paddingBottom = "40px";
mainLessonContentContainer.style.height = "100vh";
mainLessonContentContainer.style.overflowY = "auto";
mainLessonContentContainer.style.paddingBottom = "0";
/////////HIDE FULL SCREEN BUTTON
fullScreenBtn.style.display = "none";
/////////QUIZ PAGE STYLING
if (quizPage) {
const quizInitCheckboxIcon = document.querySelector(
".fa.fa-check-square-o.quiz-icon"
);
//quizInitCheckboxIcon.style.display = "none";
//console.log("quizPage", quizPage);
}
//SECOND PAGE OF STYLING INSTRUCTIONS FROM 1ST VERSION
const parentEl = document.querySelector(".sj-page-lesson");
// footerContainer.style.marginTop = "60px";
const openIcon = document.querySelector(".fa.fa-bars");
const searchIcon = document.querySelector(".fa.fa-search");
const closeIcon = document.querySelector(".fa.fa-times");
const navText = document.querySelector(".burger-text.sj-text-lessons");
searchIcon.style.display = "none";
navText.style.display = "none";
//HANDLE FIRST RENDER CASE WHEN EITHER NAV IS OPEN OR CLOSED
if (parentEl.classList.contains("cbp-spmenu-open")) {
openIcon.style.display = "none";
} else {
closeIcon.style.display = "none";
}
//HANDLE CLICKS
openIcon.addEventListener("click", (e) => {
e.target.style.display = "none";
closeIcon.style.display = "inline-block";
});
closeIcon.addEventListener("click", (e) => {
e.target.style.display = "none";
openIcon.style.display = "inline-block";
});
//STYLING OF THE LEFT NAV LINKS
const lessonNavLinksContainer = document.getElementById("curriculum-list-2");
const backToCurriculumEl = document.getElementById("left-nav-return-text");
const links = lessonNavLinksContainer.querySelectorAll("a");
const sectionTitles =
lessonNavLinksContainer.querySelectorAll(".section-title");
if (backToCurriculumEl) {
backToCurriculumEl.textContent = "Back to Course Overview";
}
lessonNavLinksContainer.style.paddingBottom = "32px";
//STYLE EACH OF THE LESSON LINKS
links.forEach((link) => {
const pageIcon = link.querySelector(".type-icon");
const lessonLinkContainer = link.querySelector(".lesson-row");
link.style.color = "#14003d";
link.style.cursor = "pointer";
pageIcon.style.display = "none";
lessonLinkContainer.style.display = "flex";
lessonLinkContainer.style.flexDirection = "row-reverse";
lessonLinkContainer.style.justifyContent = "space-between";
lessonLinkContainer.style.margin = "0 12px";
lessonLinkContainer.style.paddingLeft = "12px";
lessonLinkContainer.style.paddingRight = "12px";
lessonLinkContainer.style.fontSize = "14px";
lessonLinkContainer.style.lineHeight = "20px";
});
//STYLE EACH OF THE LESSON LINK HEADER (THE MODULE NAMES)
sectionTitles.forEach((title) => {
title.style.backgroundColor = "transparent";
title.style.padding = "12px";
title.style.paddingLeft = "24px";
title.style.paddingRight = "24px";
title.style.marginTop = "12px";
title.style.marginBottom = "12px";
title.style.border = "0";
title.style.fontFamily = "Fusiona";
title.style.fontSize = "16px";
title.style.fontWeight = "700";
});
// const copyIcon = document.querySelector('.checkbox-icon');
// const lessonContentContainer = document.querySelector('sjwc-lesson-content-item');
// const codeBlocks = lessonContentContainer.querySelectorAll('pre');
//HANDLE CODE BLOCK CUSTOM STYLING
function animateCopiedTooltip(tooltipEl) {
tooltipEl.style.opacity = "1";
setTimeout(() => {
tooltipEl.style.opacity = "0";
}, 400);
}
codeBlocks.forEach((el) => {
//console.log(el);
//WILL NEED TO CLEAN UP THE STYLING OF EL!!!!!!!!!!
el.style.padding = "0";
el.style.overflow = "visible";
el.style.position = "relative";
const codeEl = el.querySelector("code");
// codeEl.style.display = 'inline-block';
// codeEl.style.padding = '24px !important';
codeEl.setAttribute(
"style",
"display: inline-block; padding: 24px !important; overflow-x: scroll; width: 100%"
);
const copyText = codeEl.textContent;
//CREATE PARENT CONTAINER & STYLE AS FLEX CONTAINER, COL DIR, AND ALIGN INTEMS START (OR END)
const container = document.createElement("div");
container.style.display = "flex";
container.style.justifyContent = "end";
container.style.borderBottom = "1px solid gainsboro";
container.style.padding = "12px 24px";
//CLONE COPYICON EL AND ADD TO CONTAINER
const iconClone = copyIcon.cloneNode(true);
iconClone.style.display = "block";
iconClone.style.cursor = "pointer";
container.append(iconClone);
//CREATE 'COPIED' TOOLTIP
const tooltipContainer = document.createElement("div");
tooltipContainer.textContent = "Copied";
tooltipContainer.style.position = "absolute";
tooltipContainer.style.top = "-24px";
tooltipContainer.style.right = "10px";
tooltipContainer.style.textShadow = "none";
tooltipContainer.style.backgroundColor = "#1c1c1c";
tooltipContainer.style.color = "#fff";
tooltipContainer.style.padding = "5px 10px";
tooltipContainer.style.borderRadius = "4px";
tooltipContainer.style.opacity = "0";
tooltipContainer.style.transition = "opacity .2s ease-in";
el.append(tooltipContainer);
//ADD CONTAINER AS FIRST CHILD IN EL
el.prepend(container);
//ADD EVENT LISTENER TO CLONED ICON TO COPY CODE BLOCK INTO CLIPBOARD
iconClone.addEventListener("click", async () => {
try {
await navigator.clipboard.writeText(copyText);
//console.log("Content copied to clipboard");
animateCopiedTooltip(tooltipContainer);
} catch (err) {
console.error("Failed to copy codeblock to clipboard: ", err);
}
});
});
// Makes lesson links pop up in new tab
lessonContentContainer.querySelectorAll("a").forEach((el) => {
el.setAttribute("target", "_blank");
});
//LESSON CONTENT FOOTER
const prevBtn = document.querySelector(".button-prev-title span");
if (prevBtn) {
prevBtn.style.color = "#14003d";
}
//FOOTER STYLING
footerContainer.style.paddingLeft = "40px";
footerContainer.style.paddingRight = "40px";
footerCols.forEach((col) => {
col.style.width = "270px";
});
}
function desktopLoginPageStyling() {
const logoImg = document.querySelector(".header-center-img");
const fbBtn = document.getElementById("facebook_login");
const googleBtn = document.getElementById("google_login");
const loginContent = document.getElementById("login-content");
const tabArrow = document.getElementById("tab-marker-login");
const termsAndServicesText = document.getElementById("access-message");
const loginContentContainer = document.querySelector(".large-6.columns");
const orGoogleSignInContainer =
loginContent.querySelectorAll(".large-6.columns")[1];
const orGoogleSignInInnerContainer =
orGoogleSignInContainer.querySelector("ul");
const orGoogleSignInInnerContainerListItems =
orGoogleSignInInnerContainer.querySelectorAll("li");
const signUpSignInContainer = document.querySelector(".large-12.columns");
const tabsContainer = document.getElementById("tabs");
const loginTab = document.getElementById("login-tab-left");
const signInTab = document.getElementById("login-tab-right");
const signInTabText = signInTab.querySelector("a");
const longInNote = document.querySelector(".loginNote.sj-text-login-note");
const orSignInWithContainer = document.querySelector(
".socialaccount_providers li"
);
const orSignInWithTextEl = orSignInWithContainer.querySelector(
".sj-text-sign-in-with span"
);
const loginInput = document.getElementById("id_login");
const passwordInput = document.getElementById("id_password");
const loginBottomBtn = document.getElementById("button-sign-in");
const forgotPasswordText = document.querySelector(
".forgot-password.sj-text-forgot-password.focus-link-v2"
);
const loginBottomBtnAndForgotPassBtn =
loginBottomBtn.closest(".large-12.columns");
const loginForm = document.getElementById("login_form");
//FOOTER VARS
const footerContainer = document.getElementById("footer-container");
const footerCols = footerContainer.querySelectorAll(".global-footer-column");
///////STYLE LOGO
logoImg.style.height = "24px";
termsAndServicesText.style.maxWidth = "368px";
// termsAndServicesText.style.color = "#545454";
termsAndServicesText.style.fontSize = "14px";
loginForm.append(termsAndServicesText);
//////STYLE THE LOGIN/SIGN UP TABS
signUpSignInContainer.style.display = "flex";
// tabs.style.backgroundColor = "#F3F3F3";
tabs.style.borderRadius = "100px";
tabs.style.display = "flex";
tabs.style.padding = "4px";
loginTab.querySelector("span span").textContent = "Log In";
loginTab.style.border = "0";
loginTab.style.display = "flex";
loginTab.style.padding = "8px 16px";
loginTab.style.alignItems = "center";
// loginTab.style.backgroundColor = "#3443F4";
loginTab.style.textDecoration = "underline";
loginTab.style.fontFamily = "Space Mono";