-
Notifications
You must be signed in to change notification settings - Fork 0
/
html-builder.js
124 lines (104 loc) · 4.51 KB
/
html-builder.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
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
maxOrder = 12;
function updateMaxOrder(newMaxOrder)
{
maxOrder = newMaxOrder;
continuousPolesZerosDiv = document.getElementById("continuous-poles-zeros");
discretePolesZerosDiv = document.getElementById("discrete-poles-zeros");
for(var i = 0; i < maxOrder / 4; i++)
{
const startIndex = i * 4;
const endIndex = Math.min(startIndex + 4, maxOrder);
const style = "display: inline-block;";
poleSet = document.createElement("div");
poleSet.style = style;
zeroSet = document.createElement("div");
zeroSet.style = style;
for(var j = startIndex; j < endIndex; j++)
{
const index = j + 1;
const style = "padding:5px;";
pole = document.createElement("div");
pole.style = style;
poleName = document.createElement("p");
poleName.innerText = "pole " + index;
poleInputX = document.createElement("input");
poleInputY = document.createElement("input");
poleInputX.id = "sp-x" + index;
poleInputY.id = "sp-y" + index;
poleInputX.oninput = ()=>{ setFromSPlane(); };
poleInputY.oninput = ()=>{ setFromSPlane(); };
pole.appendChild(poleName);
pole.appendChild(poleInputX);
pole.appendChild(poleInputY);
poleSet.appendChild(pole);
zero = document.createElement("div");
zero.style = style;
zeroName = document.createElement("p");
zeroName.innerText = "zero " + index;
zeroInputX = document.createElement("input");
zeroInputY = document.createElement("input");
zeroInputX.id = "sz-x" + index;
zeroInputY.id = "sz-y" + index;
zeroInputX.oninput = ()=>{ setFromSPlane(); };
zeroInputY.oninput = ()=>{ setFromSPlane(); };
zero.appendChild(zeroName);
zero.appendChild(zeroInputX);
zero.appendChild(zeroInputY);
zeroSet.appendChild(zero);
}
continuousPolesZerosDiv.appendChild(poleSet);
continuousPolesZerosDiv.appendChild(zeroSet);
}
for(var i = 0; i < maxOrder / 4; i++)
{
const startIndex = i * 4;
const endIndex = Math.min(startIndex + 4, maxOrder);
const style = "display: inline-block;";
poleSet = document.createElement("div");
poleSet.style = style;
zeroSet = document.createElement("div");
zeroSet.style = style;
for(var j = startIndex; j < endIndex; j++)
{
const index = j + 1;
const style = "padding:5px;";
pole = document.createElement("div");
pole.style = style;
poleName = document.createElement("p");
poleName.innerText = "pole " + index;
poleInputX = document.createElement("input");
poleInputY = document.createElement("input");
poleInputX.id = "zp-x" + index;
poleInputY.id = "zp-y" + index;
poleInputX.oninput = ()=>{ setFromZPlane(); };
poleInputY.oninput = ()=>{ setFromZPlane(); };
pole.appendChild(poleName);
pole.appendChild(poleInputX);
pole.appendChild(poleInputY);
poleSet.appendChild(pole);
zero = document.createElement("div");
zero.style = style;
zeroName = document.createElement("p");
zeroName.innerText = "zero " + index;
zeroInputX = document.createElement("input");
zeroInputY = document.createElement("input");
zeroInputX.id = "zz-x" + index;
zeroInputY.id = "zz-y" + index;
zeroInputX.oninput = ()=>{ setFromZPlane(); };
zeroInputY.oninput = ()=>{ setFromZPlane(); };
zero.appendChild(zeroName);
zero.appendChild(zeroInputX);
zero.appendChild(zeroInputY);
zeroSet.appendChild(zero);
}
discretePolesZerosDiv.appendChild(poleSet);
discretePolesZerosDiv.appendChild(zeroSet);
}
const recursiveOrder = Math.min(maxOrder, 8);
document.getElementById("butterworthOrder").max = recursiveOrder;
document.getElementById("chebyshevOrder").max = recursiveOrder;
document.getElementById("linkwitzRileyOrder").max = Math.floor( Math.log2(recursiveOrder) ) - 1;
document.getElementById("allpassOrder").max = recursiveOrder;
document.getElementById("movingAverageOrder").max = maxOrder;
}
updateMaxOrder(maxOrder);