Skip to content

Commit

Permalink
Revert "whodunit"
Browse files Browse the repository at this point in the history
This reverts commit 28035ad.
  • Loading branch information
ethanf108 committed Sep 18, 2022
1 parent 28035ad commit 255efba
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 43 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM clojure:latest as clojure-build
WORKDIR /build
COPY deps.edn .
COPY src/ src/
RUN clojure -M -m cljs.main --optimizations none -c weird-clock.main
RUN clojure -M -m cljs.main --optimizations advanced -c weird-clock.main

FROM galenguyer/nginx
WORKDIR /web
Expand Down
20 changes: 3 additions & 17 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,14 @@
overflow: hidden;
margin: 0;
}
canvas_ {
canvas {
width: 100vw;
height: 100vh;
}
.guess {
padding: 10vw;
}
</style>
</head>
<body id="body">
<canvas id="draw" width="500" height="500"></canvas>
<br />
<span class="guess">
<input id="guess-text" type="time" min="00:00" max="11:59"></input>
<button id="guess-button">Guess</button>
</span>
<body>
<canvas id="draw"></canvas>
<script src="out/main.js" type="text/javascript"></script>
<script type="text/javascript" defer>
var hint;
window.addEventListener("load", function(){
hint = weird_clock.main;
})
</script>
</body>
</html>
28 changes: 3 additions & 25 deletions src/weird_clock/main.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
(set! (.-textBaseline draw-ctx) "middle")
(set! (.-textAlign draw-ctx) "center")

; challenge time
(def challenge-hour (.floor js/Math (* 12 (.random js/Math))))
(def challenge-minute (.floor js/Math (* 60 (.random js/Math))))
(.log js/console "Murder Myster :)")

(defn draw-fn []
(let [
draw-width (.-offsetWidth draw-canvas)
Expand All @@ -48,30 +43,13 @@
(set! (.-lineWidth draw-ctx) 6)
(let [
time (/ (.now js/Date) 1000 60)
minute challenge-minute ; (mod time 60)
hour (+ challenge-hour (/ minute 60)) ; (mod (+ (/ time 60) (- (/ (.getTimezoneOffset (js/Date.)) 60))) 12)
minute (mod time 60)
hour (mod (+ (/ time 60) (- (/ (.getTimezoneOffset (js/Date.)) 60))) 12)
startHour (.indexOf hours (Math/floor hour))
endHour (.indexOf hours (Math/floor (+ hour 1)))
startMinute (.indexOf hours (Math/floor (/ minute 5)))
endMinute (.indexOf hours (Math/floor (+ (/ minute 5) 1)))]
(draw-line draw-ctx draw-width draw-height (* 2 Math/PI (/ (+ startMinute (* (mod (- endMinute startMinute) 12) (/ (mod minute 5) 5))) 12)) 0.7)
(draw-line draw-ctx draw-width draw-height (* 2 Math/PI (/ (+ startHour (* (/ minute 60) (mod (- endHour startHour) 12))) 12)) 0.5))))

; (js/setInterval draw-fn 1000)
(draw-fn)

(def guess-input (.getElementById js/document "guess-text"))

(defn guess-fn []
(let [
value (.-value guess-input)
hour (js/parseInt (.substring value 0 (.indexOf value ":")))
minute (js/parseInt (.substring value (+ (.indexOf value ":") 1)))]
(when-not (or (js/isNaN hour) (js/isNaN minute))
(if (and (= challenge-hour hour) (= challenge-minute minute))
(set! (.-innerHTML (.getElementById js/document "body")) "<h1>Clue 9: 5</h1>")
(set! (.-value guess-input) "")))))

(.addEventListener (.getElementById js/document "guess-button") "click" guess-fn)

(defn print-answer [] (.log js/console (.concat "" challenge-hour ":" challenge-minute)))
(js/setInterval draw-fn 1000)

0 comments on commit 255efba

Please sign in to comment.