aboutsummaryrefslogtreecommitdiff
path: root/src/index.cljs.hl
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.cljs.hl')
-rw-r--r--src/index.cljs.hl45
1 files changed, 42 insertions, 3 deletions
diff --git a/src/index.cljs.hl b/src/index.cljs.hl
index 8ecbc8c..82980cc 100644
--- a/src/index.cljs.hl
+++ b/src/index.cljs.hl
@@ -33,6 +33,11 @@
id])
scoreboard))))
+(defc token nil)
+(defc= logged-in? rpc/token-ok)
+(defc= error rpc/error)
+(defc= error-message (when error (.-message error)))
+
(rpc/init)
(html
@@ -41,13 +46,47 @@
(title "Potluck CTF"))
(body
(h1 "Potluck CTF")
- (text "Login/Register?")
+ (div
+ :id "error"
+ :click #(reset! rpc/error nil)
+ :toggle (cell= (not (nil? rpc/error)))
+ (text "Error: ~{error-message}"))
+ (let [token-input (input :name "token")]
+ (form
+ :toggle (cell= (not logged-in?))
+ :submit #(do (reset! token (.-value token-input))
+ (rpc/check-token @token)
+ (set! (.-value token-input) nil))
+ (text "Registration Token:")
+ token-input
+ (input :type "submit")))
+ (let [name-input (input :name "name")]
+ (form
+ :toggle logged-in?
+ :submit #(do (rpc/set-name! @token (.-value name-input))
+ (set! (.-value name-input) nil))
+ (text "Change Name:")
+ name-input
+ (input :type "submit")))
+ (let [flag-input (input :name "flag")]
+ (form
+ :toggle logged-in?
+ :submit #(do (rpc/submit-flag! @token (.-value flag-input))
+ (set! (.-value flag-input) nil))
+ (text "Flag:")
+ flag-input
+ (input :type "submit")))
+ (form
+ :toggle logged-in?
+ :submit #(do (reset! token nil)
+ (reset! rpc/token-ok false))
+ (input :type "submit" :value "Logout"))
(h2 "Scoreboard")
(table
(thead
(tr
- (th)
- (th)
+ (th :colspan 2
+ :style "border:none")
(loop-tpl :bindings [probs (cell= (partition-by first problems))]
(th :text (cell= (:name (get scoreboard
(first (first probs)))))