From 35b9a7e79bcc3658b59c7bf2fdc395b418cf617c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Sun, 4 Feb 2024 21:55:08 +0000 Subject: [PATCH] [pre-commit.ci lite] apply automatic fixes --- src/main/resources/static/theme-toggle.js | 54 +++++++++++------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/main/resources/static/theme-toggle.js b/src/main/resources/static/theme-toggle.js index e2d58a163..ef196354f 100644 --- a/src/main/resources/static/theme-toggle.js +++ b/src/main/resources/static/theme-toggle.js @@ -1,34 +1,34 @@ (function () { - const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)') - let initialTheme - if (localStorage.getItem('darkmode-pref-set') === 'true') { - initialTheme = localStorage.getItem('darkMode') === 'true' - } else { - initialTheme = darkModeMediaQuery.matches - } + const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)') + let initialTheme + if (localStorage.getItem('darkmode-pref-set') === 'true') { + initialTheme = localStorage.getItem('darkMode') === 'true' + } else { + initialTheme = darkModeMediaQuery.matches + } - function updateToggle (darkMode) { - document.querySelector(".theme-toggle input[type=radio][value='dark']").checked = darkMode - document.querySelector(".theme-toggle input[type=radio][value='light']").checked = !darkMode + function updateToggle (darkMode) { + document.querySelector(".theme-toggle input[type=radio][value='dark']").checked = darkMode + document.querySelector(".theme-toggle input[type=radio][value='light']").checked = !darkMode - document.body.classList.toggle('dark-mode', darkMode) - localStorage.setItem('darkMode', darkMode) - localStorage.setItem('darkmode-pref-set', 'true') - } + document.body.classList.toggle('dark-mode', darkMode) + localStorage.setItem('darkMode', darkMode) + localStorage.setItem('darkmode-pref-set', 'true') + } - darkModeMediaQuery.addEventListener('change', (e) => { - const darkModeOn = e.matches - updateToggle(darkModeOn) - }) - - window.addEventListener('load', function () { - const radios = document.querySelectorAll('.theme-toggle input[type=radio]') - radios.forEach((radio) => { - radio.addEventListener('change', function (e) { - updateToggle(e.target.value === 'dark') - }) - }) + darkModeMediaQuery.addEventListener('change', (e) => { + const darkModeOn = e.matches + updateToggle(darkModeOn) + }) - updateToggle(initialTheme) + window.addEventListener('load', function () { + const radios = document.querySelectorAll('.theme-toggle input[type=radio]') + radios.forEach((radio) => { + radio.addEventListener('change', function (e) { + updateToggle(e.target.value === 'dark') + }) }) + + updateToggle(initialTheme) + }) })()