commit 044bb6f482d408bb13869e2f7363ca4aa175c23a
parent afddabe34306fa983b487b9af92993edcd73f94f
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Wed, 18 Jan 2023 21:31:45 -0800
improve chess template
Diffstat:
1 file changed, 37 insertions(+), 33 deletions(-)
diff --git a/pkg/web/handlers/api/v1/chess.go b/pkg/web/handlers/api/v1/chess.go
@@ -273,33 +273,35 @@ func (g *ChessGame) DrawPlayerCard(inChat, isBlack, isYourTurn bool) string {
imgB64 := g.renderBoardB64(isBlack)
htmlTmpl := `
-<div style="color: #eee;">
- <span {{ .White.UserStyle | attr }}>@{{ .White.Username }}</span> (white) VS
- <span {{ .Black.UserStyle | attr }}>@{{ .Black.Username }}</span> (black)
-</div>
-
-{{ if .GameOver }}
- <div style="width: 360px; height: 360px; background-image: url(data:image/png;base64,{{ .ImgB64 }})"></div>
-{{ else }}
- <form method="post">
- <input type="hidden" name="message" value="resign" />
- <button type="submit">Resign</button>
- </form>
- {{ if .IsYourTurn }}
- <form method="post"{{ if .InChat }} action="/api/v1/chat/top-bar/chess" target="iframe1"{{ end }}>
- {{ .Table }}
- <input type="hidden" name="message" value="/pm {{ .Username }} /c move" />
- <button type="submit">Move</button>
- </form>
- {{ else }}
+<div style="margin: 0 auto; width: 360px;">
+ <div style="color: #eee;">
+ <span {{ .White.UserStyle | attr }}>@{{ .White.Username }}</span> (white) VS
+ <span {{ .Black.UserStyle | attr }}>@{{ .Black.Username }}</span> (black)
+ </div>
+
+ {{ if .GameOver }}
<div style="width: 360px; height: 360px; background-image: url(data:image/png;base64,{{ .ImgB64 }})"></div>
+ {{ else }}
+ <form method="post">
+ <input type="hidden" name="message" value="resign" />
+ <button type="submit">Resign</button>
+ </form>
+ {{ if .IsYourTurn }}
+ <form method="post"{{ if .InChat }} action="/api/v1/chat/top-bar/chess" target="iframe1"{{ end }}>
+ {{ .Table }}
+ <input type="hidden" name="message" value="/pm {{ .Username }} /c move" />
+ <button type="submit">Move</button>
+ </form>
+ {{ else }}
+ <div style="width: 360px; height: 360px; background-image: url(data:image/png;base64,{{ .ImgB64 }})"></div>
+ {{ end }}
{{ end }}
-{{ end }}
-<div style="color: #eee;">Outcome: {{ .Outcome }}</div>
-
-{{ if .GameOver }}
- <div><textarea>{{ .PGN }}</textarea></div>
-{{ end }}
+ <div style="color: #eee;">Outcome: {{ .Outcome }}</div>
+
+ {{ if .GameOver }}
+ <div><textarea>{{ .PGN }}</textarea></div>
+ {{ end }}
+</div>
`
data := map[string]any{
@@ -330,15 +332,17 @@ func (g *ChessGame) DrawSpectatorCard(isFlipped bool) string {
imgB64 := g.renderBoardB64(isFlipped)
htmlTmpl := `
-<div style="color: #eee;">
- <span {{ .White.UserStyle | attr }}>@{{ .White.Username }}</span> (white) VS
- <span {{ .Black.UserStyle | attr }}>@{{ .Black.Username }}</span> (black)
+<div style="margin: 0 auto; width: 360px;">
+ <div style="color: #eee;">
+ <span {{ .White.UserStyle | attr }}>@{{ .White.Username }}</span> (white) VS
+ <span {{ .Black.UserStyle | attr }}>@{{ .Black.Username }}</span> (black)
+ </div>
+ <div style="width: 360px; height: 360px; background-image: url(data:image/png;base64,{{ .ImgB64 }})"></div>
+ <div style="color: #eee;">Outcome: {{ .Outcome }}</div>
+ {{ if .GameOver }}
+ <div><textarea>{{ .PGN }}</textarea></div>
+ {{ end }}
</div>
-<div style="width: 360px; height: 360px; background-image: url(data:image/png;base64,{{ .ImgB64 }})"></div>
-<div style="color: #eee;">Outcome: {{ .Outcome }}</div>
-{{ if .GameOver }}
- <div><textarea>{{ .PGN }}</textarea></div>
-{{ end }}
`
data := map[string]any{