Skip to content
Browse files

refactorings

  • Loading branch information...
1 parent 9ebd2ed commit e1f13feec4247c7360f6aca8863c5f9419c4b94e @nusco nusco committed Nov 25, 2012
Showing with 10 additions and 24 deletions.
  1. +7 −21 resources/public/javascript/tryclojure.js
  2. +3 −3 src/tryclojure/views/home.clj
View
28 resources/public/javascript/tryclojure.js
@@ -48,25 +48,11 @@ var pageExitConditions = [
}
];
-function nextPage() {
- if (currentPage < pages.length - 1) {
- goToPage(currentPage + 1);
- }
-}
-
-function previousPage() {
- if (currentPage > 0) {
- goToPage(currentPage - 1);
- }
-}
-
-function goToFirstPage() {
- if (currentPage > 0) {
- goToPage(0);
- }
-}
-
function goToPage(pageNumber) {
+ if (pageNumber == currentPage || pageNumber < 0 || pageNumber >= pages.length) {
+ return;
+ }
+
currentPage = pageNumber;
var block = $("#changer");
@@ -115,18 +101,18 @@ function doCommand(input) {
switch (input) {
case 'next':
case 'forward':
- nextPage();
+ goToPage(currentPage + 1);
return true;
case 'previous':
case 'prev':
case 'back':
- previousPage();
+ goToPage(currentPage - 1);
return true;
case 'restart':
case 'reset':
case 'home':
case 'quit':
- goToFirstPage();
+ goToPage(0);
return true;
default:
return false;
View
6 src/tryclojure/views/home.clj
@@ -3,7 +3,7 @@
[hiccup.element :refer [javascript-tag link-to unordered-list]]
[hiccup.page :refer [include-css include-js html5]]))
-(defpartial links []
+(defpartial links-html []
(unordered-list
[(link-to "http://clojure.org" "The official Clojure website")
(link-to "http://dev.clojure.org/display/doc/Getting+Started" "Getting started with Clojure")
@@ -35,7 +35,7 @@
"You can see a Clojure interpreter above - we call it a <em>REPL</em>."
]
[:p.bottom
- "Type \"next\" in the REPL to begin."
+ "Type <code>next</code> in the REPL to begin."
])
(defn root-html []
@@ -89,4 +89,4 @@
(about-html))
(defpage "/links" []
- (links))
+ (links-html))

0 comments on commit e1f13fe

Please sign in to comment.
Something went wrong with that request. Please try again.