From: Pexle Chris Date: Sun, 27 Apr 2025 12:13:21 +0000 (+0300) Subject: AdminerDarkSwitcher: Handle first click X-Git-Tag: v5.3.0~4 X-Git-Url: https://git.joonet.de/?a=commitdiff_plain;h=cf52c4c0a8453f0e1999508b32006f6e49606beb;p=adminer.git AdminerDarkSwitcher: Handle first click Fixed an issue where the Dark Mode Switcher icon did not respond on the first click if the Dark Mode cookie had not been set yet. Now, clicking the icon correctly sets the cookie and immediately toggles Dark Mode. --- diff --git a/plugins/dark-switcher.php b/plugins/dark-switcher.php index df3ef2ac..10ea97f5 100644 --- a/plugins/dark-switcher.php +++ b/plugins/dark-switcher.php @@ -28,6 +28,8 @@ const saved = document.cookie.match(/adminer_dark=(\d)/); if (saved) { adminerDark = +saved[1]; adminerDarkSet(); +} else { + adminerDark = +matchMedia('(prefers-color-scheme: dark)').matches; } ☀" - . Adminer\script("if (adminerDark != null) adminerDarkSet(); qsl('big').onclick = adminerDarkSwitch;") . "\n" + . Adminer\script("adminerDarkSet(); qsl('big').onclick = adminerDarkSwitch;") . "\n" ; }