Up-in-the-Air – commitdiff

You can use Git to clone the repository via the web URL. Download snapshot (zip)
Clean up options page even handling code
authorJulian Fietkau <git@fietkau.software>
Tue, 24 Sep 2024 16:39:21 +0000 (18:39 +0200)
committerJulian Fietkau <git@fietkau.software>
Tue, 24 Sep 2024 16:39:21 +0000 (18:39 +0200)
main.js

diff --git a/main.js b/main.js
index cecfcd8804f30e70dfa17cce1aa42c33f3b3873d..8c94649a2c8941b9e746087443e83dd8fc615229 100644 (file)
--- a/main.js
+++ b/main.js
@@ -876,6 +876,10 @@ game.ui.root.querySelectorAll('button.goto').forEach((btn) => {
 game.ui.root.querySelectorAll('.options .controls input, .options .graphics input, .options .feather input, .options .accessibility input, .options .accessibility select').forEach((elem) => {
   elem.addEventListener('change', () => {
     applySettings(game);
+    if(elem.name == 'upInTheAirGame-controls') {
+      game.ui.root.querySelectorAll('.options .controls p span:not(.' + game.settings['controls'] + ')').forEach(span => span.style.display = 'none');
+      game.ui.root.querySelector('.options .controls span.' + game.settings['controls']).style.display = 'block';
+    }
     if(elem.value == 'highcontrast' || elem.name == 'upInTheAirGame-graphics') {
       createMeshes(game);
     }
@@ -907,12 +911,6 @@ game.ui.root.querySelectorAll('.options .audio button').forEach((btn) => {
     }
   });
 });
-game.ui.root.querySelectorAll('.options .controls input').forEach((radio) => {
-  radio.addEventListener('change', () => applySettings(game));
-});
-game.ui.root.querySelectorAll('.options input[name=upInTheAirGame-font]').forEach((radio) => {
-  radio.addEventListener('change', () => applySettings(game));
-});
 game.ui.root.querySelector('.options .keyboard button[value="reset"]').addEventListener('click', applySettings(game));
 game.ui.root.querySelectorAll('.ui-page .areatabs button').forEach((btn) => {
   btn.addEventListener('click', (e) => {