]> gitweb.ps.run Git - lolstats/commitdiff
changes
authorPatrick Schönberger <patrick.schoenberger@posteo.de>
Thu, 13 Dec 2018 12:21:36 +0000 (13:21 +0100)
committerPatrick Schönberger <patrick.schoenberger@posteo.de>
Thu, 13 Dec 2018 12:21:36 +0000 (13:21 +0100)
html/script.js

index 7a150c4d62480886b0affa2ccd0bb7fce97ff3f3..11052629613b6c2d3d9407ffaabb20073b74e19a 100644 (file)
@@ -2,6 +2,7 @@ function getRegions() {
   $.ajax("/lol/regions")
     .done((data) => {
       app.regions = JSON.parse(data);
+      setTimeout(() => $("#regionselect").val(app.region), 0);
     });
 }
 function getChampions() {
@@ -19,7 +20,13 @@ function getMatchProps() {
 function getMatches() {
   $.ajax("/lol/matches?region=" + app.region + "&summoner=" + app.summoner)
     .done((data) => {
-      app.matches = JSON.parse(data);
+      app.matches = data;
+      for (p in app.matches[0]) {
+        app.matchprops.push({
+          name: p,
+          text: p.toUpperCase(),
+        });
+      }
     });
 }
 function getInfo() {
@@ -132,7 +139,6 @@ function parseUrl() {
   }
   if (url.searchParams.has("region")) {
     app.region = url.searchParams.get("region");
-    $("#regionselect").val(app.region);
   }
   if (url.searchParams.has("view")) {
     let view = url.searchParams.get("view");
@@ -149,7 +155,7 @@ window.addEventListener('popstate', () => {
   let view = parseUrl();
   changeView(view);
 });
-window.addEventListener('load', () => {
+window.addEventListener('load', async () => {
   let view = parseUrl();
   setView(view);
   getRegions();