1 function getRegions() {
2 return [ "euw", "na", "kr", "br" ];
4 function getChampions() {
5 return [ {name: "Aatrox"}, {name: "Annie"}, {name: "Braum"}, {name: "Not"} ];
7 function getMatchProps() {
9 {text: "Champion", name: "champ"},
10 {text: "Lane", name: "lane"},
13 function getMatches() {
15 {champ: "Xerath", lane: "Middle"},
16 {champ: "Quinn", lane: "Bottom"},
20 app.summoner = $("#nameinput").val();
21 app.region = $("#regionselect").val();
24 window.history.pushState("object or string", "Title",
32 function slideStartUp() {
33 $("#start").removeClass("slidedown");
34 $("#start").addClass("slideup");
36 function slideStartDown() {
37 $("#start").removeClass("slideup");
38 $("#start").addClass("slidedown");
40 function changeView(view) {
41 if (view != "start" && view != "history" && view != "stats") {
45 let oldView = app.view;
46 if (oldView == "start") {
47 if (view == "history") {
49 $("#matchhistory").show("slide", { direction: "down" }, 300);
50 } else if (view == "stats") {
52 $("#stats").show("slide", { direction: "down" }, 300);
54 } else if (oldView == "history") {
55 if (view == "start") {
56 $("#matchhistory").hide("slide", { direction: "down" }, 300);
58 } else if (view == "stats") {
59 $("#stats").show("blind", { direction: "right" });
60 $("#matchhistory").hide("blind", { direction: "left" });
62 } else if (oldView == "stats") {
63 if (view == "start") {
64 $("#stats").hide("slide", { direction: "down" }, 300);
66 } else if (view == "history") {
67 $("#matchhistory").show("blind", { direction: "left" });
68 $("#stats").hide("blind", { direction: "right" });
79 regions: getRegions(),
80 champions: getChampions(),
81 matchprops: getMatchProps(),
82 matches: getMatches(),
87 if (app.view == "start")
88 changeView("history");
91 historyToStats: function() {
95 statsToHistory: function() {
96 changeView("history");
99 refreshHistory: function() {
104 function parseUrl() {
105 console.log("parseUrl");
106 let url = new URL(window.location.href);
107 if (url.searchParams.has("summoner")) {
108 app.summoner = url.searchParams.get("summoner");
109 $("#nameinput").val(app.summoner);
111 if (url.searchParams.has("region")) {
112 app.region = url.searchParams.get("region");
113 $("#regionselect").val(app.region);
115 if (url.searchParams.has("view")) {
116 let view = url.searchParams.get("view");
123 window.addEventListener('popstate', parseUrl);
124 window.addEventListener('load', parseUrl);