Permalink
Browse files

get replace image js to work

  • Loading branch information...
1 parent 3e5b389 commit 334cce3f3c03645449d357382f44b7d93121bf87 Oskar Thoren committed Jun 12, 2012
Showing with 10 additions and 10 deletions.
  1. +9 −9 src/trapunto/cljs/client.cljs
  2. +1 −1 src/trapunto/views/welcome.clj
@@ -1,22 +1,22 @@
(ns trapunto)
+;; TODO: replace filename with saved image
+;; TODO: fix bad image reloaded (marked region?)
+
(defn ^:export timer [delay-ms]
(js/setInterval compare-code delay-ms))
(def xhr (new js/XMLHttpRequest))
-;;; Eventually replace with Data URI
(defn replace-image []
- (if (and (= (. xhr -readyState) 4)
+ (let [filename "x"]
+ ;; check if response is OK and finished loading
+ (if (and (= (. xhr -readyState) 4)
(= (. xhr -status) 200)
(do
- ;; temporary testing value
- (set! (.. js/document (getElementById "visible") -value)
- "Works!"))
-
- ;; actual image replacement code
- (comment (.. js/document (getElementById "output")
- (setAttribute "src" ("url" (js->clj (. xhr -responseText)))))))))
+ (.. js/document (getElementById "output")
+ (setAttribute "src" (str "/img/" (str filename) ".jpg"))))))))
+ ;;("url" (js->clj (. xhr -responseText)))
(defn compare-code []
(let [visible (.. js/document (getElementById "visible") -value)]
@@ -12,7 +12,7 @@
(text-area {:id "visible"} "")
(text-area {:id "invisible"} "")
(submit-button "Submit"))
- [:img {:src "/img/trapunto1.jpg" :width "80" :height "80" :float "left"}]
+ [:img {:id "output" :src "/img/trapunto1.jpg" :width "80" :height "80" :float "left"}]
[:script {:type "text/javascript"} "trapunto.timer(2000);"]))
(defpage [:post "/"] {}

0 comments on commit 334cce3

Please sign in to comment.