     (reset! socket websocket)))
 
 (defn sonclick [event]
-  (let [input (.getElementById js/document "input")
+  (let [input (element "input")
         text  (.-value input)]
     (.send @socket text)
     (output "sent" (str ">>> " text))))

(ns chatapp.core)

(defn output [style text]
  (let [messages         (.getElementById js/document "messages")
        current-messages (.-innerHTML messages)
        current-message  (str "<br/><span class='" style "'>" text "</span>")]
    (set! (.-innerHTML messages) (str current-messages current-message))))

  (.close @socket 1000 "Close button clicked"))

(defn onload []
  (let [openBtn  (element "open")
        sendBtn  (element "send")
        closeBtn (element "close")]
    (set! (.-onclick openBtn) oonclick)
    (set! (.-onclick sendBtn) sonclick)
    (set! (.-onclick closeBtn) conclick)))
