commit af13b2ab18ab23784f756790e7b1a9da87d813d6
parent 3228f4eff5df7040dc97b45cdccd887139eb8d3d
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Fri, 9 Jun 2023 02:26:09 -0700
chess spectator have a "flip board" link
Diffstat:
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/pkg/web/handlers/interceptors/chess.go b/pkg/web/handlers/interceptors/chess.go
@@ -369,6 +369,11 @@ func (g *ChessGame) DrawSpectatorCard(isFlipped bool) string {
<span {{ .Black.UserStyle | attr }}>@{{ .Black.Username }}</span> (black)
</div>
<div style="width: 360px; height: 360px; background-image: url(data:image/png;base64,{{ .ImgB64 }})"></div>
+ <div style="width: 100%; display: flex; margin: 5px 0;">
+ <div>
+ <a href="?{{ if not .IsFlipped }}r=1{{ end }}" style="color: #ccc;">Flip board</a>
+ </div>
+ </div>
<div style="color: #eee;">Outcome: {{ .Outcome }}</div>
{{ if .GameOver }}
<div><textarea>{{ .PGN }}</textarea></div>
@@ -377,12 +382,13 @@ func (g *ChessGame) DrawSpectatorCard(isFlipped bool) string {
`
data := map[string]any{
- "White": g.Player1,
- "Black": g.Player2,
- "ImgB64": imgB64,
- "Outcome": g.Game.Outcome().String(),
- "GameOver": g.Game.Outcome() != chess.NoOutcome,
- "PGN": g.Game.String(),
+ "White": g.Player1,
+ "Black": g.Player2,
+ "ImgB64": imgB64,
+ "Outcome": g.Game.Outcome().String(),
+ "GameOver": g.Game.Outcome() != chess.NoOutcome,
+ "PGN": g.Game.String(),
+ "IsFlipped": isFlipped,
}
fns := template.FuncMap{