refactor: inline appearance initialization
This commit is contained in:
1 parent
bc236db952
commit
20dd93d060
3 files changed
+16
-15
No files matched your search
+14
-1
@@ -6,7 +6,20 @@
|
||||
<meta name="theme-color" content="#849979">
|
||||
<meta name="description" content="Make and copy ASCII art, entirely offline.">
|
||||
<title>ascii!</title>
|
||||
<script src="./appearance.js"></script>
|
||||
<script>
|
||||
(() => {
|
||||
let theme = 'system';
|
||||
let language = navigator.language.startsWith('tr') ? 'tr' : 'en';
|
||||
try {
|
||||
const storedTheme = localStorage.getItem('ascii-pwa-theme');
|
||||
const storedLanguage = localStorage.getItem('ascii-pwa-language');
|
||||
if (['system', 'light', 'dark'].includes(storedTheme)) theme = storedTheme;
|
||||
if (['en', 'tr'].includes(storedLanguage)) language = storedLanguage;
|
||||
} catch { /* Preferences remain available without persistent storage. */ }
|
||||
document.documentElement.dataset.theme = theme;
|
||||
document.documentElement.lang = language;
|
||||
})();
|
||||
</script>
|
||||
<link rel="icon" href="./icons/ascii.svg" type="image/svg+xml">
|
||||
<link rel="apple-touch-icon" href="./icons/apple-touch-icon.png">
|
||||
<link rel="manifest" href="./manifest.webmanifest">
|
||||
|
||||
Reference in new issue
Block a user