Up-in-the-Air – commitdiff

You can use Git to clone the repository via the web URL. Download snapshot (zip)
Preserve font selection across tab refreshes
authorJulian Fietkau <git@fietkau.software>
Sun, 22 Sep 2024 16:25:21 +0000 (18:25 +0200)
committerJulian Fietkau <git@fietkau.software>
Sun, 22 Sep 2024 16:25:21 +0000 (18:25 +0200)
main.js

diff --git a/main.js b/main.js
index 93b3bba50fff2d97bb6519740739893e15fdf19f..c54e540aad80c8ac0e8bc03fe97515a4af2e7279 100644 (file)
--- a/main.js
+++ b/main.js
@@ -533,13 +533,15 @@ game.ui.root.querySelectorAll('button.goto').forEach((btn) => {
     game.ui.moveToPage(Array.from(target.classList).filter(c => c != 'goto')[0]);
   });
 });
-game.ui.root.querySelector('.options select.font').addEventListener('change', (e) => {
+function checkFontSelection(select) {
   game.ui.root.classList.remove('font-atkinson', 'font-opendyslexic');
-  const newFont = e.target.value;
+  const newFont = select.value;
   if(newFont != 'standard') {
     game.ui.root.classList.add('font-' + newFont);
   }
-});
+}
+checkFontSelection(game.ui.root.querySelector('.options select.font'));
+game.ui.root.querySelector('.options select.font').addEventListener('change', e => checkFontSelection(e.target));
 game.ui.moveToPage = (target, skipFade = false) => {
   let fadeDuration = 250;
   if(skipFade) {