ui stuff, proxy?, and whatever else
This commit is contained in:
33
loader.html
33
loader.html
@ -20,6 +20,31 @@
|
||||
<script src="/js/all.min.js" defer></script>
|
||||
<script defer>
|
||||
let gameData = {};
|
||||
function recordRecentlyPlayed(directory) {
|
||||
if (!directory) return;
|
||||
let recent = [];
|
||||
try {
|
||||
recent = JSON.parse(localStorage.getItem("selenite.recentlyPlayed") || "[]");
|
||||
} catch {
|
||||
recent = [];
|
||||
}
|
||||
recent = recent.filter((dir) => dir !== directory);
|
||||
recent.unshift(directory);
|
||||
if (recent.length > 20) recent.length = 20;
|
||||
localStorage.setItem("selenite.recentlyPlayed", JSON.stringify(recent));
|
||||
}
|
||||
function handlePanicKeydown(e) {
|
||||
let panic;
|
||||
try {
|
||||
panic = JSON.parse(localStorage.getItem("selenite.panic-mode") || "{}");
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
if (panic.key && panic.url && e.key.toLowerCase() === panic.key.toLowerCase()) {
|
||||
location.href = panic.url;
|
||||
}
|
||||
}
|
||||
document.addEventListener("keydown", handlePanicKeydown);
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const gameFrame = document.getElementById("gameFrame");
|
||||
const gameImage = document.getElementById("gameImage");
|
||||
@ -35,6 +60,7 @@
|
||||
gameFrame.src = `/resources/${prefix}/${gameData.path}/index.html`;
|
||||
gameImage.src = `/resources/${prefix}/${gameData.path}/${params.get("img")}`;
|
||||
gameName.innerText = decodeURIComponent(params.get("title"));
|
||||
recordRecentlyPlayed(gameData.path);
|
||||
} else if (localStorage.getItem("selenite.lastGame")) {
|
||||
const game = JSON.parse(decodeURIComponent(atob(localStorage.getItem("selenite.lastGame"))));
|
||||
gameData.type = game[3];
|
||||
@ -43,8 +69,15 @@
|
||||
gameFrame.src = `/resources/${prefix}/${gameData.path}/index.html`;
|
||||
gameImage.src = `/resources/${prefix}/${gameData.path}/${decodeURIComponent(game[1])}`;
|
||||
gameName.innerText = game[2];
|
||||
recordRecentlyPlayed(gameData.path);
|
||||
}
|
||||
|
||||
gameFrame.addEventListener("load", () => {
|
||||
try {
|
||||
gameFrame.contentWindow.document.addEventListener("keydown", handlePanicKeydown);
|
||||
} catch { }
|
||||
});
|
||||
|
||||
document.getElementById("fullscreen").addEventListener("click", () => gameFrame.requestFullscreen());
|
||||
document.getElementById("reload").addEventListener("click", () => { gameFrame.src = gameFrame.src; });
|
||||
document.getElementById("open").addEventListener("click", () => window.open(gameFrame.src));
|
||||
|
||||
Reference in New Issue
Block a user