-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselectButtons.js
More file actions
132 lines (114 loc) · 5.15 KB
/
Copy pathselectButtons.js
File metadata and controls
132 lines (114 loc) · 5.15 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
var inputFlags = [0,0,0];
var key_signature_input;
var tempo_input;
var time_signature_top_num_input;
var time_signature_bottom_num_input;
function addSelected(input) {
var key_sig = document.getElementById("key-signature-button");
var tempo = document.getElementById("tempo-button");
var time_sig = document.getElementById("time-signature-button");
var key_sig_content = document.getElementById("key-signature-input");
var tempo_content = document.getElementById("tempo-input");
var time_sig_content = document.getElementById("time-signature-input");
var detecting_tempo_content = document.getElementById("detecting-tempo-div");
switch (input) {
case "key-signature":
key_sig.classList.add("selected");
tempo.classList.remove("selected");
time_sig.classList.remove("selected");
key_sig_content.classList.remove("hidden");
tempo_content.classList.add("hidden");
time_sig_content.classList.add("hidden");
break;
case "tempo":
key_sig.classList.remove("selected");
tempo.classList.add("selected");
time_sig.classList.remove("selected");
key_sig_content.classList.add("hidden");
tempo_content.classList.remove("hidden");
time_sig_content.classList.add("hidden");
break;
case "time-signature":
key_sig.classList.remove("selected");
tempo.classList.remove("selected");
time_sig.classList.add("selected");
key_sig_content.classList.add("hidden");
tempo_content.classList.add("hidden");
time_sig_content.classList.remove("hidden");
break;
}
}
function submitForm(input) {
/* get input values */
if (input == "key-signature") {
inputFlags[0] = 1;
key_signature_input = document.querySelector('[name="key-signature"]').value;
console.log("key signature = " + key_signature_input);
/* remove and re-add the checkmark so animation plays again */
var elm = document.getElementById("key-signature-confirmation");
var newone = elm.cloneNode(true);
elm.parentNode.replaceChild(newone, elm);
document.getElementById("key-signature-confirmation").classList.add("confirmed");
document.getElementById("key-signature-confirmation").classList.add("bounce");
} else if (input == "tempo") {
inputFlags[1] = 1;
tempo_input = document.querySelector('[name="tempo"]').value;
console.log("tempo = " + tempo_input);
/* remove and re-add the checkmark so animation plays again */
var elm = document.getElementById("tempo-confirmation");
var newone = elm.cloneNode(true);
elm.parentNode.replaceChild(newone, elm);
document.getElementById("tempo-confirmation").classList.add("confirmed");
document.getElementById("tempo-confirmation").classList.add("bounce");
} else if (input == "time-signature") {
inputFlags[2] = 1;
time_signature_top_num_input = document.querySelector('[name="time-signature-top-num"]').value;
time_signature_bottom_num_input = document.querySelector('[name="time-signature-bottom-num"]').value;
console.log("time signature = " + time_signature_top_num_input + "/" + time_signature_bottom_num_input);
/* remove and re-add the checkmark so animation plays again */
var elm = document.getElementById("time-signature-confirmation");
var newone = elm.cloneNode(true);
elm.parentNode.replaceChild(newone, elm);
document.getElementById("time-signature-confirmation").classList.add("confirmed");
document.getElementById("time-signature-confirmation").classList.add("bounce");
}
var enableButton = true;
for (var i = 0; i < 3; i++) {
if (inputFlags[i] == 0) {
enableButton = false;
}
}
if (enableButton) {
mic_icon = document.getElementById("mic-icon");
mic_icon.classList.remove("disabled-button");
disabledTooltip = document.getElementById("disabled-record-tooltip");
disabledTooltip.classList.add("hidden");
enabledTooltip = document.getElementById("enabled-record-tooltip");
enabledTooltip.classList.remove("hidden");
}
return false;
}
function disable_input(input) {
var checkbox = document.getElementById("auto-detect-key-signature").checked;
if (checkbox) {
// disable stuff
if (input == 'key-signature') {
document.getElementsByClassName("custom-select")[0].classList.add('disabled-button');
}
} else {
// enable stuff
if (input == 'key-signature') {
document.getElementsByClassName("custom-select")[0].classList.remove('disabled-button');
}
}
// auto-submit for key_sig
submitForm('key-signature');
}
function checkPowerOfTwo() {
var bottomNumInput = document.querySelector('[name="time-signature-bottom-num"]');
if (Math.log2(bottomNumInput.value) % 1 == 0) {
bottomNumInput.setCustomValidity("");
} else {
bottomNumInput.setCustomValidity("Value must be a power of 2.");
}
}