-
Notifications
You must be signed in to change notification settings - Fork 0
/
pitscouting.html
408 lines (365 loc) · 13.6 KB
/
pitscouting.html
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
<!DOCTYPE HTML>
<html>
<head>
<title>Pit Scouting</title>
<link rel='stylesheet' href="style.css">
<meta name=viewport content="width=device-width">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="eventData.js?v=1"></script>
<script src="scheduleData.js?v=1"></script>
<script src="teamData.js?v=1"></script>
<script>
var ctx = false;
</script>
<style>
img {
display: block;
}
.m1, .p1 {
font-size: 1.35em;
}
input[type="number"]{
font-size: 1.15em;
width: 2.5em;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #fbb3ae;
}
li {
float: left;
}
li a {
display: block;
color: #4d0000;
text-align: center;
padding: 6px 8px;
text-decoration: none;
border: 1px solid #4d0000;
border-radius: 4px;
}
/* Change the link color to #111 (black) on hover */
li a:hover {
background-color: #f66;
}
</style>
</head>
<body class="w3-theme-d3">
<form onsubmit="return false">
<ul>
<li><a href='index.html'>Match</a></li>
<li><a href="pitscouting.html">Pit</a></li>
<li><a href="schedule.php">Sched</a></li>
<li><a href="team_schedule.php?team=967">967 Sched</a></li>
<li><a href="teams.php">Teams</a></li>
<li><a href="report.php">Report</a></li>
</ul>
<div>
<h3>Pit Scouting</h3>
<p class="status"></p>
<label for="team">Team Number</label><br>
<select id="team" value = "167" name="team">
<option value="167">167</option>
<option value="525">525</option>
<option value="967">967</option>
</select><br>
<img src="pics/none.jpg" alt="No picture" id="robot_picture" style='max-width: 300px'>
<canvas width=300 height = 0 id="canvas"></canvas><br>
<label for="fileToUpload">Select Picture to Upload<br></label><br>
<em>(Needs to be cropped and resized to less than 500K filesize first)</em><br>
<em>(Can be done in a separate app such as Pixlr)</em>
<input type="file" onchange="previewPicture();" name="fileToUpload" id="fileToUpload"><br>
<br>
<div id="picbox"></div>
<button id="submitPicture" onclick="uploadPicture();">Upload Image</button><br><br>
<label for="scout_name">Scout Name</label></br>
<input type="text" name="scout_name" value="" id="scout_name">
</div>
<div>
<label for="drive_type">Drive Type</label><br>
<select id="drive_type" value = "skidsteer" name="drive_type">
<option value="">???</option>
<option value="tank">Skid/Tank/4WD/6WD/8WD</option>
<option value="treads">Treads</option>
<option value="mecanum">Mecanum</option>
<option value="swerve">Swerve</option>
<option value="hdrive">H-Drive</option>
<option value="omni">Omni/Holonomic</option>
</select><br>
<br>
<label for=""># of Motors in Drive Train</label></br>
<em>(do not include motors from manipulators)</em></br>
<button class = "m1" id="m1drive_motors">-1</button>
<input type="number" value="4" id="drive_motors" name="drive_motors" min="0" max = "8">
<button class="p1" id="p1drive_motors">+1</button><br>
<br>
<label for="motors_type">Type of Drive Train Motors</label><br>
<select id="motors_type">
<option value="CIM">CIM</option>
<option value="Neo">Neo</option>
<option value="Falcon">Falcon 500</option>
<option value="775Pro">775Pro</option>
<option value="MiniCIM">MiniCIM</option>
</select><br><br>
<label for="manipulator_A">Score Cubes? (Select Max Height)</label><br>
<select id="manipulator_A">
<option value="">???</option>
<option value="Top">Top Cubes</option>
<option value="Mid">Middle Cubes</option>
<option value="Bot">Bottom Cubes</option>
</select><br><br>
<label for="manipulator_B">Score Cones?</label><br>
<select id="manipulator_B">
<option value="">???</option>
<option value="Top">Top Cones</option>
<option value="Mid">Middle Cones</option>
<option value="Bot">Bottom Cones</option>
</select><br><br>
<label for="floor_pickup">Floor Pickup</label><br>
<select id="floor_pickup">
<option value="">???</option>
<option value="none">None</option>
<option value="cubes">Cubes Only</option>
<option value="cones">Cones Only</option>
<option value="both">Both</option>
</select><br><br>
<label for="climber">Autonomous Balancing</label><br>
<select id="climber">
<option value="">No (or ???)</option>
<option value="will_try">Intending to try</option>
<option value="auto_bal">Yes/tested/working</option>
<select><br><br>
<label for="auto_plan">Autonomous Game Piece Strategy</label><br>
<select id="auto_plan">
<option value="">???</option>
<option value="none">None</option>
<option value="Preload">Score Preload</option>
<option value="Multi">Score Multiple</option>
</select><br><br>
<label for="tele_plan">TeleOp Plan</label><br>
<select id="tele_plan">
<option value="">???</option>
<option value="cycle">Substation Loading</option>
<option value="floor">Floor Pickup from Middle</option>
<option value="bot">Hybrid (Bottom) scoring</option>
<option value="defense">Defense Only</option>
<select><br><br>
<label for="build_appearance">Build Appearance</label><br>
<select id="build_appearance" value = "build_average" name="build_appearance">
<option value="">Neutral</option>
<option value="build_concerns">Concerns Noted</option>
<option value="well_built">Well Built</option>
</select><br>
<br>
<label for="wiring_appearance">Wiring Appearance</label><br>
<select id="wiring_appearance" value = "wiring_average" name="wiring_appearance">
<option value="">Neutral</option>
<option value="wiring_concerns">Concerns Noted</option>
<option value="wiring_organized">Well Organized</option>
</select><br>
<h3>Comments</h3>
<textarea placeholder="Write Comments Here" name="comments" value="" id="comments" rows="7", cols="40"></textarea><br><br>
<input type="submit" id="submit" value="Submit" onclick="submitData()"></div>
<p class="status">Status info will be displayed here.</p>
</div>
<script>
function submitData(){
status("Starting Request");
var xhr = new XMLHttpRequest();
var params = '';
params += 'team=' + document.getElementById('team').value;
params += '&event_key=' + eventData['key'];
params += '&scout_name=' + document.getElementById('scout_name').value;
params += '&drive_type=' + document.getElementById('drive_type').value;
params += '&drive_motors=' + document.getElementById('drive_motors').value;
params += '&motors_type=' + document.getElementById('motors_type').value;
params += '&floor_pickup=' + document.getElementById('floor_pickup').value;
params += '&climber=' + document.getElementById('climber').value;
params += '&manipulator_A=' + document.getElementById('manipulator_A').value;
params += '&manipulator_B=' + document.getElementById('manipulator_B').value;
params += '&tele_plan=' + document.getElementById('tele_plan').value;
params += '&manipulator_A=' + document.getElementById('manipulator_A').value;
params += '&manipulator_B=' + document.getElementById('manipulator_B').value;
params += '&auto_plan=' + document.getElementById('auto_plan').value;
params += '&build_appearance=' + document.getElementById('build_appearance').value;
params += '&wiring_appearance=' + document.getElementById('wiring_appearance').value;
params += '&comments=' + document.getElementById('comments').value;
params += '&picture_filename=' + 'filename.jpg'; // functionality not implemented yet
xhr.onreadystatechange = function(){
if(this.readyState == 4 & this.status == 200){
document.getElementsByClassName('status')[0].innerHTML = this.responseText;
document.getElementsByClassName('status')[1].innerHTML = this.responseText;
}
}
xhr.open("POST", "insert_pit_record.php", true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send(encodeURI(params));
status("Sending Request...");
}
function status(text){
s = document.getElementsByClassName('status');
for (var i=0; i < s.length; i++){
s[i].innerHTML = text;
}
}
function updateTeams(arr){
var teamList = [];
for (i = 0; i < teamData.length; i++){
teamList.push({num: parseInt(teamData[i]["team_number"]),
nick: teamData[i]["nickname"]});
}
teamList.sort(function comp(a, b){return parseInt(a['num'])-parseInt(b['num'])});
var choices = '';
for(i = 0; i < teamList.length; i++){
var num = teamList[i]['num'];
var nick = teamList[i]['nick']
choices += '<option value="'+num+'">'+num+' - '+nick.substring(0,22)+'</option>\n';
}
document.getElementById('team').innerHTML = choices;
}
function lookupTeamData(){
status("Starting Request");
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if(this.readyState == 4 & this.status == 200){
if (xhr.responseText != 'null'){
status("Scouting data exists for team " + document.getElementById('team').value);
var data = JSON.parse(xhr.responseText);
document.getElementById('team').value = data['team'];
document.getElementById('scout_name').value = data['scout_name'];
document.getElementById('drive_type').value = data['drive_type'];
document.getElementById('motors_type').value = data['motors_type'];
document.getElementById('drive_motors').value = data['drive_motors'];
document.getElementById('floor_pickup').value = data['floor_pickup'];
document.getElementById('climber').value = data['climber'];
document.getElementById('manipulator_A').value = data['manipulator_A'];
document.getElementById('manipulator_B').value = data['manipulator_B'];
document.getElementById('auto_plan').value = data['auto_plan'];
document.getElementById('tele_plan').value = data['tele_plan'];
document.getElementById('build_appearance').value = data['build_appearance'];
document.getElementById('wiring_appearance').value = data['wiring_appearance'];
document.getElementById('comments').value = data['comments'];
}
else {
status("No data yet for team " + document.getElementById('team').value);
document.getElementById('scout_name').value = "";
document.getElementById('drive_type').value = "";
document.getElementById('drive_motors').value = 4;
document.getElementById('motors_type').value = "CIM";
document.getElementById('floor_pickup').value = "";
document.getElementById('climber').value = "";
document.getElementById('manipulator_A').value = "";
document.getElementById('manipulator_B').value = "";
document.getElementById('auto_plan').value = "";
document.getElementById('tele_plan').value = "";
document.getElementById('build_appearance').value = "";
document.getElementById('wiring_appearance').value = "";
document.getElementById('comments').value = "";
}
}
else{
status("Looking for team " + document.getElementById('team').value + " data...");
}
};
xhr.open('GET', 'get_pit.php?team=' + document.getElementById('team').value + '&event_key='+eventData['key']);
xhr.send();
}
document.addEventListener("DOMContentLoaded", function() {
//Document ready function
ctx = document.getElementById('canvas').getContext("2d");
updateTeams(teamData);
lookupTeamData();
lookupPicture();
document.getElementById('team').addEventListener("change", function(){
lookupTeamData();
lookupPicture();
// document.getElementById('robot_picture').src = "pics/"+document.getElementById('team').value+".jpg";
});
});
plus = document.getElementsByClassName('p1');
for (i=0; i<plus.length; i++){
var val_id = plus[i].id.substring(2);
plus[i].addEventListener("click",closure(val_id, 1));
}
minus = document.getElementsByClassName('m1');
for (i=0; i<minus.length; i++){
var val_id = minus[i].id.substring(2);
minus[i].addEventListener("click",closure(val_id, -1));
}
function closure(id, amt){
return function(){
if ( parseInt(document.getElementById(id).value) + amt >= 0){
document.getElementById(id).value = parseInt(document.getElementById(id).value) + amt;
}
}
}
function lookupPicture(){
var xhr = new XMLHttpRequest();
var params = 'team=' + document.getElementById('team').value;
console.log(params);
xhr.onreadystatechange = function(){
if(this.readyState == 4 & this.status == 200){
document.getElementById('robot_picture').src = xhr.responseText.trim();
//ctx draw
}
}
xhr.open("POST", "get_pic_name.php", true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send(encodeURI(params));
}
function previewPicture(){
var file = document.getElementById('fileToUpload').files[0];
if(file.type.match(/image.*/)) {
// var img = document.createElement("img");
// img.src = window.URL.createObjectURL(file);
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext("2d");
var img = document.createElement("img");
var reader = new FileReader();
reader.onload = function(e) {
img.onload = function(e){
var width = img.width;
var height = img.height;
var aspect = width/height;
console.log(width+"x"+height+", "+aspect);
var w = 300;
var h = Math.floor(300/aspect);
console.log(w +"x"+h)
canvas.width = 300;
canvas.height = h;
ctx.drawImage(img, 0, 0, w, h);
//create file to upload
};
img.src = e.target.result;
};
reader.readAsDataURL(file);
// var img_file = document.querySelector('#fileToUpload').files[0];
// var img = document.createElement("img");
// img.src = window.URL.createObjectURL(img_file);
// console.log(img.width+" x "+img.height);
}
}
var myBlob = false;
function uploadPicture(){
var dataURL = canvas.toDataURL();
var data = new FormData();
var xhr = new XMLHttpRequest();
xhr.open('POST', 'sendpic.php', true);
xhr.onload = function() {
// console.log(xhr.responseText);
canvas.height = 0;
lookupPicture();
};
canvas.toBlob(function(blob){
data.append('team', document.getElementById('team').value);
data.append('blob', blob);
myBlob = blob;
xhr.send(data);
},"image/jpg",0);
}
</script>
</body>
</html>