Last active
January 3, 2016 16:19
-
-
Save sherpc/8488474 to your computer and use it in GitHub Desktop.
clj->js problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<META http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<title>Welcome to sweethome</title> | |
</head> | |
<body> | |
<!-- navbar --> | |
<div class="navbar navbar-inverse navbar-fixed-top"> | |
<div class="container"> | |
<div class="navbar-header"> | |
<a class="navbar-brand" href="{{servlet-context}}/">sweethome</a> | |
</div> | |
<div class="navbar-collapse collapse "> | |
<ul class="nav navbar-nav"> | |
<li class="{{home-selected}}"><a href="{{servlet-context}}/">Home</a></li> | |
<li class="{{about-selected}}"><a href="{{servlet-context}}/about">About</a></li> | |
</ul> | |
</div> | |
</div> | |
</div> | |
<div class="container"> | |
{% block content %} | |
{% endblock %} | |
</div> | |
<!-- scripts and styles --> | |
{% style "/css/bootstrap-theme.min.css" %} | |
{% style "/css/bootstrap.min.css" %} | |
{% style "/css/screen.css" %} | |
{% script "/js/moment-with-langs.min.js" %} | |
<script src="//code.jquery.com/jquery-2.0.3.min.js" type="text/javascript"></script> | |
<!-- My ClojureScript compiled file --!> | |
<script type="text/javascript" src="{{servlet-context}}/js/site.js"></script> | |
{% script "/js/bootstrap.min.js" %} | |
{% script "/js/flot/jquery.flot.min.js" %} | |
{% script "/js/flot/jquery.flot.time.min.js" %} | |
<script type="text/javascript"> | |
var context = "{{servlet-context}}"; | |
var plotOptions = { | |
series: { | |
bars: { | |
show: true, | |
barWidth: 14*24*60*60*300, | |
fill: true, | |
lineWidth: 1 | |
} | |
}, | |
grid: { | |
hoverable: true, | |
clickable: true, | |
tickColor: "#f0f0f0", | |
borderWidth: 1, | |
color: '#f0f0f0' | |
}, | |
colors: ["#65bd77", "red"], | |
xaxis: { | |
mode: "time", | |
tickSize: [7, "day"] | |
}, | |
yaxis: { | |
ticks: 10 | |
}, | |
}; | |
$(function() { | |
sweethome.main.render_plot(); | |
}); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns sweethome.main | |
(:use [jayq.core :only [$]]) | |
(:require [ajax.core :refer [GET POST]] | |
[domina :refer [value by-id destroy-children! append!]] | |
[domina.events :refer [listen!]] | |
[dommy.template :as template])) | |
(defn fake-date [offset] | |
(. (. (js/moment ) subtract "days" offset) startOf "day")) | |
(defn ^:export render-plot [] | |
(let [d1 (range 0 10) | |
;;data [[(fake-date 14) 1] [(fake-date 7) 4] [(fake-date 0) 2]] | |
data (map (fn [x] [(fake-date (* x 7)) x]) d1) | |
jsdata (clj->js [data])] | |
(. js/moment lang "ru") | |
(js/jQuery.plot "#placeholder" jsdata js/plotOptions))) | |
;;(fake-date 2) | |
;;(render-plot) | |
(defn ^:export test [] (clj->js "asd")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defproject | |
sweethome | |
"0.1.0-SNAPSHOT" | |
:repl-options | |
{:init-ns sweethome.repl} | |
:dependencies | |
[[com.h2database/h2 "1.3.174"] | |
[ring-server "0.3.1"] | |
[domina "1.0.2"] | |
[markdown-clj "0.9.40"] | |
[environ "0.4.0"] | |
[com.taoensso/timbre "2.7.1"] | |
[prismatic/dommy "0.1.2"] | |
[korma "0.3.0-RC6"] | |
[org.clojure/clojurescript "0.0-2127"] | |
[com.taoensso/tower "2.0.1"] | |
[org.clojure/clojure "1.5.1"] | |
[cljs-ajax "0.2.2"] | |
[log4j | |
"1.2.17" | |
:exclusions | |
[javax.mail/mail | |
javax.jms/jms | |
com.sun.jdmk/jmxtools | |
com.sun.jmx/jmxri]] | |
[compojure "1.1.6"] | |
[selmer "0.5.8"] | |
[lib-noir "0.7.9"] | |
[com.postspectacular/rotor "0.1.0"] | |
[jayq "2.5.0"]] | |
:cljsbuild | |
{:builds | |
[{:source-paths ["src-cljs"], | |
:compiler | |
{:pretty-print true, | |
:output-to "resources/public/js/site.js", | |
:optimizations :whitespace}}]} | |
:ring | |
{:handler sweethome.handler/app, | |
:init sweethome.handler/init, | |
:destroy sweethome.handler/destroy} | |
:profiles | |
{:uberjar {:aot :all}, | |
:production | |
{:ring | |
{:open-browser? false, :stacktraces? false, :auto-reload? false}}, | |
:dev | |
{:dependencies [[ring-mock "0.1.5"] [ring/ring-devel "1.2.1"]], | |
:env {:selmer-dev true}}} | |
:url | |
"http://example.com/FIXME" | |
:plugins | |
[[lein-ring "0.8.10"] | |
[lein-environ "0.4.0"] | |
[lein-cljsbuild "0.3.3"]] | |
:description | |
"FIXME: write description" | |
:min-lein-version "2.0.0") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment