Skip to content

Commit

Permalink
feat: now with a refresh button
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinFay committed Jan 31, 2025
1 parent a0677f9 commit 683d1f4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
22 changes: 22 additions & 0 deletions custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,25 @@ body {
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}

input[type="number"] {
padding: 10px;
font-size: 16px;
margin-right: 10px;
border: 1px solid #ccc;
border-radius: 4px;
}

button {
padding: 10px 20px;
font-size: 16px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}

button:hover {
background-color: #0056b3;
}
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
<div id="timer">
<span id="minutes"></span>:<span id="seconds"></span>
</div>

<input type="number" id="urlInput" placeholder="Enter number" value = "5" />
<button onclick="refresh_page()">Refresh</button>
<script src="script.js">
</script>

Expand Down
20 changes: 14 additions & 6 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// We query the timer object. We want it to be of type
// HTMLHeadingElement so that it can only
// receive a heading element.
// We query the timer object. We want it to be of type
// HTMLHeadingElement so that it can only
// receive a heading element.
// Other type could have been HTMLElement, an interface for all html elements
// but it's a larger type.
var timer = document.querySelector("#timer");
Expand All @@ -12,7 +12,7 @@ var minutes = loc.search.split("?")[1];
var doc = document.querySelector("#minutes");
// If there is a minute query param, we'll set the innerHTML
// of #minutes to that value.
// That means that we always start with NUMBER:00 as a default,
// That means that we always start with NUMBER:00 as a default,
// i.e the minutes values is always 0 at the start.
if (minutes) {
doc.innerHTML = minutes;
Expand Down Expand Up @@ -40,7 +40,7 @@ function tick() {
clearInterval(ticker_interv);
}
else {
// Here, the seconds is 0, so we'll set it back to
// Here, the seconds is 0, so we'll set it back to
//59 and decrement the minutes.
updateByQS("#seconds", "59");
updateByQS("#minutes", (minnum - 1).toString());
Expand All @@ -57,7 +57,15 @@ function tick() {
}
var ticker_interv = setInterval(tick, 1000);
window.onresize = function () {
// Reupdate the font size of the timer whenever the
// Reupdate the font size of the timer whenever the
// window is resized. We reuse the global timer variable.
timer.style.fontSize = timer.offsetWidth / 2 + "px";
};

refresh_page = function () {
var input = document.getElementById('urlInput').value;
if (!input) {
input = 5;
}
window.location.href = window.location.origin + '/?' + input;
};

0 comments on commit 683d1f4

Please sign in to comment.