Skip to content

Commit

Permalink
fixes: games number index..js
Browse files Browse the repository at this point in the history
  • Loading branch information
anisharma07 committed Jun 13, 2024
1 parent 5fb3c45 commit 05a86c9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const generateLiTags = (gamesData, searchText = "") => {
const liTags = [];
searchText = searchText.trim().toLowerCase(); // Trim whitespace and convert to lowercase

for (let tagNumber = 1; tagNumber <= 418; tagNumber++) {
for (let tagNumber = 1; tagNumber <= 417; tagNumber++) {
const gameData = gamesData[tagNumber.toString()];

if (gameData) {
Expand All @@ -22,7 +22,9 @@ const generateLiTags = (gamesData, searchText = "") => {
</figure>
<div class="title-container">
<a href="https://github.com/kunjgit/GameZone/tree/main/Games/${gameUrl}" target="_blank" aria-label="${gameTitle}">${tagNumber}. ${gameTitle} 🔗</a>
<button class="like-button ${liked ? 'liked' : ''}" onclick="like(this, ${tagNumber})">♡</button>
<button class="like-button ${
liked ? "liked" : ""
}" onclick="like(this, ${tagNumber})">♡</button>
</div>
</a>
</li>
Expand Down Expand Up @@ -163,9 +165,8 @@ document.addEventListener("DOMContentLoaded", () => {
function like(button, tagNumber, gameData) {
button.classList.toggle("liked");
const isLiked = button.classList.contains("liked");

// Store both liked state and game data in localStorage
localStorage.setItem(`liked-${tagNumber}`, isLiked);
localStorage.setItem(`game-${tagNumber}`, JSON.stringify(gameData));
}

0 comments on commit 05a86c9

Please sign in to comment.