diff options
-rw-r--r-- | static/style.css | 3 | ||||
-rw-r--r-- | timer.db | bin | 28672 -> 28672 bytes | |||
-rw-r--r-- | timer.go | 17 | ||||
-rw-r--r-- | view/timer.templ | 2 |
4 files changed, 14 insertions, 8 deletions
diff --git a/static/style.css b/static/style.css index f153f6e..8ef32c6 100644 --- a/static/style.css +++ b/static/style.css @@ -1,8 +1,5 @@ body {
font-size: 16px;
-}
-
-* {
font-family: sans-serif;
}
@@ -438,7 +438,16 @@ func (server *MyServer) handleDeleteTimer(w http.ResponseWriter, r *http.Request } } -func (server *MyServer) handlePutTimer(w http.ResponseWriter, r *http.Request) { +func parseNumber(s string) (int64, error) { + s = strings.TrimSpace(s) + if len(s) == 0 { + s = "0" + } + + return strconv.ParseInt(s, 10, 64) +} + +func (server *MyServer) handleCreateTimer(w http.ResponseWriter, r *http.Request) { timerName := strings.TrimSpace(r.FormValue("timerName")) user := server.findCurrentUser(w, r) @@ -448,14 +457,14 @@ func (server *MyServer) handlePutTimer(w http.ResponseWriter, r *http.Request) { return } - days, err := strconv.ParseInt(strings.TrimSpace(r.FormValue("days")), 10, 32) + days, err := parseNumber(r.FormValue("days")) if err != nil { w.WriteHeader(http.StatusBadRequest) view.TimerCreateForm(timerName, "Error parsing days").Render(context.Background(), w) return } - hours, err := strconv.ParseInt(strings.TrimSpace(r.FormValue("hours")), 10, 32) + hours, err := parseNumber(r.FormValue("hours")) if err != nil { w.WriteHeader(http.StatusBadRequest) view.TimerCreateForm(timerName, "Error parsing hours").Render(context.Background(), w) @@ -563,7 +572,7 @@ func main() { http.HandleFunc("DELETE /timer/{timerId}", myServer.handleDeleteTimer) http.HandleFunc("POST /timer/{timerId}/resetToken", myServer.handleResetTimerToken) http.HandleFunc("GET /timer/{timerId}/token", myServer.handleGetTimerToken) - http.HandleFunc("PUT /timer", myServer.handlePutTimer) + http.HandleFunc("PUT /timer", myServer.handleCreateTimer) http.HandleFunc("GET /", myServer.handleMain) log.Println("Started!") diff --git a/view/timer.templ b/view/timer.templ index 45194c5..09b1345 100644 --- a/view/timer.templ +++ b/view/timer.templ @@ -38,7 +38,6 @@ templ timeButton(id model.UUID, value int, unit string) { templ TimerInfo(timer model.Timer) {
<h1>Timer "{ timer.Name }"</h1>
- <p><a href="/">Back to list</a></p>
<p>Start time: <local-date>{ timer.StartTime.AsUTCString() }</local-date></p>
<p>End time: <local-date>{ timer.EndTime.AsUTCString() }</local-date></p>
<p>
@@ -57,6 +56,7 @@ templ TimerInfo(timer model.Timer) { }
templ TimerView(timer model.Timer) {
+ <p><a href="/">Back to list</a></p>
<div class="timer-info">
@TimerInfo(timer)
</div>
|