updated config and bug fixes
This commit is contained in:
+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();
|
||||
}
|
||||
Reference in New Issue
Block a user