Last active
July 18, 2016 17:33
-
-
Save zentrope/bf359cec33f6fcc02be4 to your computer and use it in GitHub Desktop.
HelloWorld Cordova ClojureScript
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 charset="utf-8" /> | |
<meta name="format-detection" content="telephone=no" /> | |
<meta name="msapplication-tap-highlight" content="no" /> | |
<!-- WARNING: for iOS 7, remove the width=device-width and | |
height=device-height attributes. See | |
https://issues.apache.org/jira/browse/CB-4323 --> | |
<meta name="viewport" | |
content="user-scalable=no, | |
initial-scale=1, | |
maximum-scale=1, | |
minimum-scale=1, | |
width=device-width, | |
height=device-height, | |
target-densitydpi=device-dpi" /> | |
<link rel="stylesheet" type="text/css" href="css/index.css" /> | |
<title>Zen Tropes</title> | |
<script type="text/javascript" src="cordova.js"></script> | |
<script type="text/javascript" src="js/app.js"></script> | |
</head> | |
<body> | |
</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 phone.main | |
(:require-macros | |
[cljs.core.async.macros :refer [go]]) | |
(:require | |
[cljs.core.async :refer [<! timeout]] | |
[om.core :as om :include-macros true] | |
[sablono.core :as html :refer-macros [html]])) | |
(enable-console-print!) | |
(defonce app | |
(atom {:msg "Hello" | |
:connected false})) | |
(defn browser-mode! | |
[] | |
(let [agent (.-userAgent (.-navigator js/window)) | |
browser? (= (.indexOf agent "MOBILE") -1)] | |
(go (<! (timeout 500)) | |
(.dispatchEvent js/document (js/CustomEvent. "deviceready"))))) | |
(defn- root-frame | |
[app owner opts] | |
(reify | |
om/IDidMount | |
(did-mount [_] | |
(.addEventListener js/document "deviceready" #(om/update! app :connected true)) | |
(browser-mode!)) | |
om/IRenderState | |
(render-state [_ _] | |
(html | |
[:div.app | |
[:h1 "Apache Cordova"] | |
[:div#deviceready.blink | |
(if (:connected app) | |
[:p.event.received {:style {:display "block"}} "Device is Ready"] | |
[:p.event.listening "Connecting to Device"])]])))) | |
(defn- bootstrap! | |
[] | |
(println "Welcome to the Client Thing") | |
(let [options {:target js/document.body}] | |
(om/root root-frame app options))) | |
(set! (.-onload js/window) bootstrap!) |
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 com.zentrope/phone-scratch-client "1" | |
:min-lein-version "2.5.0" | |
:dependencies [[org.clojure/clojure "1.7.0-alpha4"] | |
[org.clojure/clojurescript "0.0-2511"] | |
[om "0.8.0-beta5"] | |
[sablono "0.2.22"]] | |
:cljsbuild {:builds [{:id "main" | |
:source-paths ["src"] | |
:compiler {:output-to "www/js/app.js" | |
:preamble ["react/react_with_addons.min.js"] | |
:cache-analysis true | |
:optimizations :whitespace | |
:pretty-print true}}]} | |
:plugins [[lein-cljsbuild "1.0.4-SNAPSHOT"]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment