Skip to content

Instantly share code, notes, and snippets.

@Dirklectisch
Forked from skuro/berlin-clock.cljs
Last active July 20, 2016 19:07
Show Gist options
  • Save Dirklectisch/cd6aa61c1db1ac87734ef4abb7509d56 to your computer and use it in GitHub Desktop.
Save Dirklectisch/cd6aa61c1db1ac87734ef4abb7509d56 to your computer and use it in GitHub Desktop.
Berlin Clock kata as implemented at the Amsterdam Clojurians cljs dojo, meetup #80
# Amsterdam Clojurians meetup #80
# A ClojureScript dojo: the Berlin Clock!
#
# Fork this gist and put your solution in
(ns berlinclock.core
(:require [goog.dom :as gdom]
[dommy.core :as dommy :refer-macros [sel sel1]]))
(defn set-color [element colorClass]
(-> element
(dommy/remove-class! :red)
(dommy/remove-class! :black)
(dommy/add-class! colorClass)))
(defn render-oddeven [date]
(let [element (sel1 :#oddeven)]
(if (even? (.getSeconds date))
(set-color element :red)
(set-color element :black))))
; (defn render-4hours [date]
; (let [element1 (sel1 :#4hours1)
; element2 (sel1 :#4hours2)]
; (if (even? (mod (.getHours date)))
; (set-color element :red)
; (set-color element :black))))
(defn render []
(let [date (js/Date.)]
(do
(render-oddeven date))))
(js/setInterval #((render)) 1000)
(enable-console-print!)
; Todo all things except odd and even!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment