chess.gohtml (2286B)
1 {{ define "title" }}dkf - chess{{ end }} 2 3 {{ define "content" }} 4 <div class="container"> 5 <h3>Games</h3> 6 <p>You can create a chess game with someone by using the <code>/chess username</code> command.</p> 7 <form method="post" style="width: 700px;"> 8 <input type="hidden" name="csrf" value="{{ .CSRF }}" /> 9 <div class="input-group"> 10 <input style="width: 200px;" type="text" name="username" value="{{ .Data.Username }}" placeholder="opponent username" class="form-control form-control-sm{{ if .Data.Error }} is-invalid{{ end }}" /> 11 12 <select name="color" class="form-control form-control-sm"> 13 <option value="w"{{ if eq .Data.Color "w" }}} selected{{ end }}>White</option> 14 <option value="b"{{ if eq .Data.Color "b" }}} selected{{ end }}>Black</option> 15 <option value="r"{{ if eq .Data.Color "r" }}} selected{{ end }}>Random</option> 16 </select> 17 18 <input type="text" name="pgn" value="{{ .Data.Pgn }}" placeholder="PGN" aria-label="pgn" class="form-control form-control-sm" /> 19 20 <div class="input-group-append"> 21 <button class="btn btn-sm btn-primary">Create chess game</button> 22 </div> 23 {{ if .Data.Error }} 24 <div class="invalid-feedback">{{ .Data.Error }}</div> 25 {{ end }} 26 </div> 27 </form> 28 <div class="mt-4"> 29 <table class="table table-novpadding table-sm table-hover table-striped"> 30 <tr> 31 <th style="width: 180px;">Created at</th> 32 <th>Game</th> 33 <th>Outcome</th> 34 </tr> 35 {{ range .Data.Games }} 36 <tr> 37 <td>{{ .CreatedAt.Format "Jan 02, 2006 15:04:05" }}</td> 38 <td><a href="/chess/{{ .Key }}">{{ .Player1.Username }} VS {{ .Player2.Username }}</a></td> 39 <td>{{ .Game.Outcome }}</td> 40 </tr> 41 {{ else }} 42 <tr><td colspan="3"><em>No game to show</em></td></tr> 43 {{ end }} 44 </table> 45 </div> 46 </div> 47 {{ end }}