From 7a1900d8149ef6636ab8d48f0b4a38e4a30fb8ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Gur=C3=A1=C5=88?= Date: Mon, 28 Aug 2023 23:17:31 +0200 Subject: [PATCH] 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. --- app/js/custom.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/app/js/custom.js b/app/js/custom.js index ff42f1d6..d3fb9b3b 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -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'); + } } }); });