File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 11let inputTime = 0 ;
22let timer = null ;
3+ let changeBgColor = false ;
34
45function setAlarm ( ) {
56 inputTime = Number ( document . querySelector ( "#alarmSet" ) . value ) ;
67
78 if ( Number . isInteger ( inputTime ) && ! isNaN ( inputTime ) && inputTime >= 0 ) {
89 if ( inputTime === 10 ) {
10+ changeBgColor = true ;
11+ } else if ( inputTime === 0 ) {
12+ displayTime ( inputTime ) ;
13+ playAlarm ( ) ;
914 }
1015 displayTime ( inputTime ) ;
1116 if ( timer ) clearInterval ( timer ) ;
@@ -30,10 +35,21 @@ function countDown() {
3035
3136 if ( inputTime === 0 ) {
3237 playAlarm ( ) ;
38+
39+ if ( changeBgColor ) {
40+ changeColor ( ) ;
41+ changeBgColor = false ;
42+ }
43+
3344 clearInterval ( timer ) ;
3445 timer = null ;
3546 }
3647}
48+
49+ function changeColor ( ) {
50+ const bgColor = document . querySelector ( "div" ) ;
51+ bgColor . classList . add ( "myBgColor" ) ;
52+ }
3753/*
3854the the value for time remaining
3955check its a valid time (greater than 00:00)
Original file line number Diff line number Diff line change 66 transform : translate (-50% , -50% );
77}
88
9+ .myBgColor {
10+ background-color : # f0f8ff ;
11+ }
12+
913# alarmSet {
1014 margin : 20px ;
1115}
You can’t perform that action at this time.
0 commit comments