   (.getElementById js/document (name id)))
 
 (def chess (js/Chess.))
+(def loaded-game (js/Chess.))
+(def current-ply 0)
+
 (def chessground (js/Chessground. (by-id "chessground-container")))
 
 (def SQUARES (.-SQUARES chess))


(defn load-pgn [pgn]
  (println "load-pgn: " pgn)
  (.reset chess)
  (.load_pgn chess pgn)
  (println "FEN: " (.fen chess))
  (.set chessground #js {
                         :viewOnly true
                         :autoCastle true
                         :turnColor "white"
                         :fen (.fen chess)
                         :animation #js { :duration 500 }
                         :drawable #js { :enabled true }
                         }))


(defn home-page []
  [:div
   [:div
    [:input {:type "button" :value "back"}]
    [:input {:type "button" :value "next"
             :on-click #(let [move (js->clj (get (.history loaded-game #js {:verbose true}) current-ply))]
                          (println "From: " (move "from") " to:" (move "to"))
                          (.move chessground (move "from") (move "to"))
                          (set! current-ply (inc current-ply)))}]]
   [shared-state]
   [reset-button]])

