From 34cd9a5d1a48eab31d6f2451635edc892d3b3000 Mon Sep 17 00:00:00 2001 From: Andray Date: Fri, 12 Jul 2024 17:43:11 +0400 Subject: [PATCH] fix tabs --- javascript/toggle_dark_light.js | 52 ++++++++++++++++----------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/javascript/toggle_dark_light.js b/javascript/toggle_dark_light.js index bdd65bd..1cff3a1 100644 --- a/javascript/toggle_dark_light.js +++ b/javascript/toggle_dark_light.js @@ -1,36 +1,36 @@ onUiLoaded(() => { - function updateUrlParameter(key, value) { - var url = new URL(window.location.href); - url.searchParams.set(key, value); - history.replaceState(null, '', url.href); - } + function updateUrlParameter(key, value) { + var url = new URL(window.location.href); + url.searchParams.set(key, value); + history.replaceState(null, '', url.href); + } - function deleteUrlParameter(key) { - var url = new URL(window.location.href); - url.searchParams.delete(key); - history.replaceState(null, '', url.href); - } + function deleteUrlParameter(key) { + var url = new URL(window.location.href); + url.searchParams.delete(key); + history.replaceState(null, '', url.href); + } - function syncArgAndClass() { - if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { - if (!document.body.classList.contains('dark')) { - updateUrlParameter('__theme', 'light'); - } else { - deleteUrlParameter('__theme'); - } - } else { - if (document.body.classList.contains('dark')) { - updateUrlParameter('__theme', 'dark'); - } else { - deleteUrlParameter('__theme'); - } - } - } + function syncArgAndClass() { + if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { + if (!document.body.classList.contains('dark')) { + updateUrlParameter('__theme', 'light'); + } else { + deleteUrlParameter('__theme'); + } + } else { + if (document.body.classList.contains('dark')) { + updateUrlParameter('__theme', 'dark'); + } else { + deleteUrlParameter('__theme'); + } + } + } function toggleDarkMode() { document.body.classList.toggle('dark'); - syncArgAndClass(); + syncArgAndClass(); } const button = document.createElement('button');