1 function getRegions() {
4 app.regions = JSON.parse(data);
7 function getChampions() {
8 $.ajax("/lol/champions")
10 app.champions = JSON.parse(data);
13 function getMatchProps() {
15 {text: "Champion", name: "champ"},
16 {text: "Lane", name: "lane"},
19 function getMatches() {
20 $.ajax("/lol/matches?region=" + app.region + "&summoner=" + app.summoner)
22 app.matches = JSON.parse(data);
26 app.summoner = $("#nameinput").val();
27 app.region = $("#regionselect").val();
30 window.history.pushState("object or string", "Title",
38 function toggleStartUp() {
39 $("#start").removeClass("down");
40 $("#start").addClass("up");
42 function toggleStartDown() {
43 $("#start").removeClass("up");
44 $("#start").addClass("down");
46 function slideStartUp() {
47 $("#start").removeClass("slidedown");
48 $("#start").addClass("slideup");
50 function slideStartDown() {
51 $("#start").removeClass("slideup");
52 $("#start").addClass("slidedown");
54 function setView(view) {
55 console.log("Setting view to " + view);
56 if (view == "history") {
58 $("#matchhistory").show();
59 } else if (view == "stats") {
65 function changeView(view) {
66 let oldView = app.view;
67 console.log("changing view from " + oldView + " to " + view);
68 if (oldView == "start") {
69 if (view == "history") {
71 $("#matchhistory").show("blind", { direction: "down" }, 300);
72 } else if (view == "stats") {
74 $("#stats").show("blind", { direction: "down" }, 300);
76 } else if (oldView == "history") {
77 if (view == "start") {
78 $("#matchhistory").hide("blind", { direction: "down" }, 300);
80 } else if (view == "stats") {
81 $("#stats").show("blind", { direction: "right" });
82 $("#matchhistory").hide("blind", { direction: "left" });
84 } else if (oldView == "stats") {
85 if (view == "start") {
86 $("#stats").hide("blind", { direction: "down" }, 300);
88 } else if (view == "history") {
89 $("#matchhistory").show("blind", { direction: "left" });
90 $("#stats").hide("blind", { direction: "right" });
109 if (app.view == "start")
110 changeView("history");
113 historyToStats: function() {
117 statsToHistory: function() {
118 changeView("history");
121 refreshHistory: function() {
127 function parseUrl() {
128 let url = new URL(window.location.href);
129 if (url.searchParams.has("summoner")) {
130 app.summoner = url.searchParams.get("summoner");
131 $("#nameinput").val(app.summoner);
133 if (url.searchParams.has("region")) {
134 app.region = url.searchParams.get("region");
135 $("#regionselect").val(app.region);
137 if (url.searchParams.has("view")) {
138 let view = url.searchParams.get("view");
139 if (view != "start" && view != "history" && view != "stats") {
148 window.addEventListener('popstate', () => {
149 let view = parseUrl();
152 window.addEventListener('load', () => {
153 let view = parseUrl();