forked from grantjames/metronome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
26 lines (21 loc) · 767 Bytes
/
app.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
var metronome = new Metronome();
var tempo = document.getElementById('tempo');
tempo.textContent = metronome.tempo;
var playPauseIcon = document.getElementById('play-pause-icon');
var playButton = document.getElementById('play-button');
playButton.addEventListener('click', function() {
metronome.startStop();
if (metronome.isRunning) {
playPauseIcon.className = 'pause';
}
else {
playPauseIcon.className = 'play';
}
});
var tempoChangeButtons = document.getElementsByClassName('tempo-change');
for (var i = 0; i < tempoChangeButtons.length; i++) {
tempoChangeButtons[i].addEventListener('click', function() {
metronome.tempo += parseInt(this.dataset.change);
tempo.textContent = metronome.tempo;
});
}