diff --git a/resources/public/js/main.js b/resources/public/js/main.js index 5be8624..b522097 100644 --- a/resources/public/js/main.js +++ b/resources/public/js/main.js @@ -33,18 +33,21 @@ var updatePreview = function(){ }, delay); }; -if($action){ - if($action.value == "update") updatePreview(); else $draft.value = ""; - $draft.onkeyup = updatePreview; - $("publish-button").onclick = function(e) { - if($plain_password.value != "") $password.value = md5($plain_password.value); - $plain_password.value = null; - $("session-value").value = hash($draft.value + $("session-key").value); +function loadPage() { + if($action){ + if($action.value == "update") updatePreview(); else $draft.value = ""; + $draft.onkeyup = updatePreview; + $("publish-button").onclick = function(e) { + if($plain_password.value != "") $password.value = md5($plain_password.value); + $plain_password.value = null; + $("session-value").value = hash($draft.value + $("session-key").value); + } + if(iosDetected) $draft.className += " ui-border"; else $draft.focus(); } - if(iosDetected) $draft.className += " ui-border"; else $draft.focus(); -} -var mdDocs = document.getElementsByClassName("markdown"); -for(var i = 0; i < mdDocs.length; i++){ - mdDocs[i].innerHTML = marked(mdDocs[i].innerHTML); + var mdDocs = document.getElementsByClassName("markdown"); + for(var i = 0; i < mdDocs.length; i++){ + mdDocs[i].innerHTML = marked(mdDocs[i].innerHTML); + show(mdDocs[i]); + } } diff --git a/resources/public/style.less b/resources/public/style.less index 29a9abf..9d17e01 100644 --- a/resources/public/style.less +++ b/resources/public/style.less @@ -143,7 +143,7 @@ textarea { font-size: 1em; height: 500px; } -.hidden { +.hidden, .markdown { display: none; } h1 { diff --git a/src/NoteHub/views/common.clj b/src/NoteHub/views/common.clj index bf83da5..9f1e9f9 100644 --- a/src/NoteHub/views/common.clj +++ b/src/NoteHub/views/common.clj @@ -40,10 +40,6 @@ :rel "stylesheet" :type "text/css"}] [:link {:rel "stylesheet/less" :type "text/css" :href "/style.less"}] - ; google analytics code should appear in prod mode only - (if-not (dev-mode?) (include-js "/js/google-analytics.js"))] - [:body content - ; we only need JS during a new note creation, so don't render it otherwise (html (include-js "/js/less.js") (include-js "/js/md5.js") @@ -51,13 +47,16 @@ (include-js "/js/main.js") (include-js "/js/themes.js") (javascript-tag (str "less.modifyVars({ - '@background': themes['" theme "'].background.normal, - '@background_halftone': themes['" theme "'].background.halftone, - '@foreground': themes['" theme "'].foreground.normal, - '@foreground_halftone': themes['" theme "'].foreground.halftone, - '@link_fresh': themes['" theme "'].link.fresh, - '@link_visited': themes['" theme "'].link.visited, - '@link_hover': themes['" theme "'].link.hover});")))]))) + '@background': themes['" theme "'].background.normal, + '@background_halftone': themes['" theme "'].background.halftone, + '@foreground': themes['" theme "'].foreground.normal, + '@foreground_halftone': themes['" theme "'].foreground.halftone, + '@link_fresh': themes['" theme "'].link.fresh, + '@link_visited': themes['" theme "'].link.visited, + '@link_hover': themes['" theme "'].link.hover});"))) + ; google analytics code should appear in prod mode only + (if-not (dev-mode?) (include-js "/js/google-analytics.js"))] + [:body {:onload "loadPage()"} content]))) (defn layout "Generates the main html layout"