fix chrome incompatibility
authorMoritz Warning <moritzwarning@web.de>
Sun, 5 Apr 2020 22:19:43 +0000 (00:19 +0200)
committerMoritz Warning <moritzwarning@web.de>
Sun, 5 Apr 2020 22:19:43 +0000 (00:19 +0200)
index.html
index.js

index 542b82339dd71a4735a9edc598944f77185d0094..21f91d58cdcd528462503a6a953bfa168c4c7c90 100644 (file)
@@ -5,8 +5,11 @@
        <meta charset="utf-8"/>
        <title>OpenWrt Firmware Selector</title>
        <link rel="stylesheet" href="index.css" />
+       <script src="i18n.js"></script>
+       <script src="config.js"></script>
+       <script src="index.js"></script>
 </head>
-<body>
+<body onload="init()">
 
 <header>
        <div>
@@ -16,7 +19,7 @@
                <img src="logo.png" alt="Logo">
                <div style="flex-grow: 1;"></div>
 
-               <select id="language-selection" onchange="config.language=this.children[this.selectedIndex].value; translate();" size="1">
+               <select id="language-selection" size="1">
                        <option value="en">English</option>
                        <option value="es">EspaƱol</option>
                        <option value="de">Deutsch</option>
                </div>
        </div>
 </div>
-
-<script src="i18n.js"></script>
-<script src="config.js"></script>
-<script src="index.js"></script>
-
 </body>
 </html>
index cdd4d6f169038bb50ca3f4dc7c5519a9391cd047..eb0a4695aa04dde3172988b17c6c8d9b50dc0457 100644 (file)
--- a/index.js
+++ b/index.js
@@ -346,40 +346,47 @@ function updateImages(version, code, date, model, url, mobj, is_custom) {
   }
 }
 
-setupSelectList($('versions'), Object.keys(config.versions), version => {
-  fetch(config.versions[version]).then(data => {
-    data.json().then(obj => {
-      setupAutocompleteList($('models'), Object.keys(obj['models']), model => {
-        if (model in obj['models']) {
-          var url = obj.url;
-          var code = obj.version_code;
-          var date = obj.build_data || 'unknown';
-          var mobj = obj['models'][model];
-          updateImages(version, code, date, model, url, mobj, false);
-          current_model = mobj;
-        } else {
-          updateImages();
-          current_model = {};
-        }
-      });
+function init() {
+  setupSelectList($('versions'), Object.keys(config.versions), version => {
+    fetch(config.versions[version]).then(data => {
+      data.json().then(obj => {
+        setupAutocompleteList($('models'), Object.keys(obj['models']), model => {
+          if (model in obj['models']) {
+            var url = obj.url;
+            var code = obj.version_code;
+            var date = obj.build_data || 'unknown';
+            var mobj = obj['models'][model];
+            updateImages(version, code, date, model, url, mobj, false);
+            current_model = mobj;
+          } else {
+            updateImages();
+            current_model = {};
+          }
+        });
 
-      // trigger model update when selected version changes
-      $('models').onfocus();
+        // trigger model update when selected version changes
+        $('models').onfocus();
+      });
     });
   });
-});
 
-if (config.asu_url) {
-  show('custom');
-}
+  if (config.asu_url) {
+    show('custom');
+  }
 
-// hide fields
-updateImages();
+  // hide fields
+  updateImages();
 
-var user_lang = (navigator.language || navigator.userLanguage).split('-')[0];
-if (user_lang in translations) {
-  config.language = user_lang;
-  $('language-selection').value = user_lang;
-}
+  var user_lang = (navigator.language || navigator.userLanguage).split('-')[0];
+  if (user_lang in translations) {
+    config.language = user_lang;
+    $('language-selection').value = user_lang;
+  }
+
+  translate();
 
-translate();
+  $('language-selection').onclick = function() {
+    config.language = this.children[this.selectedIndex].value;
+    translate();
+  }
+}