-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasses.js
More file actions
113 lines (90 loc) · 3.8 KB
/
classes.js
File metadata and controls
113 lines (90 loc) · 3.8 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
class Filter {
constructor(name) {
this.filterDisplayName = name;
this.filterIdName = name.replace(" ", "-");
this.allParams = {};
// This is the overall div that the filter is in
var filterDiv = document.createElement("div");
filterDiv.className = "item";
// This div will contain all the parameters
// ID Example: Gain-(Volume)-param
this.paramDiv = document.createElement("div");
this.paramDiv.id = this.filterIdName + "-param";
// Checkbox to enable the filter
// ID Example: Gain-(Volume)-checkbox
this.checkbox = document.createElement("input");
this.checkbox.type = "checkbox";
this.checkbox.id = this.filterIdName + "-checkbox";
// Name of the filter
var label = document.createElement("label");
label.htmlFor = this.checkbox.id;
label.textContent = this.filterDisplayName;
filterDiv.appendChild(this.checkbox);
filterDiv.appendChild(label);
filterDiv.appendChild(this.paramDiv);
document.getElementsByClassName("wrapper")[0].appendChild(filterDiv);
}
getChecked() {
return this.checkbox.checked;
}
createNumberParam(paramName, defaultNum) {
var param = new NumberParam(paramName, defaultNum, this.filterIdName);
this.allParams[paramName] = param;
}
createDropdownParam(paramName, choices) {
var param = new DropdownParam(paramName, choices, this.filterIdName);
this.allParams[paramName] = param;
}
//TODO: Fix the removal of the default values
createCaption(html) {
var div = document.createElement('div');
div.innerHTML = html;
while (div.children.length > 0) {
this.paramDiv.appendChild(div.children[0]);
}
}
}
class NumberParam {
constructor(paramName, defaultNum, filterName) {
this.paramIdName = paramName.replace(" ", "-");
this.paramDisplayName = paramName;
var paramLabel = document.createElement("label");
paramLabel.htmlFor = filterName + "-" + this.paramIdName;
paramLabel.textContent = this.paramDisplayName;
// ID Example: Gain-(Volume)-Gain-Increase
this.inputBox = document.createElement("input");
this.inputBox.type = "number";
this.inputBox.value = defaultNum;
this.inputBox.id = filterName + "-" + this.paramIdName;
var lineBreak = document.createElement('br');
document.getElementById(filterName + "-param").appendChild(paramLabel);
document.getElementById(filterName + "-param").appendChild(this.inputBox);
document.getElementById(filterName + "-param").appendChild(lineBreak);
}
getValue() {
return this.inputBox.value;
}
}
class DropdownParam {
constructor(paramName, choices, filterName) {
this.paramIdName = paramName.replace(" ", "-");
this.paramDisplayName = paramName;
var paramLabel = document.createElement("label");
paramLabel.htmlFor = filterName + "-" + this.paramIdName;
paramLabel.textContent = this.paramDisplayName;
this.DropdownBar = document.createElement("select");
this.DropdownBar.id = filterName + "-" + this.paramIdName;
for (var choiceText in choices) {
var choice = document.createElement("option");
choice.textContent = choices[choiceText];
this.DropdownBar.appendChild(choice);
}
var lineBreak = document.createElement('br');
document.getElementById(filterName + "-param").appendChild(paramLabel);
document.getElementById(filterName + "-param").appendChild(this.DropdownBar);
document.getElementById(filterName + "-param").appendChild(lineBreak);
}
getValue() {
return this.DropdownBar.value;
}
}