-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdate_Classes.html
More file actions
268 lines (239 loc) · 8.1 KB
/
Copy pathUpdate_Classes.html
File metadata and controls
268 lines (239 loc) · 8.1 KB
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
<!--Nav Template Start-->
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=0.5">
<title>Class Updater - SyndiShanX</title>
<link rel="stylesheet" href="Fonts/Font_Awesome.min.css">
<link rel="icon" href="Images/Global/Icon_Tab.webp">
<link rel="stylesheet" href="GlobalCSS.css">
<style type="text/css">
.fileInputVisible, .outputButton {
background-color: rgba(255, 255, 255, 0.25);
padding: 28px;
color: #fff;
font: 28px Arial;
font-weight: bold;
text-align: center;
border: 1px solid #5c5c5c;
border-radius: 8px;
cursor: pointer;
}
.outputButton {
padding: 18px;
margin: 10px;
color: #fff;
font: 18px Arial;
font-weight: bold;
text-align: center;
border: 1px solid #5c5c5c;
border-radius: 8px;
cursor: pointer;
}
.fileInputVisible:hover, .outputButton:hover {
background-color: rgba(255, 255, 255, 0.15);
border: 1px solid #c0c0c0;
}
.fileInputVisible:disabled, .outputButton:disabled {
background-color: rgba(255, 255, 255, 0.05);
border: 1px solid #1a1a1a;
cursor: not-allowed;
}
.fileInput {
display: none;
}
.container {
background-image: var(--bgImageDark)!important;
background-clip: border-box!important;
background-origin: padding-box!important;
background-attachment: scroll!important;
background-repeat: repeat!important;
background-size: auto!important;
background-position: left top!important;
border: 1px solid #5c5c5c;
border-radius: 8px;
min-width: 800px;
width: 50%;
height: fit-content;
padding-bottom: 50px;
}
#themeTextArea {
background-image: var(--bgImage)!important;
background-clip: border-box!important;
background-origin: padding-box!important;
background-attachment: scroll!important;
background-repeat: repeat!important;
background-size: auto!important;
background-position: left top!important;
border: 1px solid #5c5c5c;
border-radius: 8px;
width: 80%;
height: 200px;
color: #fff;
resize: none;
}
.link {
color: #35afea;
font-weight: bold;
}
.theme {
background-color: #35afea!important;
}
.theme:hover {
background-color: #1e7dcb!important;
}
</style>
</head>
<body lang="">
<div class="MainWrapper" align="center">
<!--Nav Template End-->
<br><br><br>
<div class='container'><br><br>
<h3 style='color: #fff;'>Either Upload your Theme File or Paste it into the Textarea</h3>
<h4 style='color: #fff;'>(Optional) Either Upload a Custom Diff File or Use the <a class="link" target=”_blank” href="https://syndishanx.github.io/Update-Classes/Changes.txt">Included One</a></h3><br><br><br>
<label for='theme-file' class='fileInputVisible theme' role='button'>Upload Theme File</label><label for='diff-file' class='fileInputVisible' role='button' style="margin-left: 5%;">Upload Diff File</label>
<input id='theme-file' type='file' class='fileInput' onchange='loadThemeFile()'style='color: #fff;'><br>
<input id='diff-file' type='file' class='fileInput' onchange='loadChangesFile()'style='color: #fff;'><br><br><br>
<font style='color: #fff; font: 18px Arial; font-weight: bold;' id='textAreaStatus'>Awaiting Input...</font><br><br>
<textarea id='themeTextArea' placeholder="Paste CSS here to update it"></textarea><br><br>
<button class='outputButton' onClick='output("file")'>Download Updated Theme</button>
<button class='outputButton' onClick='output("clipboard")'>Copy to Clipboard</button><br>
<h4 style='color: #fff;'>Credits:</h4>
<div id='creditsURL'></div>
<font style='display: none;' id='regex'></font>
<font style='display: none;' id='diffFileURL'></font>
<font style='display: none;' id='diffFile'></font>
</div>
<!--Nav Template Start-->
</div>
<script>
let update_timeout;
document.getElementById('themeTextArea').addEventListener('input', () => {
clearTimeout(update_timeout);
update_timeout = setTimeout(updateClasses("textarea"), 200);
});
async function loadChangesFileURL() {
const url = 'https://syndishanx.github.io/Update-Classes/Changes.txt'
let rawFile = await fetch(url);
let rawText = await rawFile.text();
document.getElementById('diffFileURL').innerHTML = rawText
const regexUrl = 'https://syndishanx.github.io/Update-Classes/Regex_Changes.txt'
let rawRegexFile = await fetch(regexUrl);
let rawRegexText = await rawRegexFile.text();
document.getElementById('regex').innerHTML = rawRegexText
const creditsURL = 'https://syndishanx.github.io/Update-Classes/Credits.txt'
let rawCreditsFile = await fetch(creditsURL);
let rawCreditsText = await rawCreditsFile.text();
document.getElementById('creditsURL').innerHTML = rawCreditsText
}
loadChangesFileURL()
function loadChangesFile() {
input = document.getElementsByClassName('fileInput')[1];
if (typeof window.FileReader !== 'function') {
alert("The file API isn't supported on this browser yet");
return;
}
if (!input) {
alert('Unable to find the fileInput element');
} else if (!input.files) {
alert("This browser doesn't seem to support the `files` property of file inputs");
} else {
file = input.files[0];
fr = new FileReader();
fr.onload = function () { document.getElementById('diffFile').textContent = fr.result; }
fr.readAsText(file);
}
}
function loadThemeFile() {
var input, file, fr;
if (typeof window.FileReader !== 'function') {
alert("The file API isn't supported on this browser yet");
return;
}
input = document.getElementsByClassName('fileInput')[0];
if (!input) {
alert('Unable to find the fileInput element');
} else if (!input.files) {
alert("This browser doesn't seem to support the `files` property of file inputs");
} else {
file = input.files[0];
fr = new FileReader();
fr.onload = receivedText;
fr.readAsText(file);
outputName = file.name
themeFile = fr
document.getElementById('themeTextArea').style = 'display: none;'
document.getElementById('textAreaStatus').innerHTML = 'Updating...'
document.getElementsByTagName('br')[12].remove()
document.getElementsByTagName('br')[12].remove()
}
async function receivedText(e) {
let lines = e.target.result;
}
setTimeout(() => {updateClasses();}, 500);
}
function updateClasses(inputMethod) {
document.getElementById('textAreaStatus').innerHTML = 'Updating...'
var i = 0
if (document.getElementsByClassName('fileInput')[1].files.length != 1) {
rawText = document.getElementById('diffFileURL').innerHTML
} else {
rawText = document.getElementById('diffFile').innerHTML
}
//console.log(rawText)
classNum = rawText.split('\n').length - 1
changesText = rawText.split('\n')
if (inputMethod == 'textarea') {
themeText = document.getElementById('themeTextArea').value
} else {
if (document.getElementById('themeTextArea').value != '') {
themeText = document.getElementById('themeTextArea').value
} else {
themeText = themeFile.result
}
}
rawRegexText = document.getElementById('regex').innerHTML
rawRegexTextSplit = rawRegexText.split('\n')
regex_replaced = false
for (let x = 0; x < rawRegexTextSplit.length; x++) {
if(themeText.includes(rawRegexTextSplit[x])) {
themeText = themeText.replace(/\.([_0-9a-f]{6})[0-9a-f]{10,11}-([A-Za-z0-9_\-]+)/g, '.$2_$1')
regex_replaced = true
}
}
if(regex_replaced == false) {
while (i < classNum) {
class1 = changesText[i].split('\r')[0]
class2 = changesText[i + 1].split('\r')[0]
themeText = themeText.replaceAll(class1, class2)
i = i + 2
}
}
document.getElementById('themeTextArea').value = themeText
document.getElementById('textAreaStatus').innerHTML = 'Updated!'
}
function output(outputMethod) {
if (outputMethod == 'file') {
var synOutput = document.createElement('a');
if (document.getElementById('themeTextArea').value != '') {
outputName = 'Output.theme.css'
}
const blob = new Blob([themeText], { type: 'text/plain' });
url = URL.createObjectURL(blob);
synOutput.download = outputName;
synOutput.href = url;
synOutput.click();
} else if (outputMethod == 'clipboard') {
if (document.getElementById('themeTextArea').value != '') {
navigator.clipboard.writeText(document.getElementById('themeTextArea').value);
} else {
navigator.clipboard.writeText(themeText);
}
}
}
</script>
<script src="GlobalNavbar.js"></script>
<script src="GlobalNavbarFixer.js"></script>
</body>
</html>
<!--Nav Template End-->