     (set-html! (by-id ":remaining") (->minutes remaining))
     (set-html! (by-id ":type") (string/capitalize (name activity)))
     (dorun (map set-html (dissoc (assoc excercise :total total) :id :activity)))))
-    
-(defn create-td [parent workout key]
-  (let [td (. js/document createElement "td")]
-    (. parent appendChild td)
-    (set-html! td (format key (get workout key)))))
-  
-(defn create-row [parent workout]
-  (let [tr (. js/document createElement "tr")]
-    (set! (. tr -id) (str "workout-"(:id workout)))
-    (. parent appendChild tr)
-   (dorun (map (partial create-td tr workout ) [:title :holds :duration :rest :repeat]))))
-
-(defn to-html [workout]
-  (let [table (by-id "total")]
-    (dorun (map (partial create-row table) workout))))
-  
+
 (defn wall-clock []
   (let [output (chan)]
     (go-loop []


(defn set-html [[keyword val]]
  (set-html! (by-id (str keyword)) (format keyword val)))
  
(defmulti play :state)

(defmethod play :almost [_]

  (do-workout))

#_(defroute  "/workout" []
    (.log js/console "starting workout")
    (start-workout))

(defn show-root []
  (let [go-chan (listen (by-id "ok") "click")]
    (swap! app-state update-in [:workout] add-id )
    (go (<! go-chan) (start-workout))))

#_(defroute "/" []
    (.log js/console "showing root")
    (show-root))


(defn main []
  (show-root)
  (swap! app-state assoc :running-workout false)
  (swap! app-state assoc :total-duration 0)
  #_(let [h (History.)]
      (goog.events/listen h EventType/NAVIGATE #(secretary/dispatch! (.-token %)))
      (doto h (.setEnabled true)
            (.setToken "/"))))

(defcomponent om-show-moon-board [data owner]
  (render [_]
          (dom/div {:class "row"}
                   (dom/div {:class "col-sm-12"}
                            (dom/img {:class "img-rounded"
                                      :src "FingerboardNumbered1.jpg"})))))

(defcomponent om-show-workout-detail [{:keys [id title holds duration rest repeat]} owner]
  (render [_]
          (dom/tr {:id (str "workout-" id)}
                  (dom/td title)
                  (dom/td (string/join ", " holds))
                  (dom/td (->minutes duration))
                  (dom/td (->minutes rest))
                  (dom/td repeat))))

(defcomponent om-show-total-workout [data owner]
  (render [_]
          (.log js/console (pr-str data))
          (dom/table {:class "table table-striped"}
                     (dom/tbody
                      (dom/tr
                       (dom/th "Description")
                       (dom/th "Holds")
                       (dom/th "Duration")
                       (dom/th "Rest")
                       (dom/th "Sets"))
                     (map ->om-show-workout-detail data)))))

(defcomponent om-show-workout [data owner]
  (render [_]
          (when-not (:running-workout data)
            (dom/div
             (->om-show-moon-board {})
             (dom/div {:class "row heading"}
                      (dom/div {:class "col-sm-12"}
                               (dom/h1 "Total workout")))
             (dom/div {:class "row"}
                      (dom/div {:class "col-sm-12"}
                               (dom/button {:class "btn block btn-block primary btn-primary"
                                            :id "ok"}
                                           "Go!")))
             (->om-show-total-workout (:workout data))))))

(om/root om-show-workout app-state
         {:target (by-id "app")})

