diff --git a/static/games_page.css b/static/games_page.css index af6b1d3..65cb5bd 100644 --- a/static/games_page.css +++ b/static/games_page.css @@ -5,34 +5,32 @@ body { } /* Background pattern from Toptal Subtle Patterns */ -#link_div { +div { font-family: 'Alegreya', serif; + color: white; +} + +#link_div { text-align: right; position: absolute; top: 0px; right: 30px; } -#link_div > a:link { - color: lightblue; +#link_div > a { background-color: transparent; text-decoration: underline; } -#link_div > a:visited { +#link_div > a:link, #link_div > a:visited { color: lightblue; - background-color: transparent; - text-decoration: underline; } #link_div > a:hover { color: white; - background-color: transparent; - text-decoration: underline; } .container { - font-family: 'Alegreya', serif; display: grid; grid-template-columns: repeat(3, minmax(500px, 1fr)); grid-template-rows: 330px; @@ -45,14 +43,41 @@ body { #header { width: 100%; - height: 100px; - margin-bottom: 50px; + height: 150px; + margin-bottom: 20px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; } #header > .page_header { margin: auto } +#filters { + display: flex; + justify-content: space-around; + width: max-content; + margin-top: 10px; +} + +#filters > div { + padding: 4px 8px; + margin: 0px 8px; + font-size: 16pt; +} + +#filters > .filter { + border-radius: 8px; + min-width: 50px; + text-align: center; +} + +#selected_filter { + background: rgb(113, 54, 138); +} + #footer { display: flex; flex-direction: column; @@ -63,8 +88,6 @@ body { #footer > div { text-align: center; - color: white; - font-family: 'Alegreya', serif; font-size: 20px; position: relative; top: 5px; diff --git a/static/loader.js b/static/loader.js index 7ca2d83..49c9905 100644 --- a/static/loader.js +++ b/static/loader.js @@ -1,6 +1,6 @@ $(document).ready(function (){ var socket = io.connect(); - var gameslist = []; + var lastupdate; var grid = document.getElementById("container"); @@ -9,6 +9,41 @@ $(document).ready(function (){ }); socket.on("states_update", function (json) { //json is an object containing all game updates + lastupdate = json; + updateGames(json, $('#selected_filter').text()); + + //get all leagues + leagues = [] + for (var key in json) { + if (json[key].is_league) { + leagues.push(json[key].leagueoruser) + } + } + + //remove leagues no longer present + $('#filters .filter').each(function(index) { + if (!leagues.includes($(this).text())) { + if ($(this).attr('id') != 'selected_filter') { + $(this).remove(); + } + } else { + leagues.splice(leagues.indexOf($(this).text()), 1); + } + }) + + // add leagues not already present + for (var league in leagues) { + $('filters').append("