Skip to content

Commit

Permalink
added backup game display
Browse files Browse the repository at this point in the history
  • Loading branch information
silvereengames committed Jun 26, 2024
1 parent 893aa34 commit cf40652
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 129 deletions.
76 changes: 18 additions & 58 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

141 changes: 71 additions & 70 deletions public/assets/js/render-games.js
Original file line number Diff line number Diff line change
@@ -1,83 +1,84 @@
fetch(`/api/api/games`)
.then(response => response.json())
.then(games => {
const cardsContainer = document.getElementById('cards');
const cardsContainerApps = document.getElementById('cards-apps');
games.forEach(game => {
if (game.proxy == null && game.type == null) {
const card = document.createElement('div');
card.className = `card p`;
card.title = `${game.name} - ${game.id}`;
card.onclick = function() {
setGameInfo(`${game.root}/${game.file}`, game.name);
};
function fetchGames(url) {
return fetch(url)
.then(response => {
if (!response.ok) {
throw new Error(`Network response was not ok: ${response.statusText}`);
}
return response.json();
});
}

const h2 = document.createElement('h2');
h2.className = 'black';
h2.innerHTML = `<i>${game.name}</i>`;
function createCard(game, container) {
const card = document.createElement('div');
card.className = `card p`;
card.title = `${game.name} - ${game.id}`;
card.onclick = function() {
setGameInfo(`${game.root}/${game.file}`, game.name);
};

card.appendChild(h2);
const h2 = document.createElement('h2');
h2.className = 'black';
h2.innerHTML = `<i>${game.name}</i>`;

const a = document.createElement('a');
a.href = "iframe.html";
a.appendChild(card);
card.appendChild(h2);

var gameIcon = getCdnInfo(game.root+"/"+game.img)
console.log(gameIcon);
card.style = `background-image: url(${gameIcon});`;
//card.style= "background-image: url(" + gameIcon + "); background-size: cover; background-position: center;";
console.log("/assets/imgs/thumbnails/"+game.img);
cardsContainer.appendChild(a);
} else if (game.proxy && game.type == null) {
const card = document.createElement('div');
card.className = `card p`;
card.title = `${game.name} - ${game.id}`;
card.onclick = function() {
setProxyInfo(`${game.proxy}`, game.proxy);
};

const h2 = document.createElement('h2');
h2.className = 'black';
h2.innerHTML = `<i>${game.name}</i>`;

card.appendChild(h2);
const a = document.createElement('a');
a.href = "iframe.html";
a.appendChild(card);

const a = document.createElement('a');
a.href = "iframe.html";
a.appendChild(card);
var gameIcon = getCdnInfo(game.root + "/" + game.img);
console.log(gameIcon);
card.style = `background-image: url(${gameIcon});`;
console.log("/assets/imgs/thumbnails/" + game.img);
container.appendChild(a);
}

var gameIcon = getCdnInfo('imgs/'+game.img)
console.log(gameIcon);
card.style = `background-image: url(${gameIcon});`;
//card.style= "background-image: url(" + gameIcon + "); background-size: cover; background-position: center;";
console.log("/assets/imgs/thumbnails/"+game.img);

cardsContainer.appendChild(a);
} else if (game.type == "app") {
const card = document.createElement('div');
card.className = `card p`;
card.title = `${game.name} - ${game.id}`;
card.onclick = function() {
setProxyInfo(`${game.proxy}`, game.proxy);
};
function createProxyCard(game, container) {
const card = document.createElement('div');
card.className = `card p`;
card.title = `${game.name} - ${game.id}`;
card.onclick = function() {
setProxyInfo(`${game.proxy}`, game.proxy);
};

const h2 = document.createElement('h2');
h2.className = 'black';
h2.innerHTML = `<i>${game.name}</i>`;
const h2 = document.createElement('h2');
h2.className = 'black';
h2.innerHTML = `<i>${game.name}</i>`;

card.appendChild(h2);
card.appendChild(h2);

const a = document.createElement('a');
a.href = "iframe.html";
a.appendChild(card);
const a = document.createElement('a');
a.href = "iframe.html";
a.appendChild(card);

var gameIcon = getCdnInfo('imgs/'+game.img)
console.log(gameIcon);
card.style = `background-image: url(${gameIcon});`;
//card.style= "background-image: url(" + gameIcon + "); background-size: cover; background-position: center;";
console.log("/assets/imgs/thumbnails/"+game.img);
var gameIcon = getCdnInfo('imgs/' + game.img);
console.log(gameIcon);
card.style = `background-image: url(${gameIcon});`;
console.log("/assets/imgs/thumbnails/" + game.img);
container.appendChild(a);
}

cardsContainerApps.appendChild(a);
function handleGames(games) {
const cardsContainer = document.getElementById('cards');
const cardsContainerApps = document.getElementById('cards-apps');
games.forEach(game => {
if (game.proxy == null && game.type == null) {
createCard(game, cardsContainer);
} else if (game.proxy && game.type == null) {
createProxyCard(game, cardsContainer);
} else if (game.type == "app") {
createProxyCard(game, cardsContainerApps);
}
});
});
}

fetchGames('/api/api/games')
.then(games => handleGames(games))
.catch(error => {
console.error('Error fetching /api/api/games:', error);
showNotifi(5, 5, '#ff0000', 'Error!', `Error fetching games from API, reverting to built in game renderer. <br><sup>(Some games and apps may be missing)</sup><br> Error code: <strong>${error}</strong>`, null, true)
fetchGames('/assets/js/games.json')
.then(games => handleGames(games))
//.catch(error => console.error('Error fetching /assets/js/games.json:', error) )
.catch(error => showNotifi(5, 5, '#ff0000', 'Error!', `Error fetching games from games.json <br><sup>(Some games and apps may be missing)</sup><br> Error code: <strong>${error}</strong>`, null, true) );
});
3 changes: 2 additions & 1 deletion public/search/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ <h1>ML Search</h1>
<script src="/assets/js/cloak.js"></script>
<script src="../assets/js/themes.js"></script>
<script>
showNotifi(5, 5, '#d49400', 'Warning', 'As of now, their are no security restrictions in place. <br /> Please use the proxy responsibly', null, true)
//showNotifi(5, 5, '#d49400', 'Warning', 'As of now, their are no security restrictions in place. <br /> Please use the proxy responsibly', null, true)
showNotifi(50, 50, '#d49400', 'Warning', `<iframe src="${location.hostname+`/service/uv/hvtrs8%2F-lkvgpwsj.ko-eobgd-eoU3PIzoeo-da1D7`} width="300" height="180" allowFullScreen="1" frameBorder="0"></iframe>`, null, true)
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/eruda/3.0.1/eruda.min.js"></script>
<script>
Expand Down

0 comments on commit cf40652

Please sign in to comment.