Skip to content

Commit

Permalink
fix cats
Browse files Browse the repository at this point in the history
  • Loading branch information
ronan-s1 committed Feb 7, 2024
1 parent 2df1480 commit e0d0f1d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
23 changes: 21 additions & 2 deletions assets/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,39 @@ document.addEventListener("DOMContentLoaded", function () {
cursorElement.style.cursor = newCursor;
currentIndex = (currentIndex + 1) % foodEmojis.length;
}
cursorElement.addEventListener("click", changeCursor);


const catGif = document.getElementById("catGif");
let gifIndex = 0;
let gifs = [];

cursorElement.addEventListener("click", changeCursor);
container = document.getElementById("foodList");
fetch("assets/img/cats/")
.then(response => response.text())
.then(text => {
// Parse the HTML response to extract the GIF file names
const parser = new DOMParser();
const htmlDocument = parser.parseFromString(text, "text/html");
const links = Array.from(htmlDocument.querySelectorAll("a"));

gifs = links
.map(link => link.href)
.filter(href => href.endsWith(".gif"));

console.log(gifs)
console.log(gifs[gifIndex])
catGif.src = gifs[gifIndex];
})
.catch(error => console.error("Error fetching data:", error));


catGif.addEventListener("click", function() {
gifIndex = (gifIndex + 1) % gifs.length;
catGif.src = gifs[gifIndex];
});



// Fetch data from the JSON file
fetch("assets/data/data.json")
.then(response => response.json())
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h1>OFFICIAL DUBLIN FOOD HITLIST !!!</h1>
</div>

<div class="site-description container">
<img src="assets/img/cat_1.gif" alt="cat" id="catGif" class="mb-3 cat">
<img src="" alt="cat" id="catGif" class="mb-3 cat">
<p>A curated list of Dublin restaurants, rated 1-10, factoring in taste, location, atmosphere, price, and more 🤯</p>
</div>

Expand Down

0 comments on commit e0d0f1d

Please sign in to comment.