dkforest

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

commit a2543d249fde60517246e51ca1c80073b8f74aba
parent 8df352c17e393a7475c4885d268ba8407481139e
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Sun, 11 Jun 2023 16:20:48 -0700

cleanup

Diffstat:
Mpkg/web/handlers/handlers.go | 25+++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go @@ -5167,6 +5167,15 @@ func ChessGameHandler(c echo.Context) error { } send(fmt.Sprintf(`<div id="div_0">%s</div>`, card1)) + const ( + whiteKingID = "img_4" + blackKingID = "img_60" + whiteKingSideRookID = "img_7" + blackKingSideRookID = "img_63" + whiteQueenSideRookID = "img_0" + blackQueenSideRookID = "img_56" + ) + i := 0 Loop: for { @@ -5234,13 +5243,13 @@ Loop: } if payload.Turn == chess.White && payload.Move.HasTag(chess.KingSideCastle) { - animate(chess.H1, chess.F1, "img_7") + animate(chess.H1, chess.F1, whiteKingSideRookID) } else if payload.Turn == chess.Black && payload.Move.HasTag(chess.KingSideCastle) { - animate(chess.H8, chess.F8, "img_63") + animate(chess.H8, chess.F8, blackKingSideRookID) } else if payload.Turn == chess.White && payload.Move.HasTag(chess.QueenSideCastle) { - animate(chess.A1, chess.D1, "img_0") + animate(chess.A1, chess.D1, whiteQueenSideRookID) } else if payload.Turn == chess.Black && payload.Move.HasTag(chess.QueenSideCastle) { - animate(chess.A8, chess.D8, "img_56") + animate(chess.A8, chess.D8, blackQueenSideRookID) } // Render last move @@ -5248,13 +5257,13 @@ Loop: send(fmt.Sprintf(`<style>.square_%d, .square_%d { background-color: rgba(0, 255, 0, 0.2) !important; }</style>`, int(payload.Move.S1()), int(payload.Move.S2()))) // Reset kings background to transparent - send(`<style>#img_4 { background-color: transparent !important; }</style>`) - send(`<style>#img_60 { background-color: transparent !important; }</style>`) + send(`<style>#` + whiteKingID + ` { background-color: transparent !important; }</style>`) + send(`<style>#` + blackKingID + ` { background-color: transparent !important; }</style>`) // Render "checks" red background if payload.CheckW { - send(`<style>#img_4 { background-color: rgba(255, 0, 0, 0.4) !important; }</style>`) + send(`<style>#` + whiteKingID + ` { background-color: rgba(255, 0, 0, 0.4) !important; }</style>`) } else if payload.CheckB { - send(`<style>#img_60 { background-color: rgba(255, 0, 0, 0.4) !important; }</style>`) + send(`<style>#` + blackKingID + ` { background-color: rgba(255, 0, 0, 0.4) !important; }</style>`) } c.Response().Flush()