mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
b2c60ef898
This marks the launch of the new documentation website.
39 lines
865 B
JavaScript
39 lines
865 B
JavaScript
const mode = document.getElementById('mode');
|
|
|
|
if (mode !== null) {
|
|
|
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
|
|
|
|
if (event.matches) {
|
|
|
|
localStorage.setItem('theme', 'dark');
|
|
document.documentElement.setAttribute('data-dark-mode', '');
|
|
|
|
} else {
|
|
|
|
localStorage.setItem('theme', 'light');
|
|
document.documentElement.removeAttribute('data-dark-mode');
|
|
|
|
}
|
|
|
|
})
|
|
|
|
mode.addEventListener('click', () => {
|
|
|
|
document.documentElement.toggleAttribute('data-dark-mode');
|
|
localStorage.setItem('theme', document.documentElement.hasAttribute('data-dark-mode') ? 'dark' : 'light');
|
|
|
|
});
|
|
|
|
if (localStorage.getItem('theme') === 'dark') {
|
|
|
|
document.documentElement.setAttribute('data-dark-mode', '');
|
|
|
|
} else {
|
|
|
|
document.documentElement.removeAttribute('data-dark-mode');
|
|
|
|
}
|
|
|
|
}
|