Skip to content

Instantly share code, notes, and snippets.

(defn handle-file-select [evt]
(.stopPropagation evt)
(.preventDefault evt)
(let [files (.-files (.-dataTransfer evt))]
(dotimes [i (.-length files)]
(let [rdr (js/FileReader.)
the-file (aget files i)]
(set! (.-onload rdr)
(fn [e]
(let [file-content (.-result (.-target e))
@quizdr
quizdr / ux.cljs
Created July 23, 2014 13:34 — forked from anonymous/ux.cljs
;;; TODO - drag-enter and -exit events : Right now, a component doesn't receive events for other components
;;; If a component responds to drag-over, it won't "revert" state until the drag ends.
;; NOTE - compiles with om 0.1.7. Needs updating to 0.2+
(ns omdnd.ux
(:require-macros
[cljs.core.async.macros :refer [go alt!]]
)
@quizdr
quizdr / Simple logging macro
Last active August 29, 2015 13:55
Simple logging macro for any form; turn all logging on or off easily.
(defmacro alog
"When the if is true, add a logging string to the form. When it's false, do nothing."
[string form]
(if true
`(do
(println ~string)
~form)
form))