1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00

Update custom.js

Updated dark theme switcher so now it can switch between dark and light material theme while keeping it's functionality to stock theme.
This commit is contained in:
Marek Guráň 2023-08-28 23:17:31 +02:00 committed by GitHub
parent 3cf88d98b2
commit 7a1900d814
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -536,12 +536,27 @@ function set_theme(theme) {
}
$(function() {
var currentTheme = getCookie('theme');
// Check if the current theme is a dark theme
var isDarkTheme = currentTheme === 'lightsout.css' || currentTheme === 'material-dark.php';
$('#night-mode').prop('checked', isDarkTheme);
$('#night-mode').change(function() {
var state = $(this).is(':checked');
if (state == true && getCookie('theme') != 'lightsout.css') {
set_theme('lightsout.css');
var currentTheme = getCookie('theme');
if (state == true) {
if (currentTheme == 'custom.php') {
set_theme('lightsout.css');
} else if (currentTheme == 'material-light.php') {
set_theme('material-dark.php');
}
} else {
set_theme('custom.php');
if (currentTheme == 'lightsout.css') {
set_theme('custom.php');
} else if (currentTheme == 'material-dark.php') {
set_theme('material-light.php');
}
}
});
});