Ver Código Fonte

Simple demo of using friendly-check from clojurescript.

Lucas Stadler 12 anos atrás
pai
commit
a437349cf0

+ 13 - 0
clj/clarity/cljs/clarity/client.cljs

@ -0,0 +1,13 @@
1
(ns clarity.client
2
  (:use [cljs.reader :only (read-string)])
3
4
  (:require [clarity.types :as t]))
5
6
(def query-field (js/document.querySelector "#query"))
7
(def query-result (js/document.querySelector "#query-type-check"))
8
9
(.addEventListener query-field "input"
10
  (fn [e]
11
    (let [content (.-value query-field)
12
          check   (t/friendly-check (read-string content) t/datomic-attr-type)]
13
      (set! (.-textContent query-result) check))))

+ 6 - 0
clj/clarity/map-sample.html

@ -90,5 +90,11 @@
90 90
		</span>
91 91
		}
92 92
	</form>
93
94
	<div class="field">
95
		<textarea id="query"></textarea>
96
		<span id="query-type-check"></span>
97
	</div>
98
	<script src="target/cljsbuild-main.js"></script>
93 99
</body>
94 100
</html>

+ 7 - 2
clj/clarity/project.clj

@ -1,6 +1,7 @@
1 1
(defproject clarity "0.0-SNAPSHOT"
2 2
  :dependencies [[org.clojure/clojure "1.5.1"]
3 3
                 [org.clojure/core.typed "0.2.19"]
4
                 [org.clojure/clojurescript "0.0-2080"]
4 5
5 6
                 [com.datomic/datomic-free "0.9.4331"]
6 7
@ -9,5 +10,9 @@
9 10
10 11
                 [hiccup "1.0.4"]]
11 12
  :source-paths ["."]
12
  :plugins [[lein-ring "0.8.8"]]
13
  :ring {:handler clarity.server/app})
13
  :plugins [[lein-ring "0.8.8"]
14
            [lein-cljsbuild "1.0.1-SNAPSHOT"]]
15
  :ring {:handler clarity.server/app}
16
  :cljsbuild {:crossovers [clarity.types]
17
              :crossover-path "target/crossover"
18
              :builds [{:source-paths ["cljs"]}]})