diff options
-rw-r--r-- | src/app/api.clj | 5 | ||||
-rw-r--r-- | src/app/rpc.cljs | 4 | ||||
-rw-r--r-- | src/app/scoreboard.cljs | 11 | ||||
-rw-r--r-- | src/index.cljs.hl | 7 |
4 files changed, 23 insertions, 4 deletions
diff --git a/src/app/api.clj b/src/app/api.clj index 432482c..d453f4b 100644 --- a/src/app/api.clj +++ b/src/app/api.clj @@ -29,3 +29,8 @@ {:rpc/pre (= token (db/get :admin))} (binding [*ns* (find-ns 'simpledb.core)] (eval (read-string expr)))) + +(defrpc get-hints [] + (if (db/get :drop-hints) + (db/get :hints) + "Hack Harder!")) diff --git a/src/app/rpc.cljs b/src/app/rpc.cljs index dab3566..2f25b35 100644 --- a/src/app/rpc.cljs +++ b/src/app/rpc.cljs @@ -11,6 +11,7 @@ (defc loading []) (defc token-ok false) (defc eval-result nil) +(defc hints "No hints") (def get-scoreboard (mkremote 'app.api/get-scoreboard scoreboard scoreboard-error loading)) @@ -27,6 +28,9 @@ (def admin-eval! (mkremote 'app.api/admin-eval! eval-result error loading)) +(def get-hints + (mkremote 'app.api/get-hints hints error loading)) + (defn init [] (get-scoreboard) (js/setInterval get-scoreboard 1000)) diff --git a/src/app/scoreboard.cljs b/src/app/scoreboard.cljs index b58e49e..794a803 100644 --- a/src/app/scoreboard.cljs +++ b/src/app/scoreboard.cljs @@ -56,9 +56,12 @@ (td :text (cell= (:name player))) (td :text score) (loop-tpl :bindings [[owner _name] problems] - (td :text (cell= - (name (get (:scores player) - _name - :unsolved)))))))))))) + (let [solved (cell= (= :solved + (get (:scores player) + _name + :unsolved)))] + (td + :text (cell= + (when solved "\u2713")))))))))))) ;; vim: set expandtab ts=2 sw=2 filetype=clojure : diff --git a/src/index.cljs.hl b/src/index.cljs.hl index 0e2d3d4..cde8941 100644 --- a/src/index.cljs.hl +++ b/src/index.cljs.hl @@ -3,6 +3,7 @@ [app.scoreboard :as s])) (defc token nil) +(defc hints-expanded false) (defc= logged-in? rpc/token-ok) (defc= error rpc/error) (defc= error-message (when error (.-message error))) @@ -50,6 +51,12 @@ :submit #(do (reset! token nil) (reset! rpc/token-ok false)) (input :type "submit" :value "Logout")) + (h2 :toggle logged-in? + :click #(do (swap! hints-expanded not) + (rpc/get-hints)) + (text "~(if hints-expanded \"\u25be\" \"\u25b8\") Hints")) + (pre :toggle hints-expanded + :text rpc/hints) (h2 "Scoreboard") (s/scoreboard :scoreboard rpc/scoreboard))) |