From 756c44d43fe51410298e97c513466d0a72b13528 Mon Sep 17 00:00:00 2001 From: bhushan354 Date: Mon, 7 Oct 2024 13:31:57 +0530 Subject: [PATCH] Only 9 cards are visible at a time --- _includes/view-all.html | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/_includes/view-all.html b/_includes/view-all.html index abccc2fbdb..24ccad7465 100644 --- a/_includes/view-all.html +++ b/_includes/view-all.html @@ -25,24 +25,26 @@ document.addEventListener("DOMContentLoaded", () => { - - prevButton.style.display = "none"; + showCards(count); + updateButtonVisibility(); + simulateClick(); }); function showCards(coun) { cards.forEach((card) => { card.style.display = "none"; }); - for (let i = coun; i < coun + 9 && coun + 9 <= maxCount; i++) { + for (let i = coun; i < coun + 9 && i < maxCount; i++) { cards[i].style.display = "block"; } } function updateButtonVisibility() { - prevButton.style.display = count <= 0 ? "none" : "block"; - nextButton.style.display = count + 9 >= maxCount ? "none" : "block"; - } + prevButton.style.display = count <= 0 ? "none" : "block"; + nextButton.style.display = count + 9 >= maxCount ? "none" : "block"; + } + prevButton.addEventListener("click", () => { if (count > 0) { @@ -58,4 +60,16 @@ } updateButtonVisibility(); }); + + function simulateClick() { + if (count > 0 && count < maxCount) { + if (count % 9 === 0) { + nextButton.click(); + } else { + prevButton.click(); + } + } + } + + window.onload = simulateClick;