Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions static/js/match_play.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ const setTestMatchName = function () {

// Returns the integer team number entered into the team number input box for the given station, or 0 if it is empty.
const getTeamNumber = function (station) {
const teamId = $(`#status${station} .team-number`).val().trim();
return teamId ? parseInt(teamId) : 0;
const raw = $(`#status${station} .team-number`).val().trim();
if (!raw) return 0;
const num = parseInt(raw);
return isNaN(num) ? 0 : num;
}

// Handles a websocket message to update the team connection status.
Expand Down
8 changes: 7 additions & 1 deletion templates/match_play.html
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ <h4 class="modal-title">Confirm</h4>
</div>
</div>
</div>
<datalist id="teamList">
{{range .Teams}}
<option value="{{.Id}}">{{.Id}} - {{.Nickname}}</option>
{{end}}
</datalist>
{{end}}
{{define "script"}}
<script src="/static/js/match_timing.js"></script>
Expand All @@ -251,7 +256,8 @@ <h4 class="modal-title">Confirm</h4>
<div class="row mb-2" id="status{{.color}}{{.position}}">
<div class="col-lg-1">{{.position}}</div>
<div class="col-lg-3">
<input type="number" class="team-number form-control"
<input type="text" class="team-number form-control" list="teamList"
placeholder="Team #" autocomplete="off"
onchange="$('#substituteTeams').prop('disabled', false);">
</div>
<div class="col-lg-2 col-no-padding">
Expand Down
7 changes: 7 additions & 0 deletions web/match_play.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,21 @@ func (web *Web) matchPlayHandler(w http.ResponseWriter, r *http.Request) {
handleWebErr(w, err)
return
}
teams, err := web.arena.Database.GetAllTeams()
if err != nil {
handleWebErr(w, err)
return
}
data := struct {
*model.EventSettings
PlcIsEnabled bool
PlcArmorBlockStatuses map[string]bool
Teams []model.Team
}{
web.arena.EventSettings,
web.arena.Plc.IsEnabled(),
web.arena.Plc.GetArmorBlockStatuses(),
teams,
}
err = template.ExecuteTemplate(w, "base", data)
if err != nil {
Expand Down