Skip to content

Commit c129ecf

Browse files
authored
Update embed.js
1 parent 26c236b commit c129ecf

File tree

1 file changed

+44
-30
lines changed

1 file changed

+44
-30
lines changed

embed.js

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -375,39 +375,53 @@
375375
target.innerHTML = "<p class='text-center font-medium'>Loading games...</p>";
376376
showSection('gameContainer');
377377

378-
try {
379-
const response = await fetch(`${api}/fullg.json`);
380-
const games = await response.json();
381-
382-
// If the games don't have an apiUrl property, add a dummy one or just skip it
383-
allGames = games.map(game => ({
384-
...game,
385-
apiUrl: 'https://bread-org.github.io/s16' // or empty string if you want
386-
}));
387-
388-
filterGames();
389-
390-
const searchBar = document.getElementById('searchBar');
391-
searchBar.placeholder = `Search between ${allGames.length} games...`;
392-
393-
const params = new URLSearchParams(window.location.search);
394-
const gameId = params.get('id');
395-
if (gameId) {
396-
const gameToOpen = allGames.find(game => game.alt === gameId);
397-
if (gameToOpen) {
398-
opengame(gameToOpen.apiUrl, gameToOpen.alt, gameToOpen.title);
399-
} else {
400-
showMessage('Game not found.');
378+
try {
379+
380+
const [response1, response2] = await Promise.all([
381+
fetch(`${api}/g.json`),
382+
fetch(`${api2}/g.json`)
383+
]);
384+
385+
386+
const [games1, games2] = await Promise.all([
387+
response1.json(),
388+
response2.json()
389+
]);
390+
391+
392+
allGames = [
393+
...games1.map(game => ({ ...game, apiUrl: api })),
394+
...games2.map(game => ({ ...game, apiUrl: api2 }))
395+
];
396+
filterGames();
397+
398+
399+
400+
401+
402+
const searchBar = document.getElementById('searchBar');
403+
searchBar.placeholder = `Search between ${allGames.length} games...`;
404+
405+
406+
const params = new URLSearchParams(window.location.search);
407+
const gameId = params.get('id');
408+
if (gameId) {
409+
const gameToOpen = allGames.find(game => game.alt === gameId);
410+
if (gameToOpen) {
411+
opengame(gameToOpen.apiUrl, gameToOpen.alt, gameToOpen.title);
412+
} else {
413+
showMessage('Game not found.');
414+
}
401415
}
402-
}
403416

404-
lucide.createIcons();
405417

406-
} catch (err) {
407-
target.innerHTML = "<p class='text-red-500 text-center font-medium'>Error loading games. Please try again later.</p>";
408-
console.error("Error loading games:", err);
409-
showMessage('Error loading games. Please try again later.');
410-
}
418+
lucide.createIcons();
419+
420+
} catch (err) {
421+
target.innerHTML = "<p class='text-red-500 text-center font-medium'>Error loading games. Please try again later.</p>";
422+
console.error("Error loading games:", err);
423+
showMessage('Error loading games. Please try again later.');
424+
}
411425

412426

413427
window.opengame = (apiUrl, alt, title) => {

0 commit comments

Comments
 (0)