X-Git-Url: https://gitweb.ps.run/lolstats/blobdiff_plain/055e447bc0c9d170a54733539104976ec1c9004c..853f585acf864128571b4c01946d54aa0cba39c5:/html/script.js diff --git a/html/script.js b/html/script.js index cee77f6..25f1565 100644 --- a/html/script.js +++ b/html/script.js @@ -29,6 +29,14 @@ function setUrl() { "&view=" + app.view); } +function toggleStartUp() { + $("#start").removeClass("down"); + $("#start").addClass("up"); +} +function toggleStartDown() { + $("#start").removeClass("up"); + $("#start").addClass("down"); +} function slideStartUp() { $("#start").removeClass("slidedown"); $("#start").addClass("slideup"); @@ -37,23 +45,31 @@ function slideStartDown() { $("#start").removeClass("slideup"); $("#start").addClass("slidedown"); } -function changeView(view) { - if (view != "start" && view != "history" && view != "stats") { - setUrl(); - return; +function setView(view) { + console.log("Setting view to " + view); + if (view == "history") { + toggleStartUp(); + $("#matchhistory").show(); + } else if (view == "stats") { + toggleStartUp(); + $("#stats").show(); } + app.view = view; +} +function changeView(view) { let oldView = app.view; + console.log("changing view from " + oldView + " to " + 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" }); @@ -61,7 +77,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" }); @@ -75,7 +91,7 @@ let app = new Vue({ data: { summoner: "", region: "", - view: "start", + view: "", regions: getRegions(), champions: getChampions(), matchprops: getMatchProps(), @@ -102,7 +118,6 @@ let app = new Vue({ }); function parseUrl() { - console.log("parseUrl"); let url = new URL(window.location.href); if (url.searchParams.has("summoner")) { app.summoner = url.searchParams.get("summoner"); @@ -114,11 +129,20 @@ function parseUrl() { } if (url.searchParams.has("view")) { let view = url.searchParams.get("view"); - changeView(view); + if (view != "start" && view != "history" && view != "stats") { + view = "start"; + } + return view; } else { - changeView("start"); + return "start"; } } -window.addEventListener('popstate', parseUrl); -window.addEventListener('load', parseUrl); +window.addEventListener('popstate', () => { + let view = parseUrl(); + changeView(view); +}); +window.addEventListener('load', () => { + let view = parseUrl(); + setView(view); +});