-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.js
92 lines (76 loc) · 1.61 KB
/
settings.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
let white = true;
let sharp = true;
let flat = true;
let pianoClickable = false;
let buttonsClickable = false;
let randomButtons = false;
let correct = 0;
let total = 0;
let clock;
const TIMEOUT = debug ? 200 : 1000;
function toggleWhite() {
white = !white;
startLesson();
}
function toggleSharp() {
sharp = !sharp;
startLesson();
}
function toggleFlat() {
flat = !flat;
startLesson();
}
function toggleRandomButtons() {
randomButtons = !randomButtons;
startLesson();
}
function resetScore() {
correct = 0;
total = 0;
}
function correctAnswer() {
correct++;
}
function finishLesson() {
total++;
updateScore();
}
function enablePiano() {
pianoClickable = true;
}
function disablePiano() {
pianoClickable = false;
}
function enableButtons() {
buttonsClickable = true;
}
function disableButtons() {
buttonsClickable = false;
const buttons = document.getElementsByClassName('button');
for (let i = 0; i < buttons.length; i++) {
const button = buttons[i];
addClass(button, 'disabled');
}
}
function selectRandomOctave() {
selectedOctave = getRandomInt(OCTAVES) + 1;
}
function startTimer() {
const minutesLabel = document.getElementById("minutes");
const secondsLabel = document.getElementById("seconds");
let totalSeconds = 0;
clearInterval(clock);
clock = setInterval(() => {
++totalSeconds;
secondsLabel.innerHTML = pad(totalSeconds % 60);
minutesLabel.innerHTML = pad(parseInt(totalSeconds / 60));
}, 1000);
}
function pad(val) {
let valString = val + "";
if (valString.length < 2) {
return "0" + valString;
} else {
return valString;
}
}