dkforest

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

commit c1eeca3a287d4e0da52df64a76b97bbf0317330d
parent d7e3a984d806e449e7a322b23d114b17c9d519ad
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Sun, 11 Jun 2023 17:48:42 -0700

cleanup

Diffstat:
Mpkg/web/handlers/interceptors/chess.go | 44++++++++++++++++++--------------------------
1 file changed, 18 insertions(+), 26 deletions(-)

diff --git a/pkg/web/handlers/interceptors/chess.go b/pkg/web/handlers/interceptors/chess.go @@ -135,10 +135,6 @@ func (g *ChessGame) renderBoardHTML1(position *chess.Position, isFlipped bool, i height: 12.5%; background-size: 100%; } -.idk { - width: 100%; - height: 100%; -} label { position: absolute; width: 12.5%; @@ -188,36 +184,32 @@ input[type=checkbox]:checked + label { } else { id = i - mm } + sq := chess.Square(id) + idStr := strconv.Itoa(id) + p := boardMap[sq] + pidStr := g.PiecesCache[sq] + isLastMove := last != nil && (last.S1() == sq || last.S2() == sq) + fname := p.Color().String() + pieceTypeMap[p.Type()] + inCheck := last != nil && p.Color() == g.Game.Position().Turn() && p.Type() == chess.King && last.HasTag(chess.Check) + lastMoveColor := utils.Ternary(isLastMove, LastMoveColor, "transparent") + checkColor := utils.Ternary(inCheck, CheckColor, "transparent") + x := i % 8 + y := i / 8 + if i%8 == 0 { if i != 0 { out += "</tr>" } out += "<tr>" } - sq := chess.Square(id) - idStr := strconv.Itoa(id) - out += `<td class="square square_` + idStr + `"` - if last != nil && (last.S1() == sq || last.S2() == sq) { - out += ` style="background-color: ` + LastMoveColor + `;"` - } - out += ">" - sqPiece := boardMap[sq] - p := sqPiece + out += fmt.Sprintf(`<td class="square square_%s" style="background-color: %s;">`, idStr, lastMoveColor) if p != chess.NoPiece { - x := i % 8 - y := i / 8 - pidStr := g.PiecesCache[sq] - out += `<div id="` + pidStr + `" class="img" style="left: calc(` + strconv.Itoa(x) + `*12.5%); top: calc(` + strconv.Itoa(y) + `*12.5%); background-image: url(/public/img/chess/` + p.Color().String() + pieceTypeMap[p.Type()] + `.png);` - if last != nil && p.Color() == g.Game.Position().Turn() && p.Type() == chess.King && last.HasTag(chess.Check) { - out += ` background-color: ` + CheckColor + `;` - } - out += `"></div>` - } - out += `<div class="idk">` - if !spectator { - out += `<input name="sq_` + idStr + `" id="sq_` + idStr + `" type="checkbox" value="1" /><label for="sq_` + idStr + `"></label>` + out += fmt.Sprintf(`<div id="%s" class="img" style=" + left: calc(%d*12.5%%); top: calc(%d*12.5%%); + background-image: url(/public/img/chess/%s.png); + background-color: %s;"></div>`, + pidStr, x, y, fname, checkColor) } - out += "</div>" out += "</td>" } out += "</tr></table>"