Files
web/scripts/js/theme.js
RD WebDesign 2c369c0cbd Fix theme selection
- Set "bs_theme" variable in Lua code for all Pi-hole themes, including
  both high contrast themes.

- Simplify theme.js code. Most of the code was removed and now we only
  set "lte-theme" localStorage key to "light", "dark" or "auto", based
  on the currently selected Pi-hole theme.
  Pi-hole themes don't use this value directly, but AdminLTE javascript
  code uses it to switch between light and dark modes).
  This is actually only useful for "auto" theme, since all other Pi-hole
  themes use a single mode (always light or dark, selected by the user),
  regardless of the preference set on the OS or browser.
  Even so, AdminLTE tries to read this value from localStorage on every
  page load. Without this value, AdminLTE would force a different mode,
  even when the current selected theme has its own mode.
  Storing the theme mode in "lte-theme" localStorage key ensures that
  AdminLTE will never change "data-bs-theme" attribute on the "<html>"
  tag and will always respect the user choice, but still keeps the
  ability to use the preferred light/dark mode for the "Auto" theme.

Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
2026-09-27 22:17:09 -03:00

12 lines
467 B
JavaScript

/* Pi-hole: A black hole for Internet advertisements
* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
* Network-wide ad blocking via your own hardware.
*
* This file is copyright under the latest version of the EUPL.
* Please see LICENSE file for your rights under this license. */
"use strict";
// Force AdminLTE to use light/dark theme based on the current selected Pi-hole theme
localStorage.setItem("lte-theme", document.documentElement.dataset.bsTheme);