web/cobalt.js: clean up

This commit is contained in:
wukko 2024-05-12 17:31:33 +06:00
parent 8bcb98f005
commit 4aa5aef775
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2

View file

@ -151,13 +151,6 @@ const preferredColorScheme = () => {
return theme
}
if (window.matchMedia) {
window.matchMedia('(prefers-color-scheme: light)').addEventListener('change', () => {
changeStatusBarColor()
detectColorScheme()
})
}
const changeStatusBarColor = () => {
const theme = preferredColorScheme();
const colors = {
@ -176,10 +169,15 @@ const changeStatusBarColor = () => {
document.querySelector('meta[name="theme-color"]').setAttribute('content', colors[state]);
}
const detectColorScheme = () => {
let theme = preferredColorScheme();
document.documentElement.setAttribute("data-theme", preferredColorScheme());
changeStatusBarColor();
}
document.documentElement.setAttribute("data-theme", theme);
changeStatusBarColor(theme);
if (window.matchMedia) {
window.matchMedia('(prefers-color-scheme: light)').addEventListener('change', () => {
changeStatusBarColor()
detectColorScheme()
})
}
const updateFilenamePreview = () => {