1 function getRegions() {
4 app.regions = JSON.parse(data);
5 setTimeout(() => $("#regionselect").val(app.region), 0);
8 function getChampions() {
9 $.ajax("/lol/champions")
11 app.champions = JSON.parse(data);
14 function getMatchProps() {
16 {text: "Champion", name: "champ"},
17 {text: "Lane", name: "lane"},
20 function getMatches() {
21 $.ajax("/lol/matches?region=" + app.region + "&summoner=" + app.summoner)
24 for (p in app.matches[0]) {
27 text: p.toUpperCase(),
33 app.summoner = $("#nameinput").val();
34 app.region = $("#regionselect").val();
37 window.history.pushState("object or string", "Title",
45 function toggleStartUp() {
46 $("#start").removeClass("down");
47 $("#start").addClass("up");
49 function toggleStartDown() {
50 $("#start").removeClass("up");
51 $("#start").addClass("down");
53 function slideStartUp() {
54 $("#start").removeClass("slidedown");
55 $("#start").addClass("slideup");
57 function slideStartDown() {
58 $("#start").removeClass("slideup");
59 $("#start").addClass("slidedown");
61 function setView(view) {
62 console.log("Setting view to " + view);
63 if (view == "history") {
65 $("#matchhistory").show();
66 } else if (view == "stats") {
72 function changeView(view) {
73 let oldView = app.view;
74 console.log("changing view from " + oldView + " to " + view);
75 if (oldView == "start") {
76 if (view == "history") {
78 $("#matchhistory").show("blind", { direction: "down" }, 300);
79 } else if (view == "stats") {
81 $("#stats").show("blind", { direction: "down" }, 300);
83 } else if (oldView == "history") {
84 if (view == "start") {
85 $("#matchhistory").hide("blind", { direction: "down" }, 300);
87 } else if (view == "stats") {
88 $("#stats").show("blind", { direction: "right" });
89 $("#matchhistory").hide("blind", { direction: "left" });
91 } else if (oldView == "stats") {
92 if (view == "start") {
93 $("#stats").hide("blind", { direction: "down" }, 300);
95 } else if (view == "history") {
96 $("#matchhistory").show("blind", { direction: "left" });
97 $("#stats").hide("blind", { direction: "right" });
116 if (app.view == "start")
117 changeView("history");
120 historyToStats: function() {
124 statsToHistory: function() {
125 changeView("history");
128 refreshHistory: function() {
134 function parseUrl() {
135 let url = new URL(window.location.href);
136 if (url.searchParams.has("summoner")) {
137 app.summoner = url.searchParams.get("summoner");
138 $("#nameinput").val(app.summoner);
140 if (url.searchParams.has("region")) {
141 app.region = url.searchParams.get("region");
143 if (url.searchParams.has("view")) {
144 let view = url.searchParams.get("view");
145 if (view != "start" && view != "history" && view != "stats") {
154 window.addEventListener('popstate', () => {
155 let view = parseUrl();
158 window.addEventListener('load', async () => {
159 let view = parseUrl();