forked from JAYESHBATRA/Virtuo-Learn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mode-switch.js
197 lines (163 loc) · 5.95 KB
/
mode-switch.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
document.addEventListener('DOMContentLoaded', () => {
const switchCheckbox = document.getElementById('switch');
const currentTheme = localStorage.getItem('theme');
function applyDarkModeStyles() {
document.body.classList.remove('light-mode');
document.body.classList.add('dark-mode');
document.body.style.backgroundColor = "#111111";
const nav = document.getElementById("main_navbar");
if (nav) {
nav.style.backgroundColor = "#38373743";
nav.style.backdropFilter = "blur(100px)";
}
const footer = document.querySelector("footer");
if (footer) {
footer.style.backgroundColor = "#242525";
}
const tables = document.querySelectorAll(".wrapper .table");
tables.forEach(table => {
table.style.backgroundColor = "#242426";
});
const linksTitle = document.querySelectorAll(".links-title");
linksTitle.forEach(link => {
link.style.color = "#ffffff";
});
const copyright = document.querySelector(".copyright");
if (copyright) {
copyright.style.backgroundColor = "#232325";
}
const copyrightH3 = document.querySelector(".copyright h3");
if (copyrightH3) {
copyrightH3.style.color = "#ffffff";
}
const companyLogo = document.querySelector(".company-logo img");
if (companyLogo) {
companyLogo.style = "-webkit-filter: invert(100%);";
companyLogo.src = "./assets/asset 45.png";
}
const footerLogo = document.querySelector(".footer-logo img");
if (footerLogo) {
footerLogo.src = "./assets/asset 45.png";
}
const currentPage = document.querySelector(".current-page");
if (currentPage) {
currentPage.style.color = "#cfe2f3";
currentPage.style.borderColor = "#6fa8dc";
}
const automaticChangeDiv = document.getElementById("automatic-change");
if (automaticChangeDiv) {
automaticChangeDiv.style.color = "#cfe2f3";
automaticChangeDiv.style.textShadow = "2px 2px 2px #000000";
}
const featuresHeadingText = document.querySelector(".features-heading-text");
if (featuresHeadingText) {
featuresHeadingText.style.color = "#cfe2f3";
featuresHeadingText.style.textShadow = "2px 2px 2px #000000";
}
const h3Elements = document.querySelectorAll("h3");
h3Elements.forEach(h3 => {
h3.style.color = "#cfe2f3";
h3.style.textShadow = "2px 2px 2px #000000";
});
const h4Elements = document.querySelectorAll("h4");
h4Elements.forEach(h4 => {
h4.style.color = "#cfe2f3";
h4.style.textShadow = "2px 2px 2px #000000";
});
const usefulLinks = document.querySelectorAll(".useful-links");
usefulLinks.forEach(link => {
link.style.color = "#cfe2f3";
link.style.textShadow = "2px 2px 2px #000000";
});
document.documentElement.style.setProperty("--primary-text-color", "#ffffff");
document.documentElement.style.setProperty("--secondary-text-color", "#ffffff");
}
function applyLightModeStyles() {
document.body.classList.remove('dark-mode');
document.body.classList.add('light-mode');
document.body.style.backgroundColor = "#ffffff";
const nav = document.getElementById("main_navbar");
if (nav) {
nav.style.backgroundColor = "#ffffff";
nav.style.backdropFilter = "none";
}
const footer = document.querySelector("footer");
if (footer) {
footer.style.backgroundColor = "#ebf2fa";
}
const tables = document.querySelectorAll(".wrapper .table");
tables.forEach(table => {
table.style.backgroundColor = "#e9ebff";
});
const linksTitle = document.querySelectorAll(".links-title");
linksTitle.forEach(link => {
link.style.color = "rgb(33, 28, 28)";
});
const copyright = document.querySelector(".copyright");
if (copyright) {
copyright.style.backgroundColor = "#d6d9fd";
}
const copyrightH3 = document.querySelector(".copyright h3");
if (copyrightH3) {
copyrightH3.style.color = "rgb(33, 28, 28)";
}
const companyLogo = document.querySelector(".company-logo img");
if (companyLogo) {
companyLogo.style = "fill: black;";
companyLogo.src = "./assets/asset 41.png";
}
const footerLogo = document.querySelector(".footer-logo img");
if (footerLogo) {
footerLogo.src = "./assets/asset 41.png";
}
const currentPage = document.querySelector(".current-page");
if (currentPage) {
currentPage.style.color = "#4d006b";
currentPage.style.borderColor = "rgb(0, 30, 94)";
}
const automaticChangeDiv = document.getElementById("automatic-change");
if (automaticChangeDiv) {
automaticChangeDiv.style.color = "";
automaticChangeDiv.style.textShadow = "";
}
const featuresHeadingText = document.querySelector(".features-heading-text");
if (featuresHeadingText) {
featuresHeadingText.style.color = "";
featuresHeadingText.style.textShadow = "";
}
const h3Elements = document.querySelectorAll("h3");
h3Elements.forEach(h3 => {
h3.style.color = "";
h3.style.textShadow = "";
});
const h4Elements = document.querySelectorAll("h4");
h4Elements.forEach(h4 => {
h4.style.color = "";
h4.style.textShadow = "";
});
const usefulLinks = document.querySelectorAll(".useful-links");
usefulLinks.forEach(link => {
link.style.color = "";
link.style.textShadow = "";
});
document.documentElement.style.setProperty("--primary-text-color", "#183b56");
document.documentElement.style.setProperty("--secondary-text-color", "#577592");
}
if (currentTheme) {
if (currentTheme === 'dark-mode') {
applyDarkModeStyles();
switchCheckbox.checked = true;
} else {
applyLightModeStyles();
}
}
switchCheckbox.addEventListener('change', () => {
if (switchCheckbox.checked) {
applyDarkModeStyles();
localStorage.setItem('theme', 'dark-mode');
} else {
applyLightModeStyles();
localStorage.setItem('theme', 'light-mode');
}
});
});