-
Notifications
You must be signed in to change notification settings - Fork 180
/
Copy pathapp.js
447 lines (421 loc) · 15.5 KB
/
app.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
const bar = document.getElementById("sidebar");
const overflowMenu = document.getElementById("overflow-menu");
document.addEventListener("click", function () {
bar.classList.remove("movingbar");
});
document.addEventListener("mousemove", function (event) {
if (event.clientX <= 5 && bar.classList.contains("movingbar") !== true) {
bar.classList.add("movingbar");
}
});
//**Above is the universal code for every MacWeb JavaScript file**//
const google = ["Google", "/macvg/media/google.png"];
const canva = ["Home - Canva", "/macvg/media/canva.png"];
const clever = ["Clever | Portal", "/macvg/media/clever.png"];
const schoology = ["Home | Schoology", "/macvg/media/schoology.png"];
const newTab = ["New Tab", "/macvg/media/new-tab.png"];
function google1() {
localStorage.setItem("title", google);
}
function canva1() {
localStorage.setItem("title", canva);
}
function clever1() {
localStorage.setItem("title", clever);
}
function schoology1() {
localStorage.setItem("title", schoology);
}
function newTab1() {
localStorage.setItem("title", newTab);
}
function unCloak() {
const pageTon = document.querySelector(".cloak");
const favicon = document.querySelector(".favicon");
favicon.outerHTML = `<link class="favicon" rel="icon" type="image/x-icon" href="/macvg/media/logo.png" />`;
pageTon.innerHTML = "Settings | MacVG";
localStorage.setItem("title", "");
}
function cloaking() {
const name = document.getElementById("name").value;
const favicon = document.querySelector(".favicon");
localStorage.title = name + "," + favicon.href;
}
function faviconing() {
const pageTon = document.querySelector(".cloak");
const favicon = document.querySelector(".favicon");
const faviSRC = document.getElementById("name4").value;
let thingy = [pageTon.innerHTML, faviSRC];
favicon.outerHTML = `<link class="favicon" rel="icon" type="image/x-icon" href="${faviSRC}" />`;
localStorage.setItem("title", thingy);
}
function changeName() {
if (localStorage.title !== "") {
const pageTon = document.querySelector(".cloak");
const favicon = document.querySelector(".favicon");
if (localStorage.title != null) {
let all = localStorage.getItem("title");
let alln = all.split(",");
let title = alln[0];
let image = alln[1];
pageTon.innerHTML = title;
setInterval(() => {
pageTon.innerHTML = title;
}, 3000);
favicon.outerHTML = `<link class="favicon" rel="icon" type="image/x-icon" href="${image}" />`;
}
}
}
//Above are the codes for tab cloaker and panic key
function sortStuff(targetArray, key) {
if (key === "name") {
targetArray.sort((a, b) => {
const nameA = a.name.toUpperCase();
const nameB = b.name.toUpperCase();
if (nameA < nameB) {
return -1;
}
if (nameA > nameB) {
return 1;
}
return 0;
});
newArray = targetArray;
let finalArrayIds = [];
let finalGames = [];
targetArray.forEach((item) => {
finalArrayIds.push(item.id);
finalGames.push(item.name);
});
arrangeBoxes(finalGames, finalArrayIds);
} else if (key === "catagory") {
targetArray.sort((a, b) => {
const nameA = a.catagory.toUpperCase();
const nameB = b.catagory.toUpperCase();
if (nameA < nameB) {
return -1;
}
if (nameA > nameB) {
return 1;
}
return 0;
});
newArray = targetArray;
let finalArrayIds = [];
let finalGames = [];
targetArray.forEach((item) => {
finalArrayIds.push(item.id);
finalGames.push(item.name);
});
arrangeBoxes(finalGames, finalArrayIds);
} else if (key === "direction") {
let gameList = document.getElementById("list").querySelectorAll(".game");
gameList = [...gameList].reverse();
let finalArrayIds = [];
let finalGames = [];
gameList.forEach((item) => {
finalArrayIds.push(item.getAttribute("id").slice(4));
finalGames.push(item.innerHTML);
});
arrangeBoxes(finalGames, finalArrayIds);
}
}
function filterStuff(colorArray, color) {
if (
color === "action" ||
color === "strategy" ||
color === "casual" ||
color === "driving"
) {
let finalArray = [];
let finalArrayIds = [];
colorArray.forEach((item) => {
if (item.catagory === color) {
finalArray.push(item.name);
finalArrayIds.push(item.id);
}
});
secondArray = finalArray;
arrangeBoxes(finalArray, finalArrayIds);
} else if (color === "featured") {
let finalArray = [];
let finalArrayIds = [];
colorArray.forEach((item) => {
if (item.featured) {
finalArray.push(item.name);
finalArrayIds.push(item.id);
}
});
secondArray = finalArray;
arrangeBoxes(finalArray, finalArrayIds);
} else if (color === "download") {
let finalArray = [];
let finalArrayIds = [];
colorArray.forEach((item) => {
if (item.download) {
finalArray.push(item.name);
finalArrayIds.push(item.id);
}
});
secondArray = finalArray;
arrangeBoxes(finalArray, finalArrayIds);
} else {
let finalArrayIds = [];
let finalArrayNames = [];
everythingArray.forEach((item) => {
finalArrayIds.push(item.id);
finalArrayNames.push(item.name);
});
arrangeBoxes(finalArrayNames, finalArrayIds);
}
}
function arrangeBoxes(newArrayy, newIds) {
filterGamesList.innerHTML = "";
let arrayIndex = 0;
newArrayy.forEach((element) => {
let newBox = document.createElement("a");
newBox.classList.add("game");
newBox.setAttribute("id", `game${newIds[arrayIndex]}`);
newBox.innerHTML = element;
everythingArray.forEach((item) => {
if (item.id == newIds[arrayIndex]) {
newBox.style.backgroundImage = `linear-gradient(
rgba(40, 40, 40, 0.2),
rgba(20, 20, 20, 0.9)
),
url("${item.link + item.thumb}")`;
newBox.addEventListener("click", () => {
const params = new URLSearchParams({ target: item.id });
window.location.href = `game.html?${params.toString()}`;
});
}
});
filterGamesList.appendChild(newBox);
/*let computedStyle = window.getComputedStyle(newBox).backgroundImage;
let computedStylee = computedStyle.substring(
computedStyle.indexOf(`url("`) + 5
);
const projectsPosition = computedStylee.indexOf("projects/");
const slashIndex = computedStylee.indexOf(
"/",
projectsPosition + "projects/".length
);
let computedStyleee = computedStylee.substring(0, slashIndex);*/
filterGamesList.removeChild(newBox);
//newBox.setAttribute("href", computedStyleee);
filterGamesList.appendChild(newBox);
arrayIndex++;
});
}
//Above are the codes for filtering and sorting
function updateTheme() {
let theme = localStorage.getItem("theme");
if (theme === "light") {
const root = document.documentElement;
root.style.setProperty("--link", "rgb(225, 139, 9)");
root.style.setProperty("--text-color", "black");
root.style.setProperty("--shadow-color", "0px 0px 5px rgb(84, 84, 84)");
root.style.setProperty("--black-color", "rgb(235, 235, 235)");
root.style.setProperty("--bg-color", "rgb(235, 235, 235)");
root.style.setProperty("--bg-color-2", "rgb(30, 30, 30)");
root.style.setProperty("--group-bg-color", "rgb(140, 140, 140, 0.7)");
root.style.setProperty("--bar-color", "rgb(200, 200, 200)");
} else if (theme === "deep") {
const root = document.documentElement;
root.style.setProperty("--text-color", "white");
root.style.setProperty("--link", "rgb(225, 139, 9)");
root.style.setProperty("--shadow-color", "0px 5px 5px rgb(25,25,25)");
root.style.setProperty("--black-color", "black");
root.style.setProperty("--bg-color", "black");
root.style.setProperty("--bg-color-2", "black");
root.style.setProperty("--group-bg-color", "black");
root.style.setProperty("--bar-color", "black");
root.style.setProperty("--border", "rgb(50,50,50)");
} else if (theme === "cyber") {
const root = document.documentElement;
root.style.setProperty("--link", "rgb(225, 139, 9)");
root.style.setProperty("--text-color", "white");
root.style.setProperty("--shadow-color", "0px 5px 5px #42053f");
root.style.setProperty("--black-color", "black");
root.style.setProperty("--bg-color", "#0b023a");
root.style.setProperty("--bg-color-2", "#ff00a0");
root.style.setProperty("--group-bg-color", "rgba(48, 4, 98, 0.7)");
root.style.setProperty("--bar-color", "#12827e");
root.style.setProperty("--border", "rgb(50,50,50)");
} else if (theme === "custom") {
const root = document.documentElement;
let first = localStorage.getItem("first");
let second = localStorage.getItem("second");
document.documentElement.style.setProperty("--bg-color", first);
document.documentElement.style.setProperty("--bar-color", second);
document.documentElement.style.setProperty("--link", second);
document.documentElement.style.setProperty("--text-color", "white");
document.documentElement.style.setProperty("--black-color", "black");
root.style.setProperty("--shadow-color", "transparent");
root.style.setProperty("--bg-color-2", "white");
root.style.setProperty("--group-bg-color", second);
} else {
const root = document.documentElement;
root.style.setProperty("--text-color", "white");
root.style.setProperty("--link", "rgb(225, 139, 9)");
root.style.setProperty("--shadow-color", "transparent");
root.style.setProperty("--black-color", "black");
root.style.setProperty("--bg-color", "rgb(50, 50, 50)");
root.style.setProperty("--bg-color-2", "white");
root.style.setProperty("--group-bg-color", "rgba(40, 40, 40, 0.7)");
root.style.setProperty("--bar-color", "rgb(70, 70, 70)");
}
}
function glowingTitle() {
let hue = 0;
const root = document.documentElement;
setInterval(() => {
hue = (hue + 3) % 360;
root.style.setProperty("--f-t-color", `hsl(${hue}, 100%, 70%)`);
root.style.setProperty("--s-t-color", `hsl(${hue + 60}, 100%, 70%)`);
root.style.setProperty("--t-t-color", `hsl(${hue + 130}, 100%, 70%)`);
}, 300);
}
function setGameNames() {
const games = document.querySelectorAll(".game");
games.forEach(function (game) {
game.addEventListener("mouseover", function () {
let innerThing = game.innerHTML;
game.setAttribute("name", innerThing);
});
});
}
function select() {
let list = document.getElementById("list");
let items = list.getElementsByTagName("a");
let itemsL = Array.from(items);
let r = Math.random();
let rw = Math.floor(r * 399);
let selected = items[rw];
itemsL.forEach(function (item) {
if (item.contains(selected)) {
let list = document.getElementById("randomList");
item.setAttribute("name", item.innerHTML);
item.style.paddingBlock = "10px";
list.innerHTML = item.outerHTML;
let id = item.getAttribute("id").slice(4);
list.children[0].addEventListener("click", () => {
const params = new URLSearchParams({ target: id });
window.location.href = `game.html?${params.toString()}`;
});
}
});
}
function search() {
let searchInput = document.getElementById("searchInput");
const searchClear = document.getElementById("search-clear");
if (searchInput.value.trim() !== "") {
searchClear.style.display = "flex";
searchClear.addEventListener("click", () => {
searchInput.value = "";
searchClear.style.display = "none";
var list = document.getElementById("list");
var items = list.getElementsByTagName("a");
for (var i = 0; i < items.length; i++) {
items[i].style.display = "flex";
}
searchInput.focus();
});
}
var searchTerm = document.getElementById("searchInput").value.toLowerCase();
var list = document.getElementById("list");
var items = list.getElementsByTagName("a");
for (var i = 0; i < items.length; i++) {
var item = items[i];
var itemText = item.innerText.toLowerCase();
if (itemText.includes(searchTerm)) {
item.style.display = "flex";
} else {
item.style.display = "none";
}
}
}
setGameNames();
changeName();
updateTheme();
glowingTitle();
document.addEventListener("DOMContentLoaded", function () {
const bar = document.getElementById("sidebar");
const helpMenus = document.querySelectorAll(".help-label");
document.addEventListener("click", function () {
bar.classList.remove("movingbar");
});
document.addEventListener("mousemove", function (event) {
if (event.clientX <= 5 && bar.classList.contains("movingbar") !== true) {
bar.classList.add("movingbar");
}
});
document.addEventListener("click", (e) => {
if (!e.target.classList.contains("help-menu")) {
helpMenus.forEach((helpMenu) => {
helpMenu.parentElement.querySelector(".cats").style.transform =
"scaleY(0)";
helpMenu.parentElement.removeAttribute("style");
helpMenu.parentElement.querySelector(".caret").removeAttribute("style");
});
}
});
helpMenus.forEach((helpMenu) => {
helpMenu.addEventListener("click", () => {
let transformValue = window
.getComputedStyle(helpMenu.parentElement.querySelector(".cats"))
.getPropertyValue("transform");
console.log(transformValue);
if (transformValue !== "matrix(1, 0, 0, 1, 0, 0)") {
helpMenu.parentElement.style.backgroundColor = "rgba(15, 15, 15, 0.8)";
helpMenu.parentElement.querySelector(".cats").style.transform =
"scaleY(1)";
helpMenu.parentElement.querySelector(".caret").style.transform =
"rotate(0deg)";
} else {
helpMenu.parentElement.querySelector(".cats").style.transform =
"scaleY(0)";
helpMenu.parentElement.removeAttribute("style");
helpMenu.parentElement.querySelector(".caret").removeAttribute("style");
}
});
});
document.addEventListener("click", (e) => {
if (e.target.classList.contains("caret")) {
let helpMenu = e.target.parentElement.getElementsByTagName("span")[0];
let transformValue = window
.getComputedStyle(helpMenu.parentElement.querySelector(".cats"))
.getPropertyValue("transform");
if (transformValue !== "matrix(1, 0, 0, 1, 0, 0)") {
helpMenu.parentElement.style.backgroundColor = "rgba(15, 15, 15, 0.8)";
helpMenu.parentElement.querySelector(".cats").style.transform =
"scaleY(1)";
helpMenu.parentElement.querySelector(".caret").style.transform =
"rotate(0deg)";
} else {
helpMenu.parentElement.querySelector(".cats").style.transform =
"scaleY(0)";
helpMenu.parentElement.removeAttribute("style");
helpMenu.parentElement.querySelector(".caret").removeAttribute("style");
}
}
if (e.target.classList.contains("select")) {
let helpMenu = e.target.getElementsByTagName("span")[0];
let transformValue = window
.getComputedStyle(helpMenu.parentElement.querySelector(".cats"))
.getPropertyValue("transform");
if (transformValue !== "matrix(1, 0, 0, 1, 0, 0)") {
helpMenu.parentElement.style.backgroundColor = "rgba(15, 15, 15, 0.8)";
helpMenu.parentElement.querySelector(".cats").style.transform =
"scaleY(1)";
helpMenu.parentElement.querySelector(".caret").style.transform =
"rotate(0deg)";
} else {
helpMenu.parentElement.querySelector(".cats").style.transform =
"scaleY(0)";
helpMenu.parentElement.removeAttribute("style");
helpMenu.parentElement.querySelector(".caret").removeAttribute("style");
}
}
});
});