-
Notifications
You must be signed in to change notification settings - Fork 1
/
dark_mode.js
254 lines (218 loc) · 9.7 KB
/
dark_mode.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
(
window.onload = (event) => {
var cookie = getCookie("darkMode");
if (cookie == "true") {
darkMode();
}
}
)();
function darkMode() {
const darkModeBlack = "#1e1f1c";
const darkModeLightBlack = "#272822";
const darkModeKw = "#b5335d";
const darkModethead = '#999999'
const darkModetbody = '#333333'
const darkModeLightGreen = "#008900";
const darkModeLightPurple = "#684df6";
const darkModeLightBrown = "#c9a876"
const darkModeLightBlue = "#4881f6";
// noticeButton, documentButton, qnaButton, toktokButton
const sButtonColors = ["#008900", "#684df6", "#c9a876", "#4881f6"]
var noticeButtonStyle;
var documentButtonStyle;
var qnaButtonStyle;
var toktokButtonStyle;
// !!!! this variable is universal for all for loops. should keep an eye on this.
var i;
// change all default font color. It was black before changing.
document.body.style.color = "white";
document.getElementsByClassName("bg-light")[0].style.cssText = "background-color: " + darkModeBlack + " !important";
document.getElementsByClassName("bg-top")[0].style.cssText = "background-color: " + darkModeKw + " !important";
// -------------------------- CARDS -------------------------------
// ----------------------------------------------------------------
var cards = document.getElementsByClassName("card");
for (i = 0; i < cards.length; ++i) {
//cards[i].style.backgroundColor = "#505050";
cards[i].style.backgroundColor = "#272822";
}
// ---------------------- SUBJECT TABLE ---------------------------
// ----------------------------------------------------------------
var listboxes = document.querySelectorAll('.subjectlist li');
for (i = 0; i < listboxes.length; ++i) {
// change subject table border color
listboxes[i].style.borderBottomColor = darkModeKw;
listboxes[i].style.borderTopColor = darkModeKw;
}
// ----------------------- SMALL BUTTONS --------------------------
// ----------------------------------------------------------------
var noticeButtons = document.querySelectorAll('.btn-lightgreen');
for (i = 0; i < noticeButtons.length; ++i) {
var curButton = noticeButtons[i];
noticeButtonStyle = "background-color: " + darkModeLightGreen + "; ";
curButton.style.cssText = noticeButtonStyle;
if (curButton.lastElementChild && curButton.lastElementChild.style.display !== "none") {
//curButton.removeChild(curButton.lastElementChild);
noticeButtonStyle += "border-color: " + darkModeKw + "; ";
noticeButtonStyle += "border-width: thick; ";
curButton.style.cssText = noticeButtonStyle;
}
}
var documentButtons = document.querySelectorAll('.btn-lightpurple');
for (i = 0; i < documentButtons.length; ++i) {
var curButton = documentButtons[i];
documentButtonStyle = "background-color: " + darkModeLightPurple + "; ";
curButton.style.cssText = documentButtonStyle;
if (curButton.lastElementChild.style.display !== "none") {
//curButton.removeChild(curButton.lastElementChild);
documentButtonStyle += "border-color: " + darkModeKw + "; ";
documentButtonStyle += "border-width: thick; ";
curButton.style.cssText = documentButtonStyle;
}
}
var qnaButtons = document.querySelectorAll('.btn-lightbrown');
for (i = 0; i < qnaButtons.length; ++i) {
var curButton = qnaButtons[i];
qnaButtonStyle = "background-color: " + darkModeLightBrown + "; ";
curButton.style.cssText = qnaButtonStyle;
if (curButton.lastElementChild.style.display !== "none") {
//curButton.removeChild(curButton.lastElementChild);
qnaButtonStyle += "border-color: " + darkModeKw + "; ";
qnaButtonStyle += "border-width: thick; ";
curButton.style.cssText = qnaButtonStyle;
}
}
var toktokButtons = document.querySelectorAll('.btn-lightblue');
for (i = 0; i < toktokButtons.length; ++i) {
var curButton = toktokButtons[i];
toktokButtonStyle = "background-color: " + darkModeLightBlue + "; ";
curButton.style.cssText = toktokButtonStyle;
if (curButton.lastElementChild.style.display !== "none") {
//curButton.removeChild(curButton.lastElementChild);
toktokButtonStyle += "border-color: " + darkModeKw + "; ";
toktokButtonStyle += "border-width: thick; ";
curButton.style.cssText = toktokButtonStyle;
}
}
// ------------------------ TITLE TEXT ----------------------------
var title = document.getElementsByClassName('title-text');
for (i = 0; i < title.length; i++) {
title[i].style.color = 'white';
}
// --------------------------- C DAY ------------------------------
var cTitle = document.getElementsByClassName('c-title');
if (cTitle.length > 0) {
cTitle[0].style.color = 'white';
}
var day = document.querySelectorAll('.c-day-content');
for (i = 0; i < day.length; i++) {
if (day[i].style.color !== 'rgb(255, 255, 255)') {
day[i].style.color = '#747474'
}
}
// -------------------------- NOTICE ------------------------------
// ----------------------------------------------------------------
// -------------------------- Title -------------------------------
var contenttitle = document.getElementsByClassName("contenttitle");
for (i = 0; i < contenttitle.length; ++i) {
contenttitle[i].style.color = 'white';
}
// -------------------------- SEARCH ------------------------------
var search = document.getElementsByClassName("con_search");
for (i = 0; i < search.length; ++i) {
search[i].style.backgroundColor = darkModeLightBlack;
}
// -------------------------- TABLE ------------------------------
var tableBody = document.querySelectorAll('.AType tbody tr td');
for (i = 0; i < tableBody.length; ++i) {
tableBody[i].style.background = darkModetbody;
}
var tableHead = document.querySelectorAll('.AType thead tr th');
for (i = 0; i < tableHead.length; ++i) {
tableHead[i].style.background = darkModethead;
}
// -------------------------- PAGING -----------------------------
var paging = document.querySelectorAll('.paging li');
for (i = 0; i < paging.length; ++i) {
var cur = paging[i].getElementsByTagName('a')[0];
if (paging[i].className == 'active') {
cur.style.color = '#000000';
} else {
cur.style.color = 'white';
}
}
// --------------------- ASSIGMENT MAIN PAGE-----------------------
// ----------------------------------------------------------------
// ------------------------ BOTTOM TEXT ---------------------------
var text = document.querySelectorAll('.popWindow div');
if (text.length > 0) {
text[text.length - 1].style.color = darkModeLightBlue;
}
// ---------------------- DATE TEXT (BLUE) ------------------------
var dateText = document.querySelectorAll(".AType tbody tr td font");
for (i = 0; i < dateText.length; i++) {
var cur = dateText[i];
if (cur.getAttribute('color') == 'blue') {
cur.style.color = darkModeLightBlue;
}
}
// ------------------------ ASSIGMENT PAGE -------------------------
//----------------------------- TABLE ------------------------------
var table = document.getElementsByClassName('contsubtitle icon');
for (i = 0; i < table.length; i++) {
table[i].style.backgroundColor = darkModeLightBlack;
}
var tr = document.querySelectorAll('.tablegw tbody tr');
for (i = 0; i < tr.length; i++) {
var th = tr[i].getElementsByTagName('th');
var td = tr[i].getElementsByTagName('td');
for (var j = 0; j < th.length; j++) {
th[j].style.backgroundColor = darkModethead;
}
for (var j = 0; j < td.length; j++) {
td[j].style.backgroundColor = darkModetbody;
}
}
var fileherf = document.querySelectorAll('.board_viewfile a')
for (i = 0; i < fileherf.length; i++) {
fileherf[i].style.color = "white"
}
// ------------------------ CLASS MATERIALS ------------------------
var info = document.getElementsByClassName('board_view_header');
if (info.length > 0) {
info[0].style.background = darkModethead;
}
var file = document.getElementsByClassName('board_viewfile');
for (i = 0; i < file.length; i++) {
var cur = file[i];
cur.style.backgroundColor = darkModeLightBlack;
var span = cur.getElementsByTagName('span');
span[0].style.color = 'white';
span[1].style.color = darkModeLightBlue;
cur.getElementsByTagName('a')[0].style.color = 'white';
}
var textherf = document.querySelectorAll('.board_viewDetail div p a');
for (i = 0; i < textherf.length; i++) {
textherf[i].style.color = "white"
}
var comment = document.getElementsByClassName('text first');
for (i = 0; i < comment.length; i++) {
var cur = comment[i].getElementsByTagName('pre');
if (cur.length > 0) {
cur[0].style.backgroundColor = darkModeLightBlack;
cur[0].style.color = 'white';
}
}
}
function getCookie(cName) {
cName = cName + '=';
var cookieData = document.cookie;
var start = cookieData.indexOf(cName);
var cValue = '';
if (start != -1) {
start += cName.length;
var end = cookieData.indexOf(';', start);
if (end == -1) end = cookieData.length;
cValue = cookieData.substring(start, end);
}
return unescape(cValue);
}