dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 53008220edde72cf5480a1800bb983e51992e57c
parent f9468b1dc9c5201eec7839c25b212914ac2a9624
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Mon, 12 Jun 2023 15:56:41 -0700

no more flicker when game ends

Diffstat:
Mpkg/web/handlers/chess.go | 6++++--
Mpkg/web/handlers/interceptors/chess.go | 5+++--
2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/pkg/web/handlers/chess.go b/pkg/web/handlers/chess.go @@ -183,7 +183,7 @@ func ChessGameHandler(c echo.Context) error { user2, _ := db.GetUserByID(30814) interceptors.ChessInstance.NewGame(key, user1, user2) g = interceptors.ChessInstance.GetGame(key) - g.MakeMoves(enPassantGame) + g.MakeMoves(foolMateGame) } else { return c.Redirect(http.StatusFound, "/") } @@ -306,7 +306,9 @@ Loop: } if game.Outcome() != chess.NoOutcome { - send(`<meta http-equiv="refresh" content="0" />`) + send(`<style>#outcome:after { content: "` + game.Outcome().String() + `" }</style>`) + send(`<style>.gameover { display: none !important; }</style>`) + send(`<textarea readonly style="position: absolute; width: 200px; left: calc(50% - 100px); bottom: 20px">` + game.String() + `</textarea>`) break } diff --git a/pkg/web/handlers/interceptors/chess.go b/pkg/web/handlers/interceptors/chess.go @@ -320,6 +320,7 @@ func (g *ChessGame) drawPlayerCard(key string, isBlack, isSpectator, isYourTurn, #white-advantage .score:after { content: "{{ .WhiteScore }}"; } #black-advantage:before { content: "{{ .BlackAdvantage }}"; } #black-advantage .score:after { content: "{{ .BlackScore }}"; } +#outcome:after { content: "{{ .Outcome }}"; } .score { font-size: 11px; } </style> <table style="width: 100%; height: 100%;"> @@ -345,7 +346,7 @@ func (g *ChessGame) drawPlayerCard(key string, isBlack, isSpectator, isYourTurn, <tr> <td> {{ if and (not .IsSpectator) (not .GameOver) }} - <form method="post" style="display: inline-block;"> + <form method="post" style="display: inline-block;" class="gameover"> <input type="hidden" name="message" value="resign" /> <button type="submit" style="background-color: #aaa; margin: 5px 0;">Resign</button> </form> @@ -383,7 +384,7 @@ func (g *ChessGame) drawPlayerCard(key string, isBlack, isSpectator, isYourTurn, {{ if .IsSpectator }} <tr><td style="padding: 10px 0;" colspan="2"><a href="?{{ if not .IsFlipped }}r=1{{ end }}" style="color: #eee;">Flip board</a></td></tr> {{ end }} - <tr style="height: 100%;"><td colspan="2"><div style="color: #eee;">Outcome: {{ .Outcome }}</div></td></tr> + <tr style="height: 100%;"><td colspan="2"><div style="color: #eee;">Outcome: <span id="outcome"></span></div></td></tr> {{ if .GameOver }}<tr><td colspan="2"><div><textarea>{{ .PGN }}</textarea></div></td></tr>{{ end }} </table>