From 2c39dffbeb74468bb4c352c469aa17d009f2df01 Mon Sep 17 00:00:00 2001 From: monerooo <102408599+monerooo@users.noreply.github.com> Date: Sat, 2 Apr 2022 11:27:36 +0200 Subject: [PATCH] clean up --- _includes/header-custom.html | 1 - js/main.js | 22 +++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/_includes/header-custom.html b/_includes/header-custom.html index 47c3f56..4a91700 100644 --- a/_includes/header-custom.html +++ b/_includes/header-custom.html @@ -14,5 +14,4 @@ Weekly Periodical - diff --git a/js/main.js b/js/main.js index eb7d802..f2be28d 100644 --- a/js/main.js +++ b/js/main.js @@ -8,21 +8,21 @@ const toggleSwitch = document.querySelector('.switch input[type="checkbox"]'); const currentTheme = localStorage.getItem('theme'); if (currentTheme) { - document.documentElement.setAttribute('data-theme', currentTheme); - - if (currentTheme === 'dark') { - toggleSwitch.checked = true; - } + document.documentElement.setAttribute('data-theme', currentTheme); + + if (currentTheme === 'dark') { + toggleSwitch.checked = true; + } } function switchTheme(e) { - if (e.target.checked) { - document.documentElement.setAttribute('data-theme', 'dark'); - localStorage.setItem('theme', 'dark'); - } else { + if (e.target.checked) { + document.documentElement.setAttribute('data-theme', 'dark'); + localStorage.setItem('theme', 'dark'); + } else { document.documentElement.setAttribute('data-theme', 'light'); - localStorage.setItem('theme', 'light'); - } + localStorage.setItem('theme', 'light'); + } } toggleSwitch.addEventListener('change', switchTheme, false);