From ec7319b5a8b6f70941d01ea01664047ca69b9d48 Mon Sep 17 00:00:00 2001
From: Mylloon <kennel.anri@tutanota.com>
Date: Wed, 27 Nov 2024 20:08:48 +0100
Subject: [PATCH] simplify

---
 static/js/cours.js | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

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();
     }
   });
 });