Skip to content

Commit 5e723c2

Browse files
move pause button listener to window load
1 parent 35c4a7c commit 5e723c2

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Sprint-3/alarmclock/alarmclock.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ let intervalId;
22
let isPaused;
33
let remainingSeconds = 0;
44
function setAlarm() {
5-
6-
const pauseButton = document.getElementById("pause-button");
7-
pauseButton.textContent = "Pause";
8-
pauseButton.removeEventListener("click",pauseCountDown)
9-
pauseButton.addEventListener("click", pauseCountDown);
5+
// const pauseButton = document.getElementById("pause-button");
6+
// pauseButton.textContent = "Pause";
7+
// pauseButton.addEventListener("click", pauseCountDown);
108

119
const alarmSetEl = document.getElementById("alarmSet");
1210
const timeRemainingEl = document.getElementById("timeRemaining");
@@ -63,9 +61,11 @@ function pauseCountDown(e) {
6361

6462
function cleanInitialState() {
6563
isPaused = false;
64+
const pauseButton = document.getElementById("pause-button");
65+
pauseButton.textContent = "Pause";
6666
clearInterval(intervalId);
6767
document.body.classList.remove("finish-countdown");
68-
updateDisplayedTime(0)
68+
updateDisplayedTime(0);
6969
document.getElementById("alarmSet").value = null;
7070
pauseAlarm();
7171
}
@@ -86,6 +86,11 @@ function finishCountDown() {
8686
clearInterval(intervalId);
8787
}
8888

89+
window.addEventListener("load", function () {
90+
const pauseButton = document.getElementById("pause-button");
91+
pauseButton.addEventListener("click", pauseCountDown);
92+
});
93+
8994
// DO NOT EDIT BELOW HERE
9095

9196
var audio = new Audio("alarmsound.mp3");

0 commit comments

Comments
 (0)