From d2934ddf47716fe5511962df438b3b71429b9700 Mon Sep 17 00:00:00 2001 From: FrederikBaerentsen Date: Sun, 14 Apr 2024 15:57:33 +0200 Subject: [PATCH] Fixed button --- templates/frontpage.html | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/templates/frontpage.html b/templates/frontpage.html index d7e2330..e839453 100644 --- a/templates/frontpage.html +++ b/templates/frontpage.html @@ -353,7 +353,16 @@ document.addEventListener('DOMContentLoaded', function () { const toggleButton = document.getElementById('toggleButton'); let isHidden = true; // Initially, only show checked grid items + // Initialize visibility based on isHidden + updateVisibility(); + toggleButton.addEventListener('click', function() { + // Toggle visibility and update grid items + isHidden = !isHidden; + updateVisibility(); + }); + + function updateVisibility() { // Get all grid items const gridItems = document.querySelectorAll('.grid-item'); @@ -369,10 +378,7 @@ document.addEventListener('DOMContentLoaded', function () { item.style.display = 'none'; } }); - - // Invert the visibility state for the next click - isHidden = !isHidden; - }); + } });