-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservertest.js
238 lines (171 loc) · 7.57 KB
/
servertest.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
function testServer() {
console.log('1');
}
function firstDropdownChanged() {
let singularDropdown = document.getElementById("singular");
let pluralDropdown = document.getElementById("plural");
let qDropdown = document.getElementById("q");
let goButton = document.getElementById("goButton");
let singularSelected = singularDropdown.options[singularDropdown.selectedIndex].value;
var values = ["base"];
var texts = ["----"];
if(singularSelected == "base") {
pluralDropdown.disabled = true;
}else{
if(singularSelected == "type"){
values.push("satellite");
texts.push("satellites");
values.push("launch");
texts.push("launches");
// values.push("vehicle.vehiclename");
// texts.push("spaceships");
}else if(singularSelected == "ownercountry"){
values.push("satellite");
texts.push("satellites");
values.push("launch");
texts.push("launches");
values.push("vehicle.vehiclename");
texts.push("spaceships");
}else if(singularSelected == "companyname"){
values.push("satellite");
texts.push("satellites");
// values.push("launch");
// texts.push("launches");
// values.push("vehicle.vehiclename");
// texts.push("spaceships");
}
pluralDropdown.innerHTML = "";
var i;
for(i = 0; i < values.length; i++) {
var opt = document.createElement("option");
opt.value = values[i];
opt.text = texts[i];
pluralDropdown.options[i] = opt;
}
pluralDropdown.disabled = false;
}
qDropdown.disabled = true;
goButton.disabled = true;
// console.log(pluralDropdown.options);
}
function secondDropdownChanged() {
let singularDropdown = document.getElementById("singular");
let singularSelected = singularDropdown.options[singularDropdown.selectedIndex].value;
let pluralDropdown = document.getElementById("plural");
let pluralSelected = pluralDropdown.options[pluralDropdown.selectedIndex].value;
let qDropdown = document.getElementById("q");
let goButton = document.getElementById("goButton");
var values = ["base"];
var texts = ["----"];
if(pluralSelected == "base") {
qDropdown.disabled = true;
} else {
//Add pertinent options
if(pluralSelected == "satellite"){
// values.push("decade");
// texts.push("were launched in which decade");
values.push("orbitclass");
texts.push("are in which orbital class");
values.push("type");
texts.push("belong to which use case");
values.push("companyname");
texts.push("were launched by which company");
// values.push("vehicle.vehiclename");
// texts.push("were launched on which ship");
// values.push("weightClass");
// texts.push("were in which weight class");
// values.push("numLaunches");
// texts.push("were launched how many times");
// values.push("location");
// texts.push("were launched from which site");
}else if(pluralSelected == "launch"){
values.push("decade");
texts.push("were launched in which decade");
// values.push("orbitclass");
// texts.push("are in which orbital class");
values.push("type");
texts.push("belong to which use case");
//Turns out a ship isn't necessarily launched by one company
// values.push("companyname");
// texts.push("were launched by which company");
if(singularSelected != "companyname") {
values.push("vehicle.vehiclename");
texts.push("were launched on which ship");
}
values.push("weightClass");
texts.push("were in which weight class");
// values.push("numLaunches");
// texts.push("were launched how many times");
values.push("location");
texts.push("were launched from which site");
}else if(pluralSelected == "vehicle.vehiclename"){
values.push("decade");
texts.push("were launched in which decade");
// values.push("orbitclass");
// texts.push("are in which orbital class");
// values.push("type");
// texts.push("belong to which use case");
if(singularSelected != "type"){
//Turns out a single ship isn't necessarily launched by a single company
// values.push("companyname");
// texts.push("were launched by which company");
// values.push("vehicle.vehiclename");
// texts.push("were launched on which ship");
values.push("weightClass");
texts.push("were in which weight class");
values.push("numLaunches");
texts.push("were launched how many times");
values.push("location");
texts.push("were launched from which site");
}
}
qDropdown.innerHTML = "";
var i;
for(i = 0; i < values.length; i++) {
var opt = document.createElement("option");
opt.value = values[i];
opt.text = texts[i];
qDropdown.options[i] = opt;
}
qDropdown.disabled = false;
goButton.disabled = true;
}
}
function thirdDropdownChanged() {
let qDropdown = document.getElementById("q");
let qSelected = qDropdown.options[qDropdown.selectedIndex].value;
let goButton = document.getElementById("goButton");
if(qSelected == "base") {
goButton.disabled = true;
} else {
goButton.disabled = false;
}
}
function requestData() {
let singularDropdown = document.getElementById("singular");
let singularSelected = singularDropdown.options[singularDropdown.selectedIndex].value;
let pluralDropdown = document.getElementById("plural");
let pluralSelected = pluralDropdown.options[pluralDropdown.selectedIndex].value;
let qDropdown = document.getElementById("q");
let qSelected = qDropdown.options[qDropdown.selectedIndex].value;
let numberBox = document.getElementById("minNumberBox");
let minim = numberBox.value || 1;
console.log(singularSelected);
console.log(pluralSelected);
console.log(qSelected);
const Http = new XMLHttpRequest();
const url=`data/${singularSelected}/${pluralSelected}/${qSelected}/${minim}`;
if(singularSelected == qSelected) {
add_message(`errormessage`, `Asking how many of which ${singularSelected}'s anything map to which ${qSelected} is a bit redundant no?`, false);
return
}
console.log(url);
Http.open("GET", url);
Http.send();
Http.onreadystatechange=function(){
if(this.readyState == 4 && this.status == 200) {
// console.log(Http.responseText);
process_sankey(Http.responseText);
}
}
}