From 8541d54364282d3973facd8e956a8e94bc6aa21f Mon Sep 17 00:00:00 2001 From: wozniakpawel Date: Tue, 9 Apr 2024 23:21:12 +0700 Subject: [PATCH] remove duplicate switchTheme function declaration --- src/js/script.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/js/script.js b/src/js/script.js index 0e9191f..55d4de7 100644 --- a/src/js/script.js +++ b/src/js/script.js @@ -23,14 +23,6 @@ const toggleSwitch = document.querySelector( '.theme-switch input[type="checkbox"]' ); -function switchTheme(e) { - if (e.target.checked) { - document.documentElement.setAttribute("data-theme", "dark"); - } else { - document.documentElement.setAttribute("data-theme", "light"); - } -} - toggleSwitch.addEventListener("change", switchTheme, false); // Store color theme for future visits @@ -38,10 +30,10 @@ toggleSwitch.addEventListener("change", switchTheme, false); function switchTheme(e) { if (e.target.checked) { document.documentElement.setAttribute("data-theme", "dark"); - localStorage.setItem("theme", "dark"); //add this + localStorage.setItem("theme", "dark"); } else { document.documentElement.setAttribute("data-theme", "light"); - localStorage.setItem("theme", "light"); //add this + localStorage.setItem("theme", "light"); } }