   "Change the color when cell is clicked"
   (case (.-which evt)
     1 (do (dommy/toggle-class! node "cell-clicked")
-          (dommy/remove-class! node "cell-rightclicked"))
+          (dommy/remove-class! node "cell-rightclicked")
+          (swap! state assoc :clicking :left))
     3 (do (dommy/toggle-class! node "cell-rightclicked")
-          (dommy/remove-class! node "cell-clicked"))
+          (dommy/remove-class! node "cell-clicked")
+          (swap! state assoc :clicking :right))
     nil))
 
 (defn num-click [evt node]

;  [:tr [:td#.num 1] [:td#.num 2] [:td#.cell.c0.r1] [:td#.cell.c1.r1] [:td#.cell.c2.r1] [:td#.cell.c3.r1]]
;  [:tr [:td]        [:td#.num 2] [:td#.cell.c0.r2] [:td#.cell.c1.r2] [:td#.cell.c2.r2] [:td#.cell.c3.r2]]
;  [:tr [:td]        [:td#.num 4] [:td#.cell.c0.r3] [:td#.cell.c1.r3] [:td#.cell.c2.r3] [:td#.cell.c3.r3]]])

(def data {:left [[3 1] [3] [2] [1 1] [1 1]]
           :top [[1 1] [1 3] [2] [1 2] [2]]})

        cols-wrong (get wrong :cols-wrong)]
    (js/alert (str "rows" rows-wrong " cols" cols-wrong))))

(defn clear-puzzle []
  (doseq [class ["num-clicked" "cell-clicked" "cell-rightclicked"]
          el (sel (str "." class))]
    (dommy/remove-class! el class)))

(defn add-handlers []
  (let [cells (sel ".cell")
        nums (sel ".num")]
      (doseq [cell cells]
        (set! (.-onmousedown cell) #(do (cell-click % cell) false))
        (set! (.-oncontextmenu cell) (fn [evt] false))
        (set! (.-onmousemove cell) (fn [evt]
                                     (let [t (.-currentTarget evt)
                                           s (:clicking @state)]
                                       (if (and (= s :left) (not (dommy/has-class? t "cell-clicked")))
                                         ((.-onmousedown cell) evt)
                                         (if (and (= s :right) (not (dommy/has-class? t "cell-rightclicked")))
                                           ((.-oncontextmenu cell) evt)
                                           false))))))
      (doseq [num nums]
        (set! (.-onmousedown num) #(num-click % num))
        (set! (.-oncontextmenu num) (fn [evt] false)))
      (dommy/listen! (sel1 :#button-done) :click done-handler))
  (dommy/listen! (sel1 :#button-clear) :click clear-puzzle))

(defn show [nono]
  (do
    (dommy/replace! (sel1 :#puzzle-table) (create-template nono))
