updated config and bug fixes
This commit is contained in:
@@ -4,7 +4,7 @@ Vars
|
||||
const deg = a => Math.PI / 180 * a;
|
||||
const rand = (v1, v2) => Math.floor(v1 + Math.random() * (v2 - v1));
|
||||
const opt = {
|
||||
particles: window.width / 500 ? 1000 : 500,
|
||||
particles: window.width / 500 ? 250 : 125,
|
||||
noiseScale: 0.005,
|
||||
angle: Math.PI / 180 * -90,
|
||||
h1: rand(0, 360),
|
||||
|
||||
+130
-24
@@ -2,17 +2,32 @@ let currentMenu = $(".homepage");
|
||||
|
||||
$(".column button .card").on("click", function () {
|
||||
let nextMenu = this.getAttribute("data");
|
||||
if (nextMenu == "homepage") {
|
||||
$(".side-buttons").fadeOut(300);
|
||||
|
||||
if (nextMenu === "proxy") {
|
||||
if (!config["proxy"]) {
|
||||
$("#disabled").showModal();
|
||||
return;
|
||||
}
|
||||
$("#everything-else").fadeOut(300, () => {
|
||||
$("#page-loader").fadeIn(200);
|
||||
$("#page-loader").attr("src", "/proxy");
|
||||
});
|
||||
currentMenu = $("#page-loader");
|
||||
return;
|
||||
}
|
||||
|
||||
currentMenu.fadeOut(300, () => {
|
||||
$("." + nextMenu).fadeIn(200);
|
||||
});
|
||||
currentMenu = $(nextMenu);
|
||||
currentMenu = $("." + nextMenu);
|
||||
});
|
||||
|
||||
if (currentMenu != $(".homepage")) {
|
||||
$(".side-buttons").fadeIn(200);
|
||||
$("logo img").on("click", returnHome);
|
||||
$("#gameButton").on("click", returnHome);
|
||||
|
||||
$("dialog").on("click", function (e) {
|
||||
if (!e.originalEvent.target.closest("div")) {
|
||||
e.originalEvent.target.close();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -123,21 +138,11 @@ function jaroWinklerSimilarity(s1, s2) {
|
||||
return jaro_dist.toFixed(6);
|
||||
}
|
||||
|
||||
|
||||
function searchGamesList() {
|
||||
const input = $("#search");
|
||||
const filter = input.val().toLowerCase();
|
||||
const elems = Array.from(document.querySelectorAll("#gamesList li"));
|
||||
|
||||
for (i = 0; i < elems.length; i++) {
|
||||
if (jaroWinklerSimilarity(filter, elems[i].innerHTML.toLowerCase().slice(0, filter.length - 1)) >= 0.9 && elems[i].innerHTML.length > 3 || elems[i].innerHTML.toLowerCase().indexOf(filter) > -1) {
|
||||
elems[i].style.display = "";
|
||||
} else {
|
||||
elems[i].style.display = "none";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the list of games based on the current search filter and sort type.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
function updateList() {
|
||||
const filter = $("#search").val().toLowerCase();
|
||||
const elems = Array.from(document.querySelectorAll("#gamesList li"));
|
||||
@@ -154,7 +159,20 @@ function updateList() {
|
||||
|
||||
// then filter items with the search input
|
||||
elems.forEach(function (item) {
|
||||
if (jaroWinklerSimilarity(filter, item.innerHTML.toLowerCase().slice(0, filter.length - 1)) >= 0.9 && item.innerHTML.length > 3 || item.innerHTML.toLowerCase().indexOf(filter) > -1) {
|
||||
let similarity = jaroWinklerSimilarity(filter, item.innerHTML.toLowerCase().slice(0, filter.length - 1));
|
||||
if (item.getAttribute("aliases")) {
|
||||
for (alias in item.getAttribute("aliases").split(',')) {
|
||||
if (alias.length > 1) {
|
||||
console.log("alias");
|
||||
console.log(alias);
|
||||
console.log(typeof alias);
|
||||
console.log(alias.length);
|
||||
similarity += jaroWinklerSimilarity(filter, alias.toLowerCase().slice(0, filter.length - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (similarity >= 0.7 && item.innerHTML.length > 2 || item.innerHTML.toLowerCase().indexOf(filter) > -1) {
|
||||
item.style.display = "";
|
||||
} else {
|
||||
item.style.display = "none";
|
||||
@@ -163,11 +181,21 @@ function updateList() {
|
||||
|
||||
// now sort by jaro winkler distance
|
||||
elems.sort(function (a, b) {
|
||||
const distanceA = jaroWinklerSimilarity(filter, a.textContent.toLowerCase());
|
||||
const distanceB = jaroWinklerSimilarity(filter, b.textContent.toLowerCase());
|
||||
let distanceA = jaroWinklerSimilarity(filter, a.textContent.toLowerCase());
|
||||
if (a.getAttribute("aliases")) {
|
||||
for (alias in a.getAttribute("aliases").split(',')) {
|
||||
distanceA += jaroWinklerSimilarity(filter, alias.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
let distanceB = jaroWinklerSimilarity(filter, b.textContent.toLowerCase());
|
||||
if (b.getAttribute("aliases")) {
|
||||
for (alias in b.getAttribute("aliases").split(',')) {
|
||||
distanceB += jaroWinklerSimilarity(filter, alias.toLowerCase());
|
||||
}
|
||||
}
|
||||
return distanceA - distanceB;
|
||||
})
|
||||
});
|
||||
|
||||
// then fill it with the sorted and filtered list
|
||||
for (const item of elems) {
|
||||
@@ -177,6 +205,11 @@ function updateList() {
|
||||
$("#search").on("input", updateList);
|
||||
$("#sort").on("change", updateList);
|
||||
|
||||
/**
|
||||
* Generates a clone of the current window in an about:blank.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
function makeclone() {
|
||||
if ((window.top.location.href != "about:blank")) {
|
||||
var url = window.location.href;
|
||||
@@ -199,3 +232,76 @@ function makeclone() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dragElement(document.getElementById("gameButton"));
|
||||
dragElement(document.getElementById("refresh"));
|
||||
|
||||
/**
|
||||
* Adds drag functionality to an HTML element.
|
||||
*
|
||||
* @param {HTMLElement} elmnt - The element to be dragged.
|
||||
* @return {void}
|
||||
*/
|
||||
function dragElement(elmnt) {
|
||||
var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
|
||||
if (document.getElementById(elmnt.id)) {
|
||||
document.getElementById(elmnt.id).onmousedown = dragMouseDown;
|
||||
} else {
|
||||
elmnt.onmousedown = dragMouseDown;
|
||||
}
|
||||
|
||||
function dragMouseDown(e) {
|
||||
e = e || window.event;
|
||||
e.preventDefault();
|
||||
pos3 = e.clientX;
|
||||
pos4 = e.clientY;
|
||||
document.onmouseup = closeDragElement;
|
||||
document.onmousemove = elementDrag;
|
||||
}
|
||||
|
||||
function elementDrag(e) {
|
||||
e = e || window.event;
|
||||
e.preventDefault();
|
||||
|
||||
pos1 = pos3 - e.clientX;
|
||||
pos2 = pos4 - e.clientY;
|
||||
pos3 = e.clientX;
|
||||
pos4 = e.clientY;
|
||||
window.click = 1;
|
||||
elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
|
||||
|
||||
}
|
||||
|
||||
function closeDragElement() {
|
||||
|
||||
document.onmouseup = null;
|
||||
document.onmousemove = null;
|
||||
|
||||
if (window.click == 1) {
|
||||
window.hold = true;
|
||||
window.click = 0;
|
||||
}
|
||||
setTimeout(function () { window.hold = false; }, 100);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user to the home page.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
function returnHome() {
|
||||
currentMenu.fadeOut(300, () => {
|
||||
$("#everything-else").fadeIn(200);
|
||||
});
|
||||
currentMenu = $(".homepage");
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the current page by reloading it.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
function refreshPage() {
|
||||
location.reload();
|
||||
}
|
||||
+18
-3
@@ -1,3 +1,7 @@
|
||||
let config;
|
||||
let games;
|
||||
let themes;
|
||||
|
||||
function changeLoadingTip() {
|
||||
const tips = ["Press CTRL+C to cloak your current tab", "Press CTRL+M to mask your current tab", "Press CTRL+B to go back to the home page", "Join our discord server!", "Make sure to enable popups for automatic cloak", "Why are you here?"]
|
||||
const element = document.getElementsByClassName("loading-tip")[0];
|
||||
@@ -12,13 +16,16 @@ let changeTip = setInterval(() => {
|
||||
changeLoadingTip();
|
||||
}, 3000);
|
||||
|
||||
fetch("./game-info.jsonc").then((e) => e.text()).then((jsonc) => {
|
||||
fetch("./config.jsonc").then((e) => e.text()).then((jsonc) => {
|
||||
// removing all the comments from the jsonc file
|
||||
let json = JSON.parse(jsonc.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m, g) => g ? "" : m));
|
||||
games = json["games"];
|
||||
themes = json["themes"];
|
||||
config = json["config"];
|
||||
|
||||
let gamesList = $("#gamesList");
|
||||
for (game in json) {
|
||||
gamesList.append(`<li url="games/${json[game]}">${game}</li>`);
|
||||
for (game in games) {
|
||||
gamesList.append(`<li url="games/${json[game["path"]]}" ${game["aliases"] ? "aliases=\"" + game["aliases"].join(',') + "\"" : ''}>${game}</li>`);
|
||||
}
|
||||
|
||||
$("#gamesList li").on("click", function() {
|
||||
@@ -50,6 +57,14 @@ $(window).on("load", () => {
|
||||
});
|
||||
});
|
||||
|
||||
jQuery.fn.extend({showModal: function() {
|
||||
return this.each(function() {
|
||||
if(this.tagName=== "DIALOG"){
|
||||
this.showModal();
|
||||
}
|
||||
});
|
||||
}});
|
||||
|
||||
(function () {
|
||||
let previousTime = Date.now();
|
||||
let frames = 0;
|
||||
|
||||
Reference in New Issue
Block a user