Refactor schedule JS to be less buggy (fixes #12).

This commit is contained in:
Patrick Fairbank
2017-09-02 19:18:15 -07:00
parent 4e418434da
commit 11b6b5f856
4 changed files with 29 additions and 14 deletions

View File

@@ -27,10 +27,6 @@ func (web *Web) scheduleGetHandler(w http.ResponseWriter, r *http.Request) {
}
if len(cachedScheduleBlocks) == 0 {
tomorrow := time.Now().AddDate(0, 0, 1)
location, _ := time.LoadLocation("Local")
startTime := time.Date(tomorrow.Year(), tomorrow.Month(), tomorrow.Day(), 9, 0, 0, 0, location)
cachedScheduleBlocks = append(cachedScheduleBlocks, tournament.ScheduleBlock{startTime, 10, 360})
cachedMatchType = "practice"
}
web.renderSchedule(w, r, "")

View File

@@ -20,7 +20,7 @@ func TestSetupSchedule(t *testing.T) {
// Check the default setting values.
recorder := web.getHttpResponse("/setup/schedule")
assert.Equal(t, 200, recorder.Code)
assert.Contains(t, recorder.Body.String(), "360") // The default match spacing.
assert.Contains(t, recorder.Body.String(), "addBlock();")
// Submit a schedule for generation.
postData := "numScheduleBlocks=3&startTime0=2014-01-01 09:00:00 AM&numMatches0=7&matchSpacingSec0=480&" +