 (defn ^:export run []
   (reagent/render-component [menu-component] (.-body js/document)))
 
-;; (defn handle-export []
-;;   (let [export-link (. js/document (getElementById "export-download-link"))]
-;;     (log "Exporting competition")
-;;     (.click export-link)))
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Socket handling
+
 (defn- event-handler [[id data :as ev] _]
   (log (str "Event: " id))
   (match [id data]
-    ;; TODO Match your events here <...>
-         ;; [:chsk/recv [:file/imported content]]
-         ;; (do
-         ;;   (swap! app-state #(merge % {:selected-page :classes
-         ;;                               :competition (:file/content content)}))
-         ;;   ;(swap! app-state #(hash-map :competitions (conj (:competitions %) content)))
-         ;;   (log (str @app-state))
-         ;;   )
+         ;; TODO Match your events here <...>
          [:chsk/recv [:file/imported content]]
          (do
            (swap! app-state #(merge % {:competition content}))
            (log (str @app-state)))
          ;; [:chsk/recv [:file/export content]]
          ;; (handle-export)
-    [:chsk/state [:first-open _]] (log "Channel socket successfully established!")
-    ;[:chsk/state new-state] (log (str "Chsk state change: " new-state))
-    ;[:chsk/recv payload] (log (str "Push event from server: " payload))
-    :else (log (str "Unmatched event: " ev)))
-  )
+         [:chsk/state [:first-open _]]
+         (log "Channel socket successfully established!")
+                                        ;[:chsk/state new-state] (log (str "Chsk state change: " new-state))
+                                        ;[:chsk/recv payload] (log (str "Push event from server: " payload))
+         :else (log (str "Unmatched event: " ev))))
 
 (defonce chsk-router
   (sente/start-chsk-router-loop! event-handler ch-chsk))


     :type (if comment?
              ""
              (make-dance-type-presentation (:round/dances round)))})
  )

(defn events-component []
  [:div
   [:h3 "Time Schedule Ny"]
   [:table.table
    [:thead
     [:tr

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; UI utils

;; (defn- to-number [s]
;;   {:pre [(string? s)]}
;;   (let [prepared-string (clojure.string/replace s #" " "")]
;;     (cond (re-seq #"^[-+]?\d*[\.,]\d*$" prepared-string)
;;           (js/parseDouble (clojure.string/replace prepared-string #"," "."))
;;           (re-seq #"^[-+]?\d+$" prepared-string)
;;           (js/parseInt (clojure.string/replace prepared-string #"\+" ""))
;;           :else s)))

(defn make-dance-type-presentation [dances]
  ;; Dances are presented as a list of the first letters of each dance
  (clojure.string/join (map #(first (:dance/name %)) dances)))

(def round-map
  {:none ""
