diff --git a/handlers.go b/handlers.go index 04e2beb..c6bf42c 100644 --- a/handlers.go +++ b/handlers.go @@ -135,3 +135,10 @@ func attempt(w http.ResponseWriter, req *http.Request) { log.Fatal("cannot marshal solution", err) } } + +func reset(w http.ResponseWriter, req *http.Request) { + session, _ := store.Get(req, "Score") + session.Values["Score"] = 0 + session.Save(req, w) + http.Redirect(w, req, "/", http.StatusFound) +} diff --git a/main.go b/main.go index bfd0315..bc002c8 100644 --- a/main.go +++ b/main.go @@ -36,6 +36,10 @@ func main() { "/", static, ) + http.HandleFunc( + "/reset/", + reset, + ) if err := http.ListenAndServe(*addr, nil); err != nil { log.Fatal("ListenAndServe:", err) } diff --git a/static.go b/static.go index 7711c6c..0294c88 100644 --- a/static.go +++ b/static.go @@ -140,31 +140,48 @@ var staticIndexHtml = []byte{ 0x3d, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, // __conten 0x74, 0x22, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, // t_______ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________ - 0x3c, 0x75, 0x6c, 0x3e, 0x0a, 0x20, 0x20, 0x20, // _ul_____ + 0x3c, 0x64, 0x69, 0x76, 0x3e, 0x0a, 0x20, 0x20, // _div____ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________ - 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x6c, 0x69, // ______li - 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, // __a_href - 0x3d, 0x22, 0x2f, 0x61, 0x64, 0x64, 0x73, 0x75, // ___addsu - 0x62, 0x2f, 0x22, 0x3e, 0x61, 0x64, 0x64, 0x69, // b___addi - 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, 0x6e, 0x64, // tion_and - 0x20, 0x73, 0x75, 0x62, 0x74, 0x72, 0x61, 0x63, // _subtrac - 0x74, 0x69, 0x6f, 0x6e, 0x3c, 0x2f, 0x61, 0x3e, // tion__a_ - 0x3c, 0x2f, 0x6c, 0x69, 0x3e, 0x0a, 0x20, 0x20, // __li____ + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x75, // _______u + 0x6c, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, // l_______ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________ - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x6c, // _______l - 0x69, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, // i__a_hre - 0x66, 0x3d, 0x22, 0x2f, 0x6d, 0x75, 0x6c, 0x2f, // f___mul_ - 0x22, 0x3e, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, // __multip - 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, // lication - 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x6c, 0x69, // __a___li - 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________ - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x2f, // ________ - 0x75, 0x6c, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, // ul______ - 0x20, 0x20, 0x20, 0x20, 0x3c, 0x2f, 0x73, 0x65, // ______se - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3e, 0x0a, 0x20, // ction___ - 0x20, 0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, // _____bod - 0x79, 0x3e, 0x0a, 0x3c, 0x2f, 0x68, 0x74, 0x6d, // y____htm - 0x6c, 0x3e, 0x0a, // l____htm + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, // ________ + 0x6c, 0x69, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, // li__a_hr + 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x61, 0x64, 0x64, // ef___add + 0x73, 0x75, 0x62, 0x2f, 0x22, 0x3e, 0x61, 0x64, // sub___ad + 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, // dition_a + 0x6e, 0x64, 0x20, 0x73, 0x75, 0x62, 0x74, 0x72, // nd_subtr + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3c, 0x2f, // action__ + 0x61, 0x3e, 0x3c, 0x2f, 0x6c, 0x69, 0x3e, 0x0a, // a___li__ + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________ + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________ + 0x20, 0x20, 0x20, 0x20, 0x3c, 0x6c, 0x69, 0x3e, // _____li_ + 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, // _a_href_ + 0x22, 0x2f, 0x6d, 0x75, 0x6c, 0x2f, 0x22, 0x3e, // __mul___ + 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x69, // multipli + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3c, 0x2f, // cation__ + 0x61, 0x3e, 0x3c, 0x2f, 0x6c, 0x69, 0x3e, 0x0a, // a___li__ + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________ + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________ + 0x3c, 0x2f, 0x75, 0x6c, 0x3e, 0x0a, 0x20, 0x20, // __ul____ + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________ + 0x20, 0x20, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, // ____div_ + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________ + 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x64, 0x69, // ______di + 0x76, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, // v_______ + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________ + 0x20, 0x20, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, // ____a_hr + 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x72, 0x65, 0x73, // ef___res + 0x65, 0x74, 0x2f, 0x22, 0x3e, 0x72, 0x65, 0x73, // et___res + 0x65, 0x74, 0x20, 0x73, 0x63, 0x6f, 0x72, 0x65, // et_score + 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x0a, 0x20, 0x20, // s__a____ + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________ + 0x20, 0x20, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, // ____div_ + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________ + 0x20, 0x3c, 0x2f, 0x73, 0x65, 0x63, 0x74, 0x69, // ___secti + 0x6f, 0x6e, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, // on______ + 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x0a, // __body__ + 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x0a, // __html__ } var staticJqueryJs = []byte{ diff --git a/static/index.html b/static/index.html index e63790b..12b1500 100644 --- a/static/index.html +++ b/static/index.html @@ -7,10 +7,15 @@
- +
+ +
+
+ reset scores +