adding clojurescript to replace hand written javascript

I hate javascript...
This commit is contained in:
Chris Cochrun 2023-05-23 16:55:54 -05:00
parent 1f46c2daee
commit cb9f3ca324
11 changed files with 3341 additions and 6 deletions

19
src/forms.cljs Normal file
View 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
View file

@ -0,0 +1,3 @@
(ns health-form)
(+ 1 9)
(println "hello-world")