dkforest

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

commit 88e46329a56d024bb5edfb30c962b10adcdf6be0
parent 5e61521c6ef4598be2e2495a4177875e4fdbab0f
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Thu, 15 Jun 2023 00:28:50 -0700

cleanup

Diffstat:
Mpkg/web/handlers/chess.go | 23+++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/pkg/web/handlers/chess.go b/pkg/web/handlers/chess.go @@ -658,12 +658,7 @@ Loop: } var styles StylesBuilder - // Reset kings background to transparent - styles.Appendf(`#%s, #%s { background-color: transparent !important; }`, interceptors.WhiteKingID, interceptors.BlackKingID) - // Render "checks" red background - if checkIDStr != "" { - styles.Appendf(`#%s { background-color: %s !important; }`, checkIDStr, interceptors.CheckColor) - } + renderChecks(&styles, checkIDStr) for i := 0; i < 64; i++ { styles.Appendf(`#piece_%s { display: none !important; }`, chess.Square(i).String()) @@ -779,12 +774,7 @@ Loop: styles.Appendf(`.square_%d, .square_%d { background-color: %s !important; }`, int(payload.Move.S1()), int(payload.Move.S2()), interceptors.LastMoveColor) - // Reset kings background to transparent - styles.Appendf(`#%s, #%s { background-color: transparent !important; }`, interceptors.WhiteKingID, interceptors.BlackKingID) - // Render "checks" red background - if payload.CheckIDStr != "" { - styles.Appendf(`#%s { background-color: %s !important; }`, payload.CheckIDStr, interceptors.CheckColor) - } + renderChecks(&styles, payload.CheckIDStr) send(styles.Build()) @@ -792,3 +782,12 @@ Loop: } return nil } + +func renderChecks(styles *StylesBuilder, checkID string) { + // Reset kings background to transparent + styles.Appendf(`#%s, #%s { background-color: transparent !important; }`, interceptors.WhiteKingID, interceptors.BlackKingID) + // Render "checks" red background + if checkID != "" { + styles.Appendf(`#%s { background-color: %s !important; }`, checkID, interceptors.CheckColor) + } +}