diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-06-13 18:07:04 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-06-14 16:49:10 +0200 |
commit | 21bcebd491d0fa4393bb4f2263af446aa67bfedd (patch) | |
tree | 6e9138fdd74c9b7bb58736d8545ece3de9202c78 | |
parent | 072766b71f9441fdd2796b8dd1137b90acd5a561 (diff) | |
download | server-21bcebd491d0fa4393bb4f2263af446aa67bfedd.tar.gz |
Sort your turn games before others in personal ready and active lists.
-rw-r--r-- | public/style.css | 1 | ||||
-rw-r--r-- | server.js | 10 | ||||
-rw-r--r-- | views/games_public.pug | 4 |
3 files changed, 10 insertions, 5 deletions
diff --git a/public/style.css b/public/style.css index fc70bb7..dd9b49e 100644 --- a/public/style.css +++ b/public/style.css @@ -140,6 +140,7 @@ article hr + p { font-style: italic; } display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 400px)); gap: 24px; + margin: 16px 0; } .game_item { border: 1px solid black; @@ -1104,6 +1104,12 @@ app.get('/games', function (req, res) { res.redirect('/games/public') }) +function sort_your_turn(a, b) { + if (a.your_turn && !b.your_turn) return -1 + if (!a.your_turn && b.your_turn) return 1 + return 0 +} + app.get('/games/active', must_be_logged_in, function (req, res) { let games = QUERY_LIST_ACTIVE_GAMES_OF_USER.all({ user_id: req.user.user_id }) annotate_games(games, req.user.user_id) @@ -1111,8 +1117,8 @@ app.get('/games/active', must_be_logged_in, function (req, res) { user: req.user, open_games: games.filter(is_open_game), replacement_games: games.filter(is_replacement_game), - ready_games: games.filter(is_ready_game), - active_games: games.filter(is_active_game), + ready_games: games.filter(is_ready_game).sort(sort_your_turn), + active_games: games.filter(is_active_game).sort(sort_your_turn), finished_games: games.filter(is_finished_game), }) }) diff --git a/views/games_public.pug b/views/games_public.pug index 9c56402..44b250d 100644 --- a/views/games_public.pug +++ b/views/games_public.pug @@ -25,8 +25,6 @@ html h2 Ready to start +gamelist(ready_games) - h2 Active if active_games.length > 0 + h2 Active +gamelist(active_games) - else - p No open games. |