Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
GithubMaster212 authored Nov 30, 2024
1 parent f2a9dc0 commit e68abd6
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,17 @@ <h1>Game Selection</h1>

<script>
async function loadGames() {
const gameContainer = document.getElementById('game-container');

try {
const response = await fetch('games/');
const files = await response.text();
const gameFiles = files.match(/href="([^"]+\.txt)"/g);

if (gameFiles) {
const gameContainer = document.getElementById('game-container');
for (const file of gameFiles) {
const gameName = file.match(/"([^"]+)"/)[1];
const gameData = await fetch(`games/${gameName}`).then(res => res.text());
const response = await fetch('https://api.github.com/repos/githubmaster212/game/contents/games');
const files = await response.json();

for (const file of files) {
if (file.name.endsWith('.txt')) {
const gameData = await fetch(file.download_url).then(res => res.text());
const [title, description, imageUrl] = gameData.split('\n');

const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
Expand All @@ -57,6 +56,7 @@ <h2>${title}</h2>
gameCard.addEventListener('click', () => {
window.open('https://example.com', '_blank');
});

gameContainer.appendChild(gameCard);
}
}
Expand All @@ -68,4 +68,4 @@ <h2>${title}</h2>
loadGames();
</script>
</body>
</html>
</html>

0 comments on commit e68abd6

Please sign in to comment.