X-Git-Url: https://gitweb.ps.run/lolstats/blobdiff_plain/c714fc5d53069a25203ee09916e40dfbcb6f547b..cc2c4151a7641025525c1b9f51b081690d7d17a7:/html/script.js diff --git a/html/script.js b/html/script.js index 88f12a4..7a150c4 100644 --- a/html/script.js +++ b/html/script.js @@ -1,8 +1,14 @@ function getRegions() { - return [ "euw", "na", "kr", "br" ]; + $.ajax("/lol/regions") + .done((data) => { + app.regions = JSON.parse(data); + }); } function getChampions() { - return [ {name: "Aatrox"}, {name: "Annie"}, {name: "Braum"}, {name: "Not"} ]; + $.ajax("/lol/champions") + .done((data) => { + app.champions = JSON.parse(data); + }); } function getMatchProps() { return [ @@ -11,66 +17,10 @@ function getMatchProps() { ]; } 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(); @@ -118,14 +68,14 @@ function changeView(view) { if (oldView == "start") { if (view == "history") { slideStartUp(); - $("#matchhistory").show("slide", { direction: "down" }, 300); + $("#matchhistory").show("blind", { direction: "down" }, 300); } else if (view == "stats") { slideStartUp(); - $("#stats").show("slide", { direction: "down" }, 300); + $("#stats").show("blind", { direction: "down" }, 300); } } 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" }); @@ -133,7 +83,7 @@ function changeView(view) { } } 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" }); @@ -148,10 +98,10 @@ let app = new Vue({ summoner: "", region: "", view: "", - regions: getRegions(), - champions: getChampions(), - matchprops: getMatchProps(), - matches: getMatches(), + regions: [], + champions: [], + matchprops: [], + matches: [], }, methods: { submit: function() { @@ -169,6 +119,7 @@ let app = new Vue({ setUrl(); }, refreshHistory: function() { + getMatches(); }, }, }); @@ -201,4 +152,6 @@ window.addEventListener('popstate', () => { window.addEventListener('load', () => { let view = parseUrl(); setView(view); + getRegions(); + getChampions(); });