-
Notifications
You must be signed in to change notification settings - Fork 0
/
SCVMidsets.html
402 lines (377 loc) · 14.9 KB
/
SCVMidsets.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style media="screen">
body {
background-color: #4D944D;
color: #003D00;
}
#header {
width: 100%;
height: 100px;
position: fixed;
top: 0;
left: 0;
background-color: #004700;
}
#data_entry {
width: 365px;
margin-top: 120px;
margin-left: 20px;
background-color: #FFFFF5;
padding-top: 0;
padding: 10px;
border-radius: 20px;
}
#results {
position:relative;
float:left;
left: 450px;
bottom: 325px;
width: 365px;
background-color: #FFFFF5;
border-radius: 20px;
padding: 20px;
display: none;
}
</style>
</head>
<body>
<div id="header"></div>
<div id="data_entry">
<div class="starting_point">
<h3>Starting point:</h3>
<p><input type="text" id='start_LRstepsAway' style='width:15px' name="LRstepsAway" value=""> steps
<select id="start_inside_outside">
<option value="inside">inside</option>
<option value="outside">outside</option>
</select> the <input type="text" id='start_yard_line' style='width:15px' name="yard_line" value=""> yard line on
<select id="start_side">
<option value="side1">Side 1</option>
<option value="side2">Side 2</option>
</select>
</p>
<p><input type="text" id='start_FBstepsAway' style='width:15px' name="FBstepsAway" value=""> steps
<select id="start_inFront_Behind">
<option value="in_front">in front of</option>
<option value="behind">behind</option>
</select> the
<select id="start_FB_marker">
<option value="FH">front hash</option>
<option value="BH">back hash</option>
<option value="FSL">front side line</option>
<option value="BSL">back side line</option>
</select>
</p>
</div>
<div class="ending_point">
<h3>Ending point:</h3>
<p><input type="text" id='end_LRstepsAway' style='width:15px' name="LRstepsAway" value=""> steps
<select id="end_inside_outside">
<option value="inside">inside</option>
<option value="outside">outside</option>
</select> the <input type="text" id='end_yard_line' style='width:15px' name="yard_line" value=""> yard line on
<select id="end_side">
<option value="side1">Side 1</option>
<option value="side2">Side 2</option>
</select>
</p>
<p><input type="text" id='end_FBstepsAway' style='width:15px' name="FBstepsAway" value=""> steps
<select id="end_inFront_Behind">
<option value="in_front">in front of</option>
<option value="behind">behind</option>
</select> the
<select id="end_FB_marker">
<option value="FH">front hash</option>
<option value="BH">back hash</option>
<option value="FSL">front side line</option>
<option value="BSL">back side line</option>
</select>
</p>
</div>
<div class="counts">
<h3>Counts: <input type="text" id="counts" style='width:15px' name="counts" value=""></h3>
</div>
<div class="button">
<input type="button" id="calc" name="name" value="Calculate Midsets">
</div>
</div>
<div id="results">
</div>
<script src="https://code.jquery.com/jquery-2.1.1.js"></script>
<script type="text/javascript">
var LRCoordinateToSteps = function(steps, insideOutside, yard_line, side) {
var LRcoordinateArray = [];
steps = Number(steps)
yard_line = Number(yard_line);
if (side === 'side2') {
yard_line = 100 - yard_line
}
var LRinSteps = yard_line * 1.6;
if (yard_line < 50) {
if (insideOutside === 'inside') {
LRinSteps += steps;
} else if (insideOutside === 'outside') {
LRinSteps -= steps;
}
} else if (yard_line > 50) {
if (insideOutside === 'inside') {
LRinSteps -= steps;
} else if (insideOutside === 'outside') {
LRinSteps += steps;
}
}
LRcoordinateArray.push(steps,insideOutside,yard_line);
console.log(LRcoordinateArray)
return LRinSteps
}
// var parseLRCoordinate = function(LRcoordinate) {
// LRcoordinate = LRcoordinate.toLowerCase().split(' ');
// var LRcoordinateArray = [];
//
// if (LRcoordinate.length > 6) {
// if (LRcoordinate[0] !== 'side') {
// stepsAway = Number(LRcoordinate[1]);
// insideOutside = LRcoordinate[3];
// sideOfField = LRcoordinate[0];
// if (sideOfField === 'right:') {
// yardLine = 100 - Number(LRcoordinate[4])
// } else {
// yardLine = Number(LRcoordinate[4]);
// }
// } else {
// stepsAway = Number(LRcoordinate[2]);
// insideOutside = LRcoordinate[4];
// sideOfField = LRcoordinate[1];
// if (sideOfField === '2:') {
// yardLine = 100 - Number(LRcoordinate[5])
// } else {
// yardLine = Number(LRcoordinate[5]);
// }
// }
// } else if (LRcoordinate.length > 4) {
// if (LRcoordinate[0] !== 'side') {
// stepsAway = 0;
// insideOutside = 0;
// sideOfField = LRcoordinate[0];
// if (sideOfField === 'right:') {
// yardLine = 100 - Number(LRcoordinate[2])
// } else {
// yardLine = Number(LRcoordinate[2]);
// }
// } else {
// stepsAway = 0;
// insideOutside = 0;
// sideOfField = LRcoordinate[1];
// if (sideOfField === '2:') {
// yardLine = 100 - Number(LRcoordinate[3])
// } else {
// yardLine = Number(LRcoordinate[3]);
// }
// }
// } else {
// stepsAway = 0;
// insideOutside = 0;
// yardLine = 50;
// }
//
// var LRinSteps = yardLine * 1.6;
// if (yardLine < 50) {
// if (insideOutside === 'inside') {
// LRinSteps += stepsAway;
// } else if (insideOutside === 'outside') {
// LRinSteps -= stepsAway;
// }
// } else if (yardLine > 50) {
// if (insideOutside === 'inside') {
// LRinSteps -= stepsAway;
// } else if (insideOutside === 'outside') {
// LRinSteps += stepsAway;
// }
// }
// LRcoordinateArray.push(stepsAway,insideOutside,yardLine);
// console.log(LRcoordinateArray)
// return LRinSteps
// }
var FBCoordinateToSteps = function(inFrontBehind, fbMarker, steps) {
var FBinSteps;
if (steps === '' || steps === 0) {
if (fbMarker === 'FSL') {
FBinSteps = 0;
} else if (fbMarker === 'BSL') {
FBinSteps = 84;
} else if (fbMarker === 'FH') {
FBinSteps = 32;
} else if (fbMarker === 'BH') {
FBinSteps = 52;
}
} else {
steps = Number(steps);
if (fbMarker === 'FSL') {
if (inFrontBehind === 'in_front') {
FBinSteps = -steps;
} else if (inFrontBehind === 'behind') {
FBinSteps = steps;
}
} else if (fbMarker === 'BSL') {
if (inFrontBehind === 'in_front') {
FBinSteps = 84 - steps;
} else if (inFrontBehind === 'behind') {
FBinSteps = 84 + steps;
}
} else if (fbMarker === 'FH') {
if (inFrontBehind === 'in_front') {
FBinSteps = 32 - steps;
} else if (inFrontBehind === 'behind') {
FBinSteps = 32 + steps;
}
} else if (fbMarker === 'BH') {
if (inFrontBehind === 'in_front') {
FBinSteps = 52 - steps;
} else if (inFrontBehind === 'behind') {
FBinSteps = 52 + steps;
}
}
}
return FBinSteps;
}
// var parseFBCoordinate = function(FBcoordinate) {
// FBcoordinate = FBcoordinate.toLowerCase().split(' ');
// console.log(FBcoordinate);
// var FBinSteps;
//
// if (FBcoordinate[0] === 'on') {
// if (FBcoordinate[2] === 'side' && FBcoordinate[1] === 'front') {
// FBinSteps = 0;
// } else if (FBcoordinate[2] === 'side' && FBcoordinate[1] === 'back') {
// FBinSteps = 84;
// } else if (FBcoordinate[2] === 'hash' && FBcoordinate[1] === 'front') {
// FBinSteps = 32;
// } else if (FBcoordinate[2] === 'hash' && FBcoordinate[1] === 'back') {
// FBinSteps = 52;
// }
// } else {
// if (FBcoordinate[2] === 'behind' && FBcoordinate[4] === 'side') {
// if (FBcoordinate[3] === 'front') {
// FBinSteps = Number(FBcoordinate[0]);
// } else if (FBcoordinate[3] === 'back') {
// FBinSteps = 84 + Number(FBcoordinate[0]);
// }
// } else if (FBcoordinate[2] === 'behind' && FBcoordinate[4] === 'hash') {
// if (FBcoordinate[3] === 'front') {
// FBinSteps = 32 + Number(FBcoordinate[0]);
// } else if (FBcoordinate[3] === 'back') {
// FBinSteps = 52 + Number(FBcoordinate[0]);
// }
// } else if (FBcoordinate[3] === 'frnt' && FBcoordinate[6] === 'side') {
// if (FBcoordinate[5] === 'front') {
// FBinSteps = 0 - Number(FBcoordinate[0]);
// } else if (FBcoordinate[5] === 'back') {
// FBinSteps = 84 - Number(FBcoordinate[0]);
// }
// } else if (FBcoordinate[3] === 'frnt' && FBcoordinate[6] === 'hash') {
// if (FBcoordinate[5] === 'front') {
// FBinSteps = 32 - Number(FBcoordinate[0]);
// } else if (FBcoordinate[5] === 'back') {
// FBinSteps = 52 - Number(FBcoordinate[0]);
// }
// }
// }
// return FBinSteps;
// }
var calculateWrittenCoord = function(LRcoordInSteps, FBcoordInSteps) {
var yardLine = Math.floor((LRcoordInSteps * 5)/ 8);
yardLine = Math.floor(yardLine / 5) * 5
var stepsLeft = LRcoordInSteps % 8;
var LRreturn = "";
var FBreturn = "";
if (yardLine >= 50) {
if (stepsLeft > 4) {
yardLine = yardLine + 5;
yardLine = 100 - yardLine;
stepsLeft = 8 - stepsLeft;
LRreturn += 'Side 2: ' + stepsLeft + ' stp' + (stepsLeft === 1 ? '' : 's') + ' inside the ' + yardLine + ' yd ln';
} else if (stepsLeft > 0) {
LRreturn += 'Side 2: ' + stepsLeft + ' stp' + (stepsLeft === 1 ? '' : 's') + ' outside the ' + yardLine + ' yd ln';
} else {
LRreturn += 'Side 2: on the ' + yardLine + ' yd ln';
}
} else {
if (stepsLeft > 4) {
yardLine = yardLine + 5;
stepsLeft = 8 - stepsLeft;
LRreturn += 'Side 1: ' + stepsLeft + ' stp' + (stepsLeft === 1 ? '' : 's') + ' outsie the ' + yardLine + ' yd ln';
} else if (stepsLeft > 0) {
LRreturn += 'Side 1: ' + stepsLeft + ' stp' + (stepsLeft === 1 ? '' : 's') + ' inside the ' + yardLine + ' yd ln';
} else {
LRreturn += 'Side 1: on the ' + yardLine + ' yd ln';
}
} if (FBcoordInSteps === 0) {
FBreturn += 'on Front side line'
} else if (FBcoordInSteps === 32) {
FBreturn += 'on Front hash (NCAA)'
} else if (FBcoordInSteps === 52) {
FBreturn += 'on Back hash (NCAA)'
} else if (FBcoordInSteps === 84) {
FBreturn += 'on Back side line'
} else if (FBcoordInSteps < 0) {
FBcoordInSteps = 0 - FBcoordInSteps;
FBreturn += FBcoordInSteps + ' stp' + (FBcoordInSteps === 1 ? '' : 's') + ' in front of Front side line'
} else if (FBcoordInSteps <= 16) {
FBreturn += FBcoordInSteps + ' stp' + (FBcoordInSteps === 1 ? '' : 's') + ' behind Front side line'
} else if (FBcoordInSteps < 32) {
FBcoordInSteps = 32 - FBcoordInSteps
FBreturn += FBcoordInSteps + ' stp' + (FBcoordInSteps === 1 ? '' : 's') + ' in front of Front hash'
} else if (FBcoordInSteps <= 42) {
FBcoordInSteps -= 32
FBreturn += FBcoordInSteps + ' stp' + (FBcoordInSteps === 1 ? '' : 's') + ' behind Front hash'
} else if (FBcoordInSteps < 52) {
FBcoordInSteps = 52 - FBcoordInSteps
FBreturn += FBcoordInSteps + ' stp' + (FBcoordInSteps === 1 ? '' : 's') + ' in front of Back hash'
} else if (FBcoordInSteps <= 68) {
FBcoordInSteps -= 52
FBreturn += FBcoordInSteps + ' stp' + (FBcoordInSteps === 1 ? '' : 's') + ' behind Back hash'
} else if (FBcoordInSteps < 84) {
FBcoordInSteps = 84 - FBcoordInSteps
FBreturn += FBcoordInSteps + ' stp' + (FBcoordInSteps === 1 ? '' : 's') + ' in front of Back side line'
} else if (FBcoordInSteps > 84) {
FBcoordInSteps -= 84
FBreturn += FBcoordInSteps + ' stp' + (FBcoordInSteps === 1 ? '' : 's') + ' beind Back side line'
}
return LRreturn + "\n" + FBreturn
}
var calclateMidset = function (startingLR, startingFB, endingLR, endingFB, counts) {
// startingLR = parseLRCoordinate(startingLR);
// startingFB = parseFBCoordinate(startingFB);
// endingLR = parseLRCoordinate(endingLR);
// endingFB = parseFBCoordinate(endingFB);
var changeInLR = endingLR - startingLR;
var changeInFB = endingFB - startingFB;
var midSetChangeLR = changeInLR / 2;
var quarSetChangeLR = changeInLR / 4;
var midSetChangeFB = changeInFB / 2;
var quarSetChangeFB = changeInFB / 4;
var midSetLR = startingLR + midSetChangeLR;
var midSetFB = startingFB + midSetChangeFB;
var quarSetLR1 = startingLR + quarSetChangeLR;
var quarSetFB1 = startingFB + quarSetChangeFB;
var quarSetLR2 = startingLR + (quarSetChangeLR * 3);
var quarSetFB2 = startingFB + (quarSetChangeFB * 3);
$('#results').empty()
$('#results').append($('<p>').html('<h4>On count ' + (counts / 4) + ':</h4>' + calculateWrittenCoord(quarSetLR1,quarSetFB1)));
$('#results').append($('<p>').html('<h4>On count ' + (counts / 2) + ':</h4>' + calculateWrittenCoord(midSetLR,midSetFB)));
$('#results').append($('<p>').html('<h4>On count ' + (counts * 3 / 4) + ':</h4>' + calculateWrittenCoord(quarSetLR2,quarSetFB2)));
$('#results').show()
}
$('#calc').on('click', function(){
var startingLR = LRCoordinateToSteps($('#start_LRstepsAway').val(), $('#start_inside_outside').val(),$('#start_yard_line').val(),$('#start_side').val());
var endingLR = LRCoordinateToSteps($('#end_LRstepsAway').val(), $('#end_inside_outside').val(),$('#end_yard_line').val(),$('#end_side').val());
var startingFB = FBCoordinateToSteps($('#start_inFront_Behind').val(), $('#start_FB_marker').val(), $('#start_FBstepsAway').val());
var endingFB = FBCoordinateToSteps($('#end_inFront_Behind').val(), $('#end_FB_marker').val(), $('#end_FBstepsAway').val());
calclateMidset(startingLR, startingFB, endingLR, endingFB,$('#counts').val())
})
</script>
</body>
</html>