File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,25 +12,33 @@ function setAlarm() {
1212 timeRemaining = parseInt ( input . value ) ;
1313
1414 if ( isNaN ( timeRemaining ) || timeRemaining <= 0 ) return ;
15- updateDisplay ( ) ;
15+ updateDisplay ( ) ;
1616
1717 interval = setInterval ( ( ) => {
1818 if ( timeRemaining <= 0 ) {
1919 clearInterval ( interval ) ;
2020 timeRemaining = 0 ;
2121 updateDisplay ( ) ;
2222 playAlarm ( ) ;
23-
2423 // Start flashing background
25- if ( window . JEST_WORKER_ID ) {
2624 flashInterval = setInterval ( ( ) => {
2725 document . body . style . backgroundColor =
2826 document . body . style . backgroundColor === "green" ? "white" : "green" ;
2927 } , 500 ) ;
30-
31- return ; // exit interval
32- } }
33- // Decrement only if above 0
28+ const stopButton = document . getElementById ( "stop" ) ;
29+ stopButton . addEventListener (
30+ "click" ,
31+ ( ) => {
32+ clearInterval ( flashInterval ) ;
33+ document . body . style . backgroundColor = "white" ;
34+ } ,
35+ { once : true }
36+ ) ;
37+
38+ return ;
39+ }
40+
41+ // Decrement only if above 0
3442 timeRemaining -- ;
3543 updateDisplay ( ) ;
3644 } , 1000 ) ;
@@ -46,7 +54,6 @@ function setAlarm() {
4654 }
4755}
4856
49-
5057// DO NOT EDIT BELOW HERE
5158
5259var audio = new Audio ( "alarmsound.mp3" ) ;
You can’t perform that action at this time.
0 commit comments