@@ -42,7 +42,7 @@ function setAlarm() {
42
42
if ( inputInfo <= 0 ) {
43
43
clearInterval ( intervalId ) ;
44
44
playAlarm ( ) ;
45
- changeBackgroundColor ( ) ;
45
+ changeBackgroundColorFlashing ( ) ;
46
46
return ;
47
47
} else {
48
48
inputInfo -- ;
@@ -57,16 +57,27 @@ function setAlarm() {
57
57
//console.log("click event is firing...");
58
58
//});
59
59
60
- //setStopButton.addEventListener("click", function stopAlarm() {
61
- //console.log("click event is firing...");
62
- //clearInterval(intervalId);
63
- //pauseAlarm();
64
- //});
65
-
66
- //alarm sound stop })
67
-
68
- function changeBackgroundColor ( ) {
69
- backgroundColor . style . backgroundColor = "lightblue" ;
60
+ setStopButton . addEventListener ( "click" , function stopFlashing ( ) {
61
+ console . log ( "click event is firing..." ) ;
62
+ clearInterval ( flashIntervalId ) ;
63
+ backgroundColor . style . backgroundColor = "" ;
64
+ pauseAlarm ( ) ;
65
+ } ) ;
66
+
67
+ //function changeBackgroundColor() {
68
+ //backgroundColor.style.backgroundColor = "lightblue";
69
+ //}
70
+
71
+ let flashColor = [ "yellow" , "pink" , "lightgrey" , "green" ] ;
72
+ let flashIntervalId ;
73
+ let colorIndex = 0 ;
74
+
75
+ function changeBackgroundColorFlashing ( ) {
76
+ if ( flashIntervalId ) clearInterval ( flashIntervalId ) ;
77
+ flashIntervalId = setInterval ( function ( ) {
78
+ backgroundColor . style . backgroundColor = flashColor [ colorIndex ] ;
79
+ colorIndex = ( colorIndex + 1 ) % flashColor . length ;
80
+ } , 1000 ) ;
70
81
}
71
82
72
83
// DO NOT EDIT BELOW HERE
0 commit comments