Replace lightsout.php w/ dark.css, set data-bs-theme

This commit is contained in:
billz
2024-10-26 03:17:52 -07:00
parent eb3873ac3f
commit 3004ce49cc
3 changed files with 16 additions and 379 deletions

View File

@@ -759,7 +759,7 @@ $(function() {
if (nightModeChecked && hasDarkTheme) {
if (theme === "custom.php") {
set_theme("lightsout.php");
set_theme("dark.css");
}
} else {
set_theme(theme);
@@ -776,7 +776,7 @@ function set_theme(theme) {
$(function() {
var currentTheme = getCookie('theme');
// Check if the current theme is a dark theme
var isDarkTheme = currentTheme === 'lightsout.php';
var isDarkTheme = currentTheme === 'dark.css';
$('#night-mode').prop('checked', isDarkTheme);
$('#night-mode').change(function() {
@@ -785,10 +785,10 @@ $(function() {
if (state == true) {
if (currentTheme == 'custom.php') {
set_theme('lightsout.php');
set_theme('dark.css');
}
} else {
if (currentTheme == 'lightsout.php') {
if (currentTheme == 'dark.css') {
set_theme('custom.php');
}
}
@@ -855,6 +855,17 @@ $(window).bind("load", function() {
}).parent().addClass('active');
});
$(document).ready(function() {
const $htmlElement = $('html');
const $modeswitch = $('#night-mode');
$modeswitch.on('change', function() {
const isChecked = $(this).is(':checked');
const newTheme = isChecked ? 'dark' : 'light';
$htmlElement.attr('data-bs-theme', newTheme);
localStorage.setItem('bsTheme', newTheme);
});
});
$(document)
.ajaxSend(setCSRFTokenHeader)
.ready(contentLoaded)