Skip to content

Commit

Permalink
keep hashes working
Browse files Browse the repository at this point in the history
  • Loading branch information
nadavoosh committed Jun 22, 2019
1 parent 631e976 commit 033d37e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ function setFace(){

}

function initClockHours() {
const DEFAULT_HOURS_IN_CLOCK = 11;
const hoursOverride = parseInt(window.location.hash.toString().replace('#', ''));
const initialValue = (function() {
if (isNaN(hoursOverride)) {
return DEFAULT_HOURS_IN_CLOCK
}
if (hoursOverride < 0) {
return -hoursOverride
}
return hoursOverride
})()
document.getElementById("hoursInput").value = initialValue

}

function getHoursInClock() {
const DEFAULT_HOURS_IN_CLOCK = 11;
let hoursOverride = document.getElementById("hoursInput").value;
Expand All @@ -62,6 +78,7 @@ function getHoursInClock() {
}

$(document).ready(function() {
initClockHours()
setFace();
moveHands();
});
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</head>

<body>
<input type="number" id="hoursInput" value="11" min="1">
<input type="number" id="hoursInput" min="1">
<div class="clock">
<div id="hours"></div>
<div id="minutes"></div>
Expand Down

0 comments on commit 033d37e

Please sign in to comment.