-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathevents.js
95 lines (80 loc) · 2.2 KB
/
events.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import {
buttonPlay,
buttonPause,
buttonStop,
buttonPlus,
buttonMinus,
buttonLightTheme,
buttonDarkTheme,
forestCard,
rainCard,
fireCard,
coffeeCard,
forestButton,
rainButton,
fireButton,
coffeeButton,
forestVolume,
rainVolume,
fireVolume,
coffeeVolume
} from './elements.js'
export default function ({ timer, controls, sounds, theme }) {
buttonPlay.addEventListener('click', function () {
sounds.pressButton(sounds.buttonPressAudio)
controls.play()
timer.countdown()
})
buttonPause.addEventListener('click', function () {
sounds.pressButton(sounds.buttonPressAudio)
controls.pause()
timer.hold()
})
buttonStop.addEventListener('click', function () {
sounds.pressButton(sounds.buttonPressAudio)
controls.pause()
timer.reset()
})
buttonPlus.addEventListener('click', function () {
sounds.pressButton(sounds.buttonPressAudio)
timer.plus()
})
buttonMinus.addEventListener('click', function () {
sounds.pressButton(sounds.buttonPressAudio)
timer.minus()
})
forestButton.addEventListener('click', function () {
controls.toggle(forestCard)
sounds.playAudio(sounds.forestAudio, forestCard)
})
forestVolume.addEventListener('input', function () {
sounds.adjustVolume(sounds.forestAudio, forestVolume.value)
})
rainButton.addEventListener('click', function () {
controls.toggle(rainCard)
sounds.playAudio(sounds.rainAudio, rainCard)
})
rainVolume.addEventListener('input', function () {
sounds.adjustVolume(sounds.rainAudio, rainVolume.value)
})
fireButton.addEventListener('click', function () {
controls.toggle(fireCard)
sounds.playAudio(sounds.fireAudio, fireCard)
})
fireVolume.addEventListener('input', function () {
sounds.adjustVolume(sounds.fireAudio, fireVolume.value)
})
coffeeButton.addEventListener('click', function () {
controls.toggle(coffeeCard)
sounds.playAudio(sounds.coffeeAudio, coffeeCard)
})
coffeeVolume.addEventListener('input', function () {
sounds.adjustVolume(sounds.coffeeAudio, coffeeVolume.value)
})
buttonLightTheme.addEventListener('click', function () {
theme.toggle(buttonLightTheme, buttonDarkTheme)
})
buttonDarkTheme.addEventListener('click', function () {
theme.toggle(buttonDarkTheme, buttonLightTheme)
})
}