-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
893aa34
commit cf40652
Showing
3 changed files
with
91 additions
and
129 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) ); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters