Skip to content

Commit

Permalink
attempt academicpages#7 to fix carousel buttons, checking if script l…
Browse files Browse the repository at this point in the history
…oaded at all, even outside DOM
  • Loading branch information
Konstantinos Ioannidis authored and Konstantinos Ioannidis committed Jan 23, 2025
1 parent 5f79254 commit 415651c
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions _personal/gaming.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,40 +182,40 @@ permalink: /personal/gaming
}

// Initialize carousels
document.addEventListener("DOMContentLoaded", () => {
console.log("DOM fully loaded and parsed.");

document.querySelectorAll(".carousel-container").forEach((carousel) => {
const carouselId = carousel.id;

// Set the initial slide index
carousel.setAttribute("data-slide-index", 0);
showSlide(carouselId, 0);

// Attach event listeners to navigation buttons
const prevButton = carousel.querySelector(".prev");
const nextButton = carousel.querySelector(".next");

if (prevButton) {
prevButton.addEventListener("click", () => {
console.log(`Prev button clicked for ${carouselId}`);
moveSlide(carouselId, -1);
});
} else {
console.warn(`Prev button not found for carousel: ${carouselId}`);
}

if (nextButton) {
nextButton.addEventListener("click", () => {
console.log(`Next button clicked for ${carouselId}`);
moveSlide(carouselId, 1);
});
} else {
console.warn(`Next button not found for carousel: ${carouselId}`);
}
});
console.log("Script loaded."); // Debugging log to ensure the script is loaded

document.querySelectorAll(".carousel-container").forEach((carousel) => {
const carouselId = carousel.id;
console.log(`Found carousel: ${carouselId}`); // Debugging log to check carousel IDs

carousel.setAttribute("data-slide-index", 0);
showSlide(carouselId, 0);

const prevButton = carousel.querySelector(".prev");
const nextButton = carousel.querySelector(".next");

if (prevButton) {
console.log(`Prev button found for ${carouselId}`); // Debugging log to confirm prev button
prevButton.addEventListener("click", () => {
console.log(`Prev button clicked for ${carouselId}`); // Debugging log when prev button is clicked
moveSlide(carouselId, -1);
});
} else {
console.warn(`Prev button not found for carousel: ${carouselId}`); // Warning if prev button is missing
}

if (nextButton) {
console.log(`Next button found for ${carouselId}`); // Debugging log to confirm next button
nextButton.addEventListener("click", () => {
console.log(`Next button clicked for ${carouselId}`); // Debugging log when next button is clicked
moveSlide(carouselId, 1);
});
} else {
console.warn(`Next button not found for carousel: ${carouselId}`); // Warning if next button is missing
}
});


</script>


Expand Down

0 comments on commit 415651c

Please sign in to comment.