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 toggleStartUp() {
33 $("#start").removeClass("down");
34 $("#start").addClass("up");
36 function toggleStartDown() {
37 $("#start").removeClass("up");
38 $("#start").addClass("down");
40 function slideStartUp() {
41 $("#start").removeClass("slidedown");
42 $("#start").addClass("slideup");
44 function slideStartDown() {
45 $("#start").removeClass("slideup");
46 $("#start").addClass("slidedown");
48 function setView(view) {
49 console.log("Setting view to " + view);
50 if (view == "history") {
52 $("#matchhistory").show();
53 } else if (view == "stats") {
59 function changeView(view) {
60 let oldView = app.view;
61 console.log("changing view from " + oldView + " to " + view);
62 if (oldView == "start") {
63 if (view == "history") {
65 $("#matchhistory").show("blind", { direction: "down" }, 300);
66 } else if (view == "stats") {
68 $("#stats").show("blind", { direction: "down" }, 300);
70 } else if (oldView == "history") {
71 if (view == "start") {
72 $("#matchhistory").hide("blind", { direction: "down" }, 300);
74 } else if (view == "stats") {
75 $("#stats").show("blind", { direction: "right" });
76 $("#matchhistory").hide("blind", { direction: "left" });
78 } else if (oldView == "stats") {
79 if (view == "start") {
80 $("#stats").hide("blind", { direction: "down" }, 300);
82 } else if (view == "history") {
83 $("#matchhistory").show("blind", { direction: "left" });
84 $("#stats").hide("blind", { direction: "right" });
95 regions: getRegions(),
96 champions: getChampions(),
97 matchprops: getMatchProps(),
98 matches: getMatches(),
103 if (app.view == "start")
104 changeView("history");
107 historyToStats: function() {
111 statsToHistory: function() {
112 changeView("history");
115 refreshHistory: function() {
120 function parseUrl() {
121 let url = new URL(window.location.href);
122 if (url.searchParams.has("summoner")) {
123 app.summoner = url.searchParams.get("summoner");
124 $("#nameinput").val(app.summoner);
126 if (url.searchParams.has("region")) {
127 app.region = url.searchParams.get("region");
128 $("#regionselect").val(app.region);
130 if (url.searchParams.has("view")) {
131 let view = url.searchParams.get("view");
132 if (view != "start" && view != "history" && view != "stats") {
141 window.addEventListener('popstate', () => {
142 let view = parseUrl();
145 window.addEventListener('load', () => {
146 let view = parseUrl();