]> gitweb.ps.run Git - lolstats/blobdiff - html/script.js
changes
[lolstats] / html / script.js
index 88f12a4e4312d604fd8e9f5e0a39c9d8a1484855..7a150c4d62480886b0affa2ccd0bb7fce97ff3f3 100644 (file)
@@ -1,8 +1,14 @@
 function getRegions() {
 function getRegions() {
-  return [ "euw", "na", "kr", "br" ];
+  $.ajax("/lol/regions")
+    .done((data) => {
+      app.regions = JSON.parse(data);
+    });
 }
 function getChampions() {
 }
 function getChampions() {
-  return [ {name: "Aatrox"}, {name: "Annie"}, {name: "Braum"}, {name: "Not"} ];
+  $.ajax("/lol/champions")
+    .done((data) => {
+      app.champions = JSON.parse(data);
+    });
 }
 function getMatchProps() {
   return [
 }
 function getMatchProps() {
   return [
@@ -11,66 +17,10 @@ function getMatchProps() {
   ];
 }
 function getMatches() {
   ];
 }
 function getMatches() {
-  return [
-    {champ: "Xerath", lane: "Middle"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-    {champ: "Quinn", lane: "Bottom"},
-  ];
+  $.ajax("/lol/matches?region=" + app.region + "&summoner=" + app.summoner)
+    .done((data) => {
+      app.matches = JSON.parse(data);
+    });
 }
 function getInfo() {
   app.summoner = $("#nameinput").val();
 }
 function getInfo() {
   app.summoner = $("#nameinput").val();
@@ -118,14 +68,14 @@ function changeView(view) {
   if (oldView == "start") {
     if (view == "history") {
       slideStartUp();
   if (oldView == "start") {
     if (view == "history") {
       slideStartUp();
-      $("#matchhistory").show("slide", { direction: "down" }, 300);
+      $("#matchhistory").show("blind", { direction: "down" }, 300);
     } else if (view == "stats") {
       slideStartUp();
     } else if (view == "stats") {
       slideStartUp();
-      $("#stats").show("slide", { direction: "down" }, 300);
+      $("#stats").show("blind", { direction: "down" }, 300);
     }
   } else if (oldView == "history") {
     if (view == "start") {
     }
   } else if (oldView == "history") {
     if (view == "start") {
-      $("#matchhistory").hide("slide", { direction: "down" }, 300);
+      $("#matchhistory").hide("blind", { direction: "down" }, 300);
       slideStartDown();
     } else if (view == "stats") {
       $("#stats").show("blind", { direction: "right" });
       slideStartDown();
     } else if (view == "stats") {
       $("#stats").show("blind", { direction: "right" });
@@ -133,7 +83,7 @@ function changeView(view) {
     }
   } else if (oldView == "stats") {
     if (view == "start") {
     }
   } else if (oldView == "stats") {
     if (view == "start") {
-      $("#stats").hide("slide", { direction: "down" }, 300);
+      $("#stats").hide("blind", { direction: "down" }, 300);
       slideStartDown();
     } else if (view == "history") {
       $("#matchhistory").show("blind", { direction: "left" });
       slideStartDown();
     } else if (view == "history") {
       $("#matchhistory").show("blind", { direction: "left" });
@@ -148,10 +98,10 @@ let app = new Vue({
     summoner: "",
     region: "",
     view: "",
     summoner: "",
     region: "",
     view: "",
-    regions: getRegions(),
-    champions: getChampions(),
-    matchprops: getMatchProps(),
-    matches: getMatches(),
+    regions: [],
+    champions: [],
+    matchprops: [],
+    matches: [],
   },
   methods: {
     submit: function() {
   },
   methods: {
     submit: function() {
@@ -169,6 +119,7 @@ let app = new Vue({
       setUrl();
     },
     refreshHistory: function() {
       setUrl();
     },
     refreshHistory: function() {
+      getMatches();
     },
   },
 });
     },
   },
 });
@@ -201,4 +152,6 @@ window.addEventListener('popstate', () => {
 window.addEventListener('load', () => {
   let view = parseUrl();
   setView(view);
 window.addEventListener('load', () => {
   let view = parseUrl();
   setView(view);
+  getRegions();
+  getChampions();
 });
 });