File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,16 @@ function incrementTime(amount) {
3030 updateDisplay ( ) ;
3131}
3232
33+ function resetAlarmState ( ) {
34+ if ( timer ) clearInterval ( timer ) ;
35+ timer = null ;
36+
37+ audio . pause ( ) ;
38+ audio . currentTime = 0 ;
39+ }
40+
3341function setAlarm ( ) {
42+ resetAlarmState ( ) ;
3443 const input = document . getElementById ( "alarmSet" ) ;
3544 const parsed = parseInputTime ( input . value ) ;
3645
@@ -66,7 +75,9 @@ function stopTimer() {
6675}
6776
6877document . getElementById ( "up" ) . addEventListener ( "click" , ( ) => incrementTime ( 5 ) ) ;
69- document . getElementById ( "down" ) . addEventListener ( "click" , ( ) => incrementTime ( - 5 ) ) ;
78+ document
79+ . getElementById ( "down" )
80+ . addEventListener ( "click" , ( ) => incrementTime ( - 5 ) ) ;
7081document . getElementById ( "set" ) . addEventListener ( "click" , setAlarm ) ;
7182document . getElementById ( "stop" ) . addEventListener ( "click" , stopTimer ) ;
7283
You can’t perform that action at this time.
0 commit comments