mirror of
https://gitlab.com/skysthelimit.dev/selenite.git
synced 2025-06-17 11:02:08 -05:00
Upload files to "v4/assets"
This commit is contained in:
parent
5fc86f35cc
commit
ff68cec8ac
102
v4/assets/game.html
Normal file
102
v4/assets/game.html
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<link rel="stylesheet" href="../css/index.css" />
|
||||||
|
<link rel="shortcut icon" href="../images/logo.png" type="image/png" />
|
||||||
|
<title>Loading... | 3kh0</title>
|
||||||
|
<style>
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
margin: 0px;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
text-align: center;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
iframe {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner {
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.playgame {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
width: 500px;
|
||||||
|
height: 500px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loader {
|
||||||
|
margin: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loader.center {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.overlay {
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
z-index: 99999999999;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
background: var(--background);
|
||||||
|
}
|
||||||
|
|
||||||
|
.game_img {
|
||||||
|
border-radius: 10%;
|
||||||
|
width: 200px;
|
||||||
|
height: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner {
|
||||||
|
height: 150px;
|
||||||
|
width: 150px;
|
||||||
|
margin: 50px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body theme="default">
|
||||||
|
<center class="playgame">
|
||||||
|
<div class="loader">
|
||||||
|
<span class="spinner">
|
||||||
|
<svg viewBox="22 22 44 44">
|
||||||
|
<circle
|
||||||
|
class="spinnerSvg"
|
||||||
|
cx="44"
|
||||||
|
cy="44"
|
||||||
|
r="20.2"
|
||||||
|
fill="none"
|
||||||
|
stroke-width="3.6"
|
||||||
|
></circle>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<h1 id="game">Loading...</h1>
|
||||||
|
<button class="play hidden" id="startgame" data-aos="fade-up">
|
||||||
|
Lets go!
|
||||||
|
</button>
|
||||||
|
</center>
|
||||||
|
|
||||||
|
<script src="./game.js"> </script>
|
||||||
|
</body>
|
||||||
|
</html>
|
91
v4/assets/game.js
Normal file
91
v4/assets/game.js
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
(function () {
|
||||||
|
const { search, pathname } = window.location;
|
||||||
|
const urlParams = new URLSearchParams(search);
|
||||||
|
const gameSubpath = urlParams.get("game");
|
||||||
|
const origin = localStorage.getItem("instance");
|
||||||
|
const cdn = localStorage.getItem("cdn");
|
||||||
|
const instance = origin.replace(location.origin, "");
|
||||||
|
|
||||||
|
if (!origin || !cdn) {
|
||||||
|
window.location.href = `../?onload=window.location.href='${pathname}${search}'`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gameSubpath && origin) {
|
||||||
|
fetch("./json/games.json")
|
||||||
|
.then((res) => res.json())
|
||||||
|
.then((games) => {
|
||||||
|
const game = games.find((g) => g.root === gameSubpath);
|
||||||
|
if (game) {
|
||||||
|
const { name, root, img, file } = game;
|
||||||
|
document.title = `Play ${name} | 3kh0`;
|
||||||
|
window.history.pushState({}, "", `${origin}games/${gameSubpath}`);
|
||||||
|
document.querySelector("#game").textContent = name;
|
||||||
|
document.querySelector(".loader").innerHTML = `<img src="${cdn}${root}/${img}" class="game_img" loading="lazy" onerror="this.src='/assets/globe.svg'"/>`;
|
||||||
|
document.querySelector("#startgame").classList.remove("hidden");
|
||||||
|
|
||||||
|
const startGameHandler = (e) => {
|
||||||
|
document.body.innerHTML = `
|
||||||
|
<iframe frameborder="0" src="${cdn}${root}/${file}" onerror="document.write('Could not load game');console.error('The game encountered an error.');" onload="document.querySelector('.overlay').remove();"></iframe>
|
||||||
|
<div class="overlay">
|
||||||
|
<div class="loader center">
|
||||||
|
<span class="spinner">
|
||||||
|
<svg viewBox="22 22 44 44">
|
||||||
|
<circle class="spinnerSvg" cx="44" cy="44" r="20.2" fill="none" stroke-width="3.6"></circle>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
};
|
||||||
|
|
||||||
|
document.querySelector("#startgame").addEventListener("click", startGameHandler);
|
||||||
|
} else {
|
||||||
|
console.error(`The game "${gameSubpath}" was not found.`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
console.error(e);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.error("Could not load game");
|
||||||
|
if (!origin) {
|
||||||
|
console.error("The origin of the instance could not be found");
|
||||||
|
}
|
||||||
|
if (!gameSubpath) {
|
||||||
|
console.error("The game was not provided");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.top === window.self) {
|
||||||
|
window.location.href = document.referrer || "../";
|
||||||
|
}
|
||||||
|
|
||||||
|
function getColorValues(hexcolor) {
|
||||||
|
const r = parseInt(hexcolor.substr(1, 2), 16);
|
||||||
|
const g = parseInt(hexcolor.substr(3, 2), 16);
|
||||||
|
const b = parseInt(hexcolor.substr(5, 2), 16);
|
||||||
|
const yiq = (r * 299 + g * 587 + b * 114) / 1000;
|
||||||
|
return {
|
||||||
|
contrast: yiq >= 128 ? "#1c1c1c" : "white",
|
||||||
|
text: yiq >= 128 ? "white" : "black"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const theme = localStorage.getItem("theme");
|
||||||
|
|
||||||
|
if (!theme) {
|
||||||
|
document.body.setAttribute("theme", "default");
|
||||||
|
} else if (theme !== "custom") {
|
||||||
|
document.body.setAttribute("theme", theme);
|
||||||
|
} else if (theme === "custom") {
|
||||||
|
const customTheme = localStorage.getItem("theme_color");
|
||||||
|
document.body.setAttribute("theme", "custom");
|
||||||
|
const { contrast, text } = getColorValues(customTheme);
|
||||||
|
document.body.style = `--theme: ${customTheme}; --background: ${contrast}; --text: ${text}; --text-secondary: ${text};`;
|
||||||
|
|
||||||
|
if (location.pathname.includes("/settings")) {
|
||||||
|
document.querySelector("#theme_color").value = customTheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
1
v4/assets/globe.svg
Normal file
1
v4/assets/globe.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path fill="var(--background)" d="M12 2c5.52 0 10 4.48 10 10s-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2zM4 12h4.4c3.407.022 4.922 1.73 4.543 5.127H9.488v2.47a8.004 8.004 0 0010.498-8.083C19.327 12.504 18.332 13 17 13c-2.137 0-3.206-.916-3.206-2.75h-3.748c-.274-2.728.683-4.092 2.87-4.092 0-.975.327-1.597.811-1.97A8.004 8.004 0 004 12z"/></svg>
|
After Width: | Height: | Size: 404 B |
Loading…
x
Reference in New Issue
Block a user