This repository has been archived by the owner on Sep 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eventEditor.html
396 lines (366 loc) · 16 KB
/
eventEditor.html
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
<html>
<link rel="stylesheet" href="main.css" />
<meta charset="utf8" />
<div
style="
width: 100vw;
overflow: auto;
height: 100vh;
margin-top: -8px;
margin-left: -8px;
filter: blur(22px);
border-radius: 14px;
transition:
scale 0.3s ease,
filter 0.5s ease;
scale: 0.1;
"
id="everything_container"
>
<div
id="editorContent"
style="
height: 90vh;
width: 100vw;
background-color: #ffffff10;
overflow: auto;
"
>
<div class="ring"></div>
</div>
<div
id="selectorMenu"
class="flexbox"
style="
height: auto;
justify-content: left;
width: 100vw;
background-color: #ffffff08;
"
>
<div
id="buttonsContainer"
class="flexbox"
style="width: 100vw; height: 10vh; transition: scale 5.3s ease"
>
<div
class="barbuttonshift flexbox"
id="eventSearchButton"
onclick="eventSearch()"
style="margin-left: 1vw; width: 20vw; margin-right: auto"
>
<div
class="image switchObjs"
style="
width: 25% !important;
height: 30px !important;
margin: auto;
"
></div>
<div style="margin: auto">
<div class="barbuttontexta">Change Event</div>
<div class="smalltext" style="opacity: 50%; font-size: 8px">
CTRL+K
</div>
</div>
</div>
<div class="barbuttontexta" id="event-name"></div>
<div
class="barbuttonshift flexbox"
style="margin-right: 1vw; width: 13vw; margin-left: auto"
onclick="closeEvent()"
>
<div
class="image checkmark"
style="
width: 30% !important;
height: 30px !important;
margin: auto !important;
"
></div>
<div style="margin: auto">
<div class="barbuttontexta">Close</div>
<div class="smalltext" style="opacity: 50%; font-size: 8px">
CTRL+TAB
</div>
</div>
</div>
</div>
</div>
</div>
<script src="./AppData/Kits/Loader.js"></script>
<script src="./AppData/Kits/settings.js"></script>
<script>
var datjson = JSON.parse(fs.readFileSync("./AppData/data.json"));
let themeColor = datjson.color;
document.getElementById(
"everything_container",
).style.background = `linear-gradient(45deg, ${themeColor} 0%, #121212 ${editorSettings.smoothness})`;
document.body.style.transition = "all 0.2s ease";
document.body.style.backgroundColor = "#FFFFFF00";
const { ipcRenderer } = require("electron");
let data, event, __data;
document.onkeydown = function (event) {
if (event.key == "Tab" && event.ctrlKey == true) {
closeEvent();
}
if (event.key.toLowerCase() == "q" && event.ctrlKey == true) {
closeEvent();
}
if (event.key.toLowerCase() == "k" && event.ctrlKey == true) {
if (document.getElementById("eventSearchCloseButton")) {
closeEvents();
} else {
eventSearch();
}
}
};
function updateEventData(at, content) {
data[at] = content;
__data.data[at] = content;
}
ipcRenderer.on("eventData", (builtinEvent, _data) => {
document.getElementById(
"everything_container",
).style.transition = `all 0.${editorSettings.commonAnimation}s ease`;
document.getElementById("everything_container").style.scale = "1";
document.getElementById("everything_container").style.filter =
"blur(0px)";
__data = _data;
data = _data.data;
event = require(`./AppData/Events/${__data.file}`);
document.getElementById(
"event-name",
).innerHTML = `<span style="opacity: 50%">Event:</span> ${event.name}`;
document.getElementById('editorContent').innerHTML = `
<div class="barbuttontext" style="margin-top: 12px; margin-left: 1.5vw;"><span style="opacity: 0.5">On</span> ${event.name}</div>
<div class="sepbar noanims" style="margin-top: 4px; margin-bottom: 7px; width: 97%;"></div>
`
for (let element in event.nameSchemes) {
document.getElementById('editorContent').innerHTML += `
<btext style="margin-left: 3vw; text-align: left;">${event.nameSchemes[element]}</btext>
<input oninput="updateEventData(${element}, this.value)" value="${data[element]}">
`
}
});
function updateEventData(dataIndex, data) {
__data.data[dataIndex] = data
}
function validateInput(event) {
const div = event.target;
const text = div.textContent;
// Save the current cursor position
const selection = window.getSelection();
const range = selection.getRangeAt(0);
const offset = range.startOffset;
// Remove image tags
const sanitizedText = text.replace(/<img\b[^>]*>/gi, "");
// Update the content of the div with sanitized text
div.innerHTML = sanitizedText;
// Restore the cursor position
const updatedRange = document.createRange();
updatedRange.setStart(div.firstChild, offset);
updatedRange.collapse(true);
selection.removeAllRanges();
selection.addRange(updatedRange);
}
function closeEvent() {
document.getElementById("everything_container").style.scale = "0";
document.body.style.transition = "all 0.2s ease";
document.body.style.backgroundColor = "#FFFFFF00";
document.getElementById("everything_container").style.filter =
"blur(40px)";
setTimeout(() => {
ipcRenderer.send("eventClosed", __data);
}, 500);
}
let pendingSearchStart = false;
function eventSearch() {
if (pendingSearchStart == true) return;
pendingSearchStart = true;
document.getElementById("eventSearchButton").onclick = (event) => {
event.preventDefault();
};
let searchContainer = document.getElementById("selectorMenu");
let eventView = document.getElementById("editorContent");
searchContainer.style.transition = "all 0.3s ease";
eventView.style.transition = "all 0.3s ease";
setTimeout(() => {
let buttonsContainer = document.getElementById("buttonsContainer");
buttonsContainer.style.transition = "all 0.3s ease";
buttonsContainer.style.height = "0vh";
buttonsContainer.style.overflow = "auto";
pendingSearchStart = false;
}, 200);
searchContainer.style.height = "85vh";
eventView.style.scale = "0.8";
eventView.onclick = (event) => {
event.preventDefault();
};
eventView.style.borderRadius = "10px";
eventView.style.height = "15vh";
searchContainer.innerHTML += `
<div id="eventSearchCloseButton" onclick="closeEvents()" class="barbuttonshift" style="width: 95% !important; margin: auto; margin-top: 1vh; margin-bottom: 1vh;"><div class="barbuttontexta">Close</div></div>
<input class="input" id="searchHolder" oninput="queryEvents(this.value)" placeholder="Search" style="padding: 20px; width: 97%; padding-left: 11px; padding-right: 11px;">
<div class='flexbox' id="searchEvents" style="height: 67vh; overflow: auto; margin-top: 2vh; align-items: flex-start; align-content: start; width: 100%;"></div>
`;
viewAllEvents();
setTimeout(() => {
document.getElementById('searchHolder').focus()
}, 600);
}
let cachedEvents = [];
function queryEvents(query) {
if (query == "") {
viewAllEvents();
return;
}
let matchNo = 0;
document.getElementById("searchEvents").innerHTML = "";
for (let event in cachedEvents) {
if (fuzzyMatch(cachedEvents[event].name, query, 0.02)) {
matchNo++
if (editorSettings.searchStyling == 'grid') {
const animationId = cachedEvents[event].file
document.getElementById("searchEvents").innerHTML += `
<div class="hoverablez dimension fade" onclick="switchOutEvent('${cachedEvents[event].file}')" style="border-radius: 8px; width: 29%; overflow: auto; padding: 5px; padding-left: 5px; padding-right: 5px; margin-left: 0.5vw; margin-right: 0.5vw; margin-bottom: 1vh;"><div class="barbuttontexta">${cachedEvents[event].name}</div></div>
`;
} else {
document.getElementById("searchEvents").style.alignItems = ''
document.getElementById("searchEvents").innerHTML = "";
document.getElementById("searchEvents").innerHTML += `
<div class="hoverablez dimension fade" onclick="switchOutEvent('${cachedEvents[event].file}')" class="hoverablez dimension fade" style="border-radius: 7px; width: calc(95% - 10px); padding: 5px; margin-bottom: 1vh; margin-right: auto; margin-left: auto; overflow: auto;"><div class="barbuttontexta" style="margin-left: 1vw; text-align: left;">${cachedEvents[event].name}</div></div>
`;
}
}
}
if (matchNo == 0) {
if (editorSettings.searchStyling == 'grid') {
document.getElementById("searchEvents").innerHTML += `
<div class="dimension fade" style="background-color: #FFFFFF08; padding: 7px; border-radius: 12px; width: calc(95% - 14px); margin-bottom: 2vh;">
<div class="barbuttontexta" style="margin-left: 1vw !important; text-align: left;">No Matches Found</div>
<div onclick="viewAllEvents()" class="hoverablez dimension" style="border-radius: 9px; width: 95%; margin-left: auto !important; margin-right: auto !important; padding: 5px; padding-left: 5px; padding-right: 5px; margin-left: 0.5vw; margin-right: 0.5vw;"><div class="barbuttontexta">View All Events</div></div>
</div>
`;
} else {
document.getElementById('searchEvents').innerHTML = `
<div class="dimension fade" style="background-color: #FFFFFF08; padding: 7px; border-radius: 7px; width: calc(95% - 14px); margin-bottom: 2vh; margin: auto;">
<div class="barbuttontexta" style="margin-left: 0.3vw !important; text-align: left;">No Matches Found</div>
<div onclick="viewAllEvents()" class="hoverablez dimension" style="border-radius: 7px; width: calc(100% - 10px); padding: 5px; padding-left: 5px; padding-right: 5px; margin: auto;"><div class="barbuttontexta">View All Events</div></div>
</div>
`
}
}
}
function closeEvents() {
let closeButton = document.getElementById("eventSearchCloseButton");
closeButton.nextElementSibling.style.transition = "all 0.4s ease";
closeButton.nextElementSibling.nextElementSibling.style.transition =
"all 0.4s ease";
closeButton.nextElementSibling.style.height = "0vh";
closeButton.nextElementSibling.nextElementSibling.style.height = "0vh";
document.getElementById("eventSearchButton").onclick = () => {
eventSearch();
};
let searchContainer = document.getElementById("selectorMenu");
let eventView = document.getElementById("editorContent");
searchContainer.style.transition = "all 0.3s ease";
eventView.style.transition = "all 0.3s ease";
closeButton.nextElementSibling.onclick = (event) => {
event.preventDefault();
};
setTimeout(() => {
let buttonsContainer = document.getElementById("buttonsContainer");
buttonsContainer.style.transition = "all 0.3s ease";
buttonsContainer.style.height = "10vh";
buttonsContainer.style.overflow = "auto";
setTimeout(() => {
closeButton.nextElementSibling.remove();
closeButton.nextElementSibling.remove();
closeButton.remove();
}, 300);
}, 300);
searchContainer.style.height = "10vh";
eventView.style.scale = "1";
eventView.onclick = (event) => {};
eventView.style.borderRadius = "0px";
eventView.style.height = "90vh";
}
function fuzzyMatch(str, pattern, accuracy) {
pattern = pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
pattern = pattern.split("").reduce((a, b) => a + `.*${b}`, "");
const regex = new RegExp(pattern, "i");
const matchScore = str.match(regex) ? str.match(regex)[0].length : 0;
const requiredScore = str.length * accuracy;
return matchScore >= requiredScore;
}
function switchOutEvent(newEventFile) {
let newEvent = require(`./AppData/Events/${newEventFile}`);
__data.name = newEvent.name;
__data.file = newEventFile;
event = newEvent;
document.getElementById(
"event-name",
).innerHTML = `<span style="opacity: 50%">Event:</span> ${event.name}`;
document.getElementById('editorContent').innerHTML = `
<div class="barbuttontext" style="margin-top: 12px; margin-left: 1.5vw;"><span style="opacity: 0.5">On</span> ${event.name}</div>
<div class="sepbar noanims" style="margin-top: 4px; margin-bottom: 7px; width: 97%;"></div>
`
for (let element in event.nameSchemes) {
if (!__data.data[element]) {
__data.data[element] = ''
}
document.getElementById('editorContent').innerHTML += `
<btext style="margin-left: 3vw; text-align: left;">${event.nameSchemes[element]}</btext>
<input oninput="updateEventData(${element}, this.value)" value="${data[element]}">
`
}
closeEvents();
}
function viewAllEvents() {
let timeout = 0;
document.getElementById("searchEvents").innerHTML = "";
if (cachedEvents[0] == undefined) {
let events = fs.readdirSync("./AppData/Events");
for (let eventFile in events) {
let evt = require("./AppData/Events/" + events[eventFile]);
cachedEvents.push({
name: evt.name,
file: events[eventFile],
});
}
}
for (let event in cachedEvents) {
if (editorSettings.searchStyling == 'grid') {
timeout++;
const animationId = cachedEvents[event].file
document.getElementById("searchEvents").innerHTML += `
<div class="hoverablez dimension" id="${animationId}" onclick="switchOutEvent('${cachedEvents[event].file}')" style="border-radius: 8px; width: 29%; overflow: auto; padding: 5px; padding-left: 5px; padding-right: 5px; margin-left: 0.5vw; margin-right: 0.5vw; margin-bottom: 1vh; transition: all 0.5s cubic-bezier(.17,.67,.31,1.34), scale 0.3s cubic-bezier(.17,.67,.31,1.36), opacity 0.1s ease; opacity: 0%; scale: 0.7;"><div class="barbuttontexta">${cachedEvents[event].name}</div></div>
`;
setTimeout(() => {
document.getElementById(animationId).style.opacity = "100%";
document.getElementById(animationId).style.width = "29%";
document.getElementById(animationId).style.scale = "1";
}, timeout * 15);
} else {
document.getElementById("searchEvents").style.alignItems = ''
document.getElementById("searchEvents").innerHTML = "";
for (let event in cachedEvents) {
timeout++;
const animationId = cachedEvents[event].file
document.getElementById("searchEvents").innerHTML += `
<div class="hoverablez dimension" id='${animationId}' onclick="switchOutEvent('${cachedEvents[event].file}')" class="hoverablez dimension fade" style="border-radius: 7px; scale: 0.1; opacity: 10%; width: calc(50% - 10px); padding: 5px; margin-bottom: 1vh; margin-right: auto; margin-left: auto; transition: all 0.5s cubic-bezier(.17,.67,.31,1.34), scale 0.3s ease, opacity 0.3s ease; overflow: auto;"><div class="barbuttontexta" style="margin-left: 1vw; text-align: left;">${cachedEvents[event].name}</div></div>
`;
try {
setTimeout(() => {
document.getElementById(animationId).style.opacity = "100%";
document.getElementById(animationId).style.width = "calc(95% - 10px)";
document.getElementById(animationId).style.scale = "1";
}, timeout * 15);
} catch (e) {}
}
}
}
}
</script>
</html>