Suppress white 'flashing' on page reloading in dark mode.

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2020-05-02 12:28:41 +02:00
parent b5e64653db
commit eefbef678c
2 changed files with 20 additions and 7 deletions

View File

@@ -175,6 +175,11 @@
* Please see LICENSE file for your rights under this license. -->
<html lang="en">
<head>
<?php if ($darkmode) { ?>
<style>
html { background-color: black; }
</style>
<?php } ?>
<meta charset="utf-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'self' https://api.github.com; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'">
<title>Pi-hole<?php if (gethostname()) {echo " - ", gethostname();} ?></title>

View File

@@ -8,9 +8,16 @@
// Array of available themes and their description
$available_themes = [];
$available_themes["default-light"] = ["Pi-hole default theme (light, default)", "default-light", "minimal", "blue"];
$available_themes["default-dark"] = ["Pi-hole midnight theme (dark)", "default-dark", "polaris", "polaris"];
$available_themes["default-dark2"] = ["Pi-hole afternoon theme (dark)", "default-dark", "futurico", "futurico"];
/* Array key = name used internally, not shown to the user
* Array[0] = Description
* Array[1] = Is this a dark mode theme? (Sets background to black during page reloading to avoid white "flashing")
* Array[2] = Style sheet name
* Array[3] = Radio/checkbox theme name
* Array[4] = Radio/checkbox theme variant
*/
$available_themes["default-light"] = ["Pi-hole default theme (light, default)", false, "default-light", "minimal", "blue"];
$available_themes["default-dark"] = ["Pi-hole midnight theme (dark)", true, "default-dark", "polaris", "polaris"];
$available_themes["default-dark2"] = ["Pi-hole afternoon theme (dark)", true, "default-dark", "futurico", "futurico"];
$webtheme = "";
// Try to load theme settings from setupVars.conf
@@ -29,15 +36,16 @@ if(!array_key_exists($webtheme,$available_themes)) {
// or requested theme is not among the available
$webtheme = "default-light";
}
$theme = $available_themes[$webtheme][1];
$checkbox_theme_name = $available_themes[$webtheme][2];
$checkbox_theme_variant = $available_themes[$webtheme][3];
$darkmode = $available_themes[$webtheme][1];
$theme = $available_themes[$webtheme][2];
$checkbox_theme_name = $available_themes[$webtheme][3];
$checkbox_theme_variant = $available_themes[$webtheme][4];
error_log(print_r($available_themes,true));
function theme_selection() {
global $available_themes, $webtheme;
foreach ($available_themes as $key => $value) {
error_log($key."->".$value);
?><input type="radio" name="webtheme" value="<?php echo $key; ?>" id="webtheme_<?php echo $key; ?>" <?php if ($key === $webtheme){ ?>checked<?php } ?>>
<label for="webtheme_<?php echo $key; ?>"><?php echo $value[0]; ?></label><br><?php
}