Skip to content

Commit

Permalink
Look for theme + use setInterval
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Apr 25, 2024
1 parent 2f40c0f commit e39a043
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions itables/html/init_datatables.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<script>
if (document.body.dataset.jpThemeLight === undefined ?
window.matchMedia('(prefers-color-scheme: dark)').matches :
document.body.dataset.jpThemeLight == "false") {
document.querySelector('html').classList.add('dark');
}
else {
document.querySelector('html').classList.remove('dark');
}
setInterval(() => {
if (document.documentElement.dataset.theme == "dark" ||
document.body.dataset.jpThemeLight == "false" ||
window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.documentElement.classList.add('dark');
}
else {
document.documentElement.classList.remove('dark');
}
}, 300);
</script>

0 comments on commit e39a043

Please sign in to comment.