Files
wireguard_webadmin/templates/template_parts/dark_mode_active_sync.html

22 lines
706 B
HTML
Raw Normal View History

<script>
(function () {
function setCookie(name, value, days) {
var d = new Date();
d.setTime(d.getTime() + days * 24 * 60 * 60 * 1000);
document.cookie = name + '=' + value + ';path=/;expires=' + d.toUTCString();
}
function getCookie(name) {
var m = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
return m ? m[1] : null;
}
var userPref = getCookie('darkMode');
var isDark;
if (userPref) {
isDark = userPref === 'dark';
} else {
isDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
}
setCookie('darkModeActive', isDark ? '1' : '0', 365);
})();
</script>