1
+ "use strict" ;
2
+
3
+ const sound = document . getElementById ( "sound" ) ;
1
4
const buttons = document . querySelectorAll ( "[data-seconds]" ) ;
2
5
const form = document . querySelector ( "#form" ) ;
3
6
const input = document . querySelector ( "#input" ) ;
@@ -17,6 +20,9 @@ function timer(seconds) {
17
20
clearInterval ( countdown ) ;
18
21
return ;
19
22
}
23
+ if ( remainingTime . innerText === "00:00" ) {
24
+ sound . pause ( ) ;
25
+ }
20
26
displayRemainingTime ( remainingSeconds ) ;
21
27
} ) ;
22
28
}
@@ -43,36 +49,41 @@ function displayEndTime(then) {
43
49
}
44
50
45
51
function startTimer1 ( ) {
52
+ sound . play ( ) ;
46
53
const seconds = this . dataset . seconds ;
47
54
timer ( seconds ) ;
48
55
}
49
56
50
57
function startTimer2 ( e ) {
51
58
e . preventDefault ( ) ;
59
+ sound . play ( ) ;
52
60
const minutes = input . value ;
53
61
const seconds = minutes * 60 ;
54
62
55
63
if ( minutes / 1 != minutes ) {
64
+ sound . pause ( ) ;
56
65
clearInterval ( countdown ) ;
57
66
remainingTime . textContent = "Please enter only numbers." ;
58
- remainingTime . style . fontSize = "7rem" ;
67
+ remainingTime . style . fontSize = window . innerWidth < 500 ? "4rem" : "7rem" ;
59
68
document . title = "Countdown Timer" ;
60
69
endTime . textContent = "" ;
61
70
this . reset ( ) ;
62
71
return ;
63
72
}
64
73
65
74
if ( minutes < 0 ) {
75
+ sound . pause ( ) ;
66
76
clearInterval ( countdown ) ;
67
77
remainingTime . textContent = "Please enter a positive number." ;
68
- remainingTime . style . fontSize = "7rem" ;
78
+ remainingTime . style . fontSize = window . innerWidth < 500 ? "3.9rem" : "7rem" ;
69
79
document . title = "Countdown Timer" ;
70
80
endTime . textContent = "" ;
71
81
this . reset ( ) ;
72
82
return ;
73
83
}
74
84
75
85
if ( minutes == 0 ) {
86
+ sound . pause ( ) ;
76
87
clearInterval ( countdown ) ;
77
88
remainingTime . textContent = "Oh, no! Zero?" ;
78
89
remainingTime . style . fontSize = "7rem" ;
0 commit comments