refactor: inline appearance initialization
This commit is contained in:
1 parent
bc236db952
commit
20dd93d060
3 files changed
+16
-15
No files matched your search
@@ -1,12 +0,0 @@
|
|||||||
(() => {
|
|
||||||
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;
|
|
||||||
})();
|
|
||||||
+14
-1
@@ -6,7 +6,20 @@
|
|||||||
<meta name="theme-color" content="#849979">
|
<meta name="theme-color" content="#849979">
|
||||||
<meta name="description" content="Make and copy ASCII art, entirely offline.">
|
<meta name="description" content="Make and copy ASCII art, entirely offline.">
|
||||||
<title>ascii!</title>
|
<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="icon" href="./icons/ascii.svg" type="image/svg+xml">
|
||||||
<link rel="apple-touch-icon" href="./icons/apple-touch-icon.png">
|
<link rel="apple-touch-icon" href="./icons/apple-touch-icon.png">
|
||||||
<link rel="manifest" href="./manifest.webmanifest">
|
<link rel="manifest" href="./manifest.webmanifest">
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
// Bump VERSION whenever a shell file changes. New versions wait for approval.
|
// Bump VERSION whenever a shell file changes. New versions wait for approval.
|
||||||
const VERSION = 'v8';
|
const VERSION = 'v9';
|
||||||
const BASE = self.registration.scope;
|
const BASE = self.registration.scope;
|
||||||
const PREFIX = `ascii-pwa-${encodeURIComponent(BASE)}-`;
|
const PREFIX = `ascii-pwa-${encodeURIComponent(BASE)}-`;
|
||||||
const CACHE = `${PREFIX}${VERSION}`;
|
const CACHE = `${PREFIX}${VERSION}`;
|
||||||
const SHELL = [
|
const SHELL = [
|
||||||
'./', './index.html', './style.css', './appearance.js', './app.js',
|
'./', './index.html', './style.css', './app.js',
|
||||||
'./renderer.js', './font-catalog.js', './vendor/figlet.js', './vendor/alpine.js',
|
'./renderer.js', './font-catalog.js', './vendor/figlet.js', './vendor/alpine.js',
|
||||||
'./translations.js', './pwa.js', './manifest.webmanifest',
|
'./translations.js', './pwa.js', './manifest.webmanifest',
|
||||||
'./fonts/IBMPlexMono-Regular.subset.woff2',
|
'./fonts/IBMPlexMono-Regular.subset.woff2',
|
||||||
|
|||||||
Reference in new issue
Block a user