summaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-10-13 12:41:22 +0200
committerTor Andersson <tor@ccxvii.net>2024-10-13 12:41:22 +0200
commit88d909a874499f9d3d18e76ff30c1155caa2e48e (patch)
treed263ee318a8934fbb1a6b755cb6d2a6fa9bfb013 /views
parent54fbf4a8dc99f2a3040fb89295ad3f9129467754 (diff)
downloadserver-88d909a874499f9d3d18e76ff30c1155caa2e48e.tar.gz
Improve sorting of games on active/user game pages.
Separate sections for "your move" and "solo" games. Stable sorting order for other games. # Conflicts: # server.js # views/games_active.pug # views/user.pug
Diffstat (limited to 'views')
-rw-r--r--views/games_active.pug23
-rw-r--r--views/user.pug14
2 files changed, 30 insertions, 7 deletions
diff --git a/views/games_active.pug b/views/games_active.pug
index a65f9be..76ac030 100644
--- a/views/games_active.pug
+++ b/views/games_active.pug
@@ -1,7 +1,11 @@
//- vim:ts=4:sw=4:
-- let open_games = games.filter(game => game.status === 0)
-- let active_games = games.filter(game => game.status === 1)
+- let open_games = games.filter(game => game.status === 0 && !game.is_match)
+- let future_games = games.filter(game => game.status === 0 && game.is_match)
+- let active_games = games.filter(game => game.status === 1 && game.is_opposed && !game.your_turn)
+- let move_games = games.filter(game => game.status === 1 && game.is_opposed && game.your_turn)
+- let solo_games = games.filter(game => game.status === 1 && !game.is_opposed)
- let finished_games = games.filter(game => game.status === 2)
+- move_games.sort((a,b)=>a.time_left-b.time_left)
doctype html
html
head
@@ -21,16 +25,25 @@ html
p
a(href="/create") Create a new game
+ if move_games.length > 0
+ h2 Move
+ +gamelist(move_games)
+
if active_games.length > 0
h2 Active
+gamelist(active_games)
+ if solo_games.length > 0
+ h2 Solo
+ +gamelist(solo_games)
+
+ if future_games.length > 0
+ h2 Future
+ +gamelist(future_games)
+
if finished_games.length > 0
h2 Recently finished
+gamelist(finished_games)
- if open_games.length === 0 && active_games.length === 0 && finished_games.length === 0
- p Nothing here.
-
p
a(href="/games/finished") All your finished games
diff --git a/views/user.pug b/views/user.pug
index dbadd36..ce5b5f0 100644
--- a/views/user.pug
+++ b/views/user.pug
@@ -1,6 +1,8 @@
//- vim:ts=4:sw=4:
-- let open_games = games.filter(game => game.status === 0)
-- let active_games = games.filter(game => game.status === 1)
+- let open_games = games.filter(game => game.status === 0 && !game.is_match)
+- let future_games = games.filter(game => game.status === 0 && game.is_match)
+- let active_games = games.filter(game => game.status === 1 && game.is_opposed)
+- let solo_games = games.filter(game => game.status === 1 && !game.is_opposed)
- let finished_games = games.filter(game => game.status === 2)
doctype html
html
@@ -48,6 +50,14 @@ html
h2 Active
+gamelist(active_games)
+ if solo_games.length > 0
+ h2 Solo
+ +gamelist(solo_games)
+
+ if future_games.length > 0
+ h2 Future
+ +gamelist(future_games)
+
if finished_games.length > 0
h2 Recently finished
+gamelist(finished_games)