diff --git a/static/js/cours.js b/static/js/cours.js index da7cec2..76418e2 100644 --- a/static/js/cours.js +++ b/static/js/cours.js @@ -113,11 +113,11 @@ window.addEventListener("load", () => { uncollapse(last_openeded); } // Responsive menu + let menuOpen = false; const button = document.getElementsByTagName("button")[0]; const content = document.getElementsByTagName("main")[0]; - let menuOpen = false; const initialButtonTextContent = button.textContent; - button.addEventListener("click", () => { + const resetPage = () => { menuOpen = !menuOpen; if (menuOpen) { fileTreeElement.style.display = "block"; @@ -128,13 +128,12 @@ window.addEventListener("load", () => { content.style.display = ""; button.textContent = initialButtonTextContent; } - }); + }; + + button.addEventListener("click", resetPage); window.addEventListener("resize", () => { if (menuOpen && window.innerWidth > 640) { - menuOpen = !menuOpen; - fileTreeElement.style.display = ""; - content.style.display = ""; - button.textContent = initialButtonTextContent; + resetPage(); } }); });