   ; (println "notify")
   (model/text-justification (get-text) (.-checked (get-checkbox-el)) (.-value (get-slider-el))))
 
-(comment
+
 ;;;;
 ;;;; listeners
 ;;;;
 
 (defn reload-element
-  "allows for listeners removal"
-  [el]
-  (.replaceChild (.-parentNode el) (.cloneNode el true) el))
-  ; (if el 
-    ; (.replaceChild (.-parentNode el) (.cloneNode el true) el))
-    ; ())
-  
-
-(reload-element (get-text-el))
-(reload-element (get-slider-el))
-(reload-element (get-checkbox-el))
+  "make element reloadable"
+  [el listener-bind]
+  (let [new-el (.cloneNode el true)]
+    (.replaceChild (.-parentNode el) new-el el)
+    (listener-bind new-el) ))
 
 (defn char-keypress? [e]
   ; (.log js/console e)

;;;; TODO mark right margin
;;;; TODO line length should be part of state too

(defonce space-char (gstring/unescapeEntities "&nbsp;")) ;; \u00A0 ?

(defn get-slider-el   [] (dom/getElement "page-width"))
(defn get-checkbox-el [] (dom/getElement "preserve-paragraphs"))
(defn get-text-el     [] (dom/getElement "text"))

(defn get-text "get text to justify as string" []
  (.-value (get-text-el)))

                  (= word-id (dec word-count)) (- max-width (count res) (count word) (count (last words)))
                  (zero? (mod word-id extra-space-every-X-words)) (inc spaces-per-break-i) ; add one more space the usual
                  :else spaces-per-break-i)
              spaces (apply str (repeat space-count SPACE-CHAR))]
             ; (println word "(" (= word-id (dec word-count)) "):" max-width "-" (count res) "-" (count word))
            [(inc word-id) (str res word spaces)]))
        [1 ""]
