adding clojurescript to replace hand written javascript
I hate javascript...
This commit is contained in:
parent
1f46c2daee
commit
cb9f3ca324
11 changed files with 3341 additions and 6 deletions
19
src/forms.cljs
Normal file
19
src/forms.cljs
Normal file
|
@ -0,0 +1,19 @@
|
|||
(ns forms
|
||||
(:require [clj-http.client :as client]))
|
||||
(def log (.-log js/console))
|
||||
|
||||
(defn calc-age [dob]
|
||||
(let [diff-ms (- js/Date.now dob.getTime)
|
||||
age-dt (js/Date. diff-ms)]
|
||||
(js/Math.abs (- age-dt.getUTCFullyYear 1970))))
|
||||
|
||||
(defn submit-form [e]
|
||||
;; (e.preventDefault)
|
||||
(let [form (js/document.getElementById "form")
|
||||
data (js/FormData. form)
|
||||
birthdate (js/Date. (get data "birthdate"))
|
||||
age (calc-age birthdate)]
|
||||
(data.append "age" age)
|
||||
(log data)))
|
||||
|
||||
(js/document.addEventListener "DOMContentLoaded" submit-form)
|
3
src/health-form.cljs
Normal file
3
src/health-form.cljs
Normal file
|
@ -0,0 +1,3 @@
|
|||
(ns health-form)
|
||||
(+ 1 9)
|
||||
(println "hello-world")
|
Loading…
Add table
Add a link
Reference in a new issue