From 34487c1b1920c6a52108a7ed7b390d4b08728ff9 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 23 Jul 2024 13:48:12 +0200 Subject: New join page! * Remove explicit (and redundant) role=Observer parameter. * Remove old /play/:id redirects. * Show "private" badge on game boxes. * Forbid leave/kick in public games. * Allow "rewind" by owner in public games. --- views/create.pug | 6 ++-- views/head.pug | 23 ++++++++-------- views/info.pug | 4 --- views/join.pug | 84 ++++++++++++++++---------------------------------------- 4 files changed, 38 insertions(+), 79 deletions(-) (limited to 'views') diff --git a/views/create.pug b/views/create.pug index 4e52da4..912156c 100644 --- a/views/create.pug +++ b/views/create.pug @@ -13,6 +13,8 @@ html div.logo +gamecover(title.title_id) + if limit + p.error= limit if !user p.error You are not logged in! @@ -77,9 +79,7 @@ html input(type="checkbox" name="is_private" value="true") | Private - if limit - p.error= limit - else + if !limit p button(type="submit") Create diff --git a/views/head.pug b/views/head.pug index 3deb614..e4ff857 100644 --- a/views/head.pug +++ b/views/head.pug @@ -61,10 +61,11 @@ mixin gamelist(list,hide_title=0) else if (item.status === 2) className += " finished" else if (item.status === 3) className += " archived" if (item.is_unread) chat_icon = "\u{1f4dd}" - if (item.is_match) pace_icon = EMOJI_MATCH - else if (item.pace === 1) pace_icon = EMOJI_LIVE, pace_text = "Live!" - else if (item.pace === 2) pace_icon = EMOJI_FAST, pace_text = "Fast - many moves per day" - else if (item.pace === 3) pace_icon = EMOJI_SLOW, pace_text = "Slow - one move per day" + if (item.is_private) pace_icon += EMOJI_PRIVATE + if (item.is_match) pace_icon += EMOJI_MATCH + else if (item.pace === 1) pace_icon += EMOJI_LIVE, pace_text = "Live!" + else if (item.pace === 2) pace_icon += EMOJI_FAST, pace_text = "Fast - many moves per day" + else if (item.pace === 3) pace_icon += EMOJI_SLOW, pace_text = "Slow - one move per day" div(class=className) div.game_head @@ -77,25 +78,25 @@ mixin gamelist(list,hide_title=0) case item.status when 0 - a(class="command" href=`/join/${item.game_id}`) Enter + a(class="command" href=`/join/${item.game_id}`) Join when 1 if !item.is_ready - a(class="command" href="/join/"+item.game_id) Enter + a(class="command" href="/join/"+item.game_id) Join else if item.is_yours if item.your_role a(class="command" href=`/${item.title_id}/play.html?game=${item.game_id}&role=${encodeURIComponent(item.your_role)}`) Play else - a(class="command" href="/join/"+item.game_id) Enter + a(class="command" href="/join/"+item.game_id) Play else - a(class="command" href=`/${item.title_id}/play.html?game=${item.game_id}&role=Observer`) View + a(class="command" href=`/${item.title_id}/play.html?game=${item.game_id}`) Watch when 2 if item.is_yours if item.your_role - a(class="command" href=`/${item.title_id}/play.html?game=${item.game_id}&role=${encodeURIComponent(item.your_role)}`) Play + a(class="command" href=`/${item.title_id}/play.html?game=${item.game_id}&role=${encodeURIComponent(item.your_role)}`) Review else - a(class="command" href="/join/"+item.game_id) Enter + a(class="command" href="/join/"+item.game_id) Review else - a(class="command" href=`/${item.title_id}/play.html?game=${item.game_id}&role=Observer`) View + a(class="command" href=`/${item.title_id}/play.html?game=${item.game_id}`) Review when 3 | Archived diff --git a/views/info.pug b/views/info.pug index 369cf8a..5c8346b 100644 --- a/views/info.pug +++ b/views/info.pug @@ -30,10 +30,6 @@ html p a(href="/create/"+title.title_id) Create a new game - if ready_games.length > 0 - h2 Open (waiting to start) - +gamelist(ready_games, true) - if active_games.length > 0 h2 Recently active +gamelist(active_games, true) diff --git a/views/join.pug b/views/join.pug index 1f00995..257e4a8 100644 --- a/views/join.pug +++ b/views/join.pug @@ -8,71 +8,51 @@ html game.title_id) title ##{game.game_id} - #{game.title_name} style. - th,td { border: var(--table-border); } - a.red { text-decoration: none; color: var(--color-red); font-size: 15px; float: right; } - a.green { text-decoration: none; color: var(--color-green); font-size: 15px; float: right; } - td, th { border: var(--thin-border); } - td { width: 180px; } - .hide { display: none; } - td.is_invite { background-color: var(--color-table-invite); } - td.is_active { background-color: var(--color-table-active); } - td.enemy { background-color: var(--color-table-danger); } - td.enemy::before { content: "\1f6ab "; font-size: 15px; } + table { width: clamp(240px, 100%, 400px); } + table.invite tr.p { background-color: var(--color-table-invite) } + table.active tr.p { background-color: var(--color-table-active) } + #game_info td { padding: 2px 10px } + #game_info td:first-child { width: 80px } + #game_info tr:first-child td { padding-top: 5px } + #game_info tr:last-child td { padding-bottom: 5px } + td.r a { margin-left: 18px; } + tr.p i { color: #0008; } + td.blacklist::before { color: brown; content: "\1f6ab "; font-size: 15px; } script. let game = !{ JSON.stringify(game) } - let roles = !{ JSON.stringify(roles) } let players = !{ JSON.stringify(players) } + let roles = !{ JSON.stringify(roles) } let user_id = !{ user ? user.user_id : 0 } - let whitelist = !{ JSON.stringify(whitelist) } let blacklist = !{ JSON.stringify(blacklist) } let friends = !{ JSON.stringify(friends) } - let limit = !{ !!limit } - let ready = !{ ready } script(src="/join.js") body include header article - if game.scenario === "Standard" - h1 ##{game.game_id} - #{game.title_name} + if icon + h1 #{icon} ##{game.game_id} - #{game.title_name} else - h1 ##{game.game_id} - #{game.title_name} - #{game.scenario} + h1 ##{game.game_id} - #{game.title_name} div.logo +gamecover(game.title_id) + p.error#error + if limit && game.status < 1 p.error= limit if !user p.error You are not logged in! - p.error#error - if game.owner_id - if game.is_private - p Created #{game.ctime} by #{game.owner_name} (private). - else - p Created #{game.ctime} by #{game.owner_name}. - else - p Created #{game.ctime}. + div#game_info - if game.status > 1 - p Finished #{game.mtime}. - else if game.status > 0 - p Last move #{game.mtime}. + p#game_enter - unless game.human_options === "None" - p Options: #{game.human_options}. + div#game_players - case game.pace - when 1 - p #{EMOJI_LIVE} Live! - when 2 - p #{EMOJI_FAST} Fast – many moves per day. - when 3 - p #{EMOJI_SLOW} Slow – one move per day. + p#game_actions - if game.notice - p - i= game.notice + p.error#disconnected if user dialog(id="invite") @@ -87,30 +67,12 @@ html button(onclick="send_invite()") Invite button(onclick="hide_invite()") Cancel - p - table - tbody - each role in roles - tr - th.w(id="role_"+role.replace(/ /g, "_")+"_name")= role - td(id="role_"+role.replace(/ /g, "_")) - - tfoot - tr - td#message(colspan=2) - - - p - button.hide#delete_button(onclick="confirm_delete()") Delete - button.hide#start_button(onclick="start()" disabled) Start - - if !user && !ready - p Login or sign up to play. - if user && user.user_id === 1 hr div: p each snap in rewind - REWIND #{snap.snap_id} - #{snap.state} - #{snap.active} + REWIND #{snap.snap_id} - #{snap.state} - #{snap.active} br if DEBUG - CLONE + CLONE br -- cgit v1.2.3