c5_labsci/web/jscss/theme.js

13 lines
415 B
JavaScript

function ciy_chgtheme(val) {
if (val)
document.documentElement.classList.remove('dark-theme');
else
document.documentElement.classList.add('dark-theme');
}
var theme = '';
if (localStorage)
theme = localStorage.getItem('theme');
if (theme == 'dark')
ciy_chgtheme(false);
else if (theme != 'light' && window.matchMedia('(prefers-color-scheme: dark)').matches)
ciy_chgtheme(false);