commit 968bfd689ed580c498918cf9d583fcd2ae7576cf
parent 88e46329a56d024bb5edfb30c962b10adcdf6be0
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Thu, 15 Jun 2023 00:31:12 -0700
cleanup
Diffstat:
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/pkg/web/handlers/chess.go b/pkg/web/handlers/chess.go
@@ -664,10 +664,8 @@ Loop:
styles.Appendf(`#piece_%s { display: none !important; }`, chess.Square(i).String())
}
- // Render last move
- styles.Appendf(`.square { background-color: transparent !important; }`)
- styles.Appendf(`.square_%d, .square_%d { background-color: %s !important; }`,
- int(lastMove.S1()), int(lastMove.S2()), interceptors.LastMoveColor)
+ renderLastMove(&styles, *lastMove)
+
// Render best move
if bestMove != nil {
styles.Appendf(`.square_%d, .square_%d { background-color: rgba(0, 0, 255, 0.2) !important; }`,
@@ -769,10 +767,7 @@ Loop:
styles.Appendf(`#black-advantage:before { content: "%s" !important; }`, blackAdv)
styles.Appendf(`#black-advantage .score:after { content: "%s" !important; }`, blackScore)
- // Render last move
- styles.Appendf(`.square { background-color: transparent !important; }`)
- styles.Appendf(`.square_%d, .square_%d { background-color: %s !important; }`,
- int(payload.Move.S1()), int(payload.Move.S2()), interceptors.LastMoveColor)
+ renderLastMove(&styles, payload.Move)
renderChecks(&styles, payload.CheckIDStr)
@@ -783,6 +778,12 @@ Loop:
return nil
}
+func renderLastMove(styles *StylesBuilder, lastMove chess.Move) {
+ styles.Appendf(`.square { background-color: transparent !important; }`)
+ styles.Appendf(`.square_%d, .square_%d { background-color: %s !important; }`,
+ int(lastMove.S1()), int(lastMove.S2()), interceptors.LastMoveColor)
+}
+
func renderChecks(styles *StylesBuilder, checkID string) {
// Reset kings background to transparent
styles.Appendf(`#%s, #%s { background-color: transparent !important; }`, interceptors.WhiteKingID, interceptors.BlackKingID)