Co-authored-by: dbroqua <contact@darkou.fr>
Reviewed-on: https://git.darkou.fr/dbroqua/MusicTopus/pulls/28
Co-authored-by: Damien Broqua <dbroqua@noreply.localhost>
Co-committed-by: Damien Broqua <dbroqua@noreply.localhost>
This commit is contained in:
Damien Broqua 2022-03-04 16:33:45 +01:00
parent cf63d8b6d8
commit b27a81a0b6
26 changed files with 1094 additions and 97 deletions

View file

@ -1,7 +1,7 @@
/**
* Fonction permettant d'afficher un message dans un toastr
* @param {String} message
*/
* Fonction permettant d'afficher un message dans un toastr
* @param {String} message
*/
function showToastr(message) {
let x = document.getElementById("toastr");
if ( message ) {
@ -114,17 +114,22 @@ document.addEventListener('DOMContentLoaded', () => {
}
const switchAriaThemeBtn = document.querySelector("#switchAriaTheme");
switchAriaThemeBtn.addEventListener("click", switchAriaTheme);
if ( switchAriaThemeBtn ) {
switchAriaThemeBtn.addEventListener("click", switchAriaTheme);
}
setAriaTheme(getCookie('ariatheme'));
const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]');
toggleSwitch.addEventListener('change', switchTheme, false);
if ( toggleSwitch ) {
toggleSwitch.addEventListener('change', switchTheme, false);
}
let currentThemeIsDark = getCookie('theme');
if ( currentThemeIsDark === 'false' && window.matchMedia ) {
currentThemeIsDark = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
}
console.log('currentThemeIsDark:', currentThemeIsDark);
switchTheme({target: {checked: currentThemeIsDark === 'dark'}});
toggleSwitch.checked = currentThemeIsDark === 'dark';
if ( toggleSwitch) {
toggleSwitch.checked = currentThemeIsDark === 'dark';
}
});