-
Notifications
You must be signed in to change notification settings - Fork 20
/
rate-pit.html
159 lines (133 loc) · 5.97 KB
/
rate-pit.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
---
layout: page
title: Rate a Team
permalink: /rate-pit/
---
<div class="container">
<div class="row">
<div class="col-md-12">
<form id="reportForm" class="form-horizontal">
<fieldset>
<div class="scouting-report">Pit Report</div>
<div class="row">
<div class="col-md-5">
<div class="form-group">
<label class="col-md-4 control-label" for="teams">Team to Rate:</label>
<div class="col-md-8">
<select id="teams" name="team_id" class="form-control">
</select>
</div>
</div>
</div>
</div>
<div class="col-md-12 panel panel-default">Overall Robot:</div>
<div class="row">
<div class="form-group">
<label class="col-md-2 control-label" for="pit_rating_drive_train">Drive Train:</label>
<select class="scouting-report" name="pit_rating_drive_train">
<option name="pit_rating_drive_train" id="pit_rating_drive_train_tank_drive" value="Tank Drive">Tank Drive</option>
<option name="pit_rating_drive_train" id="pit_rating_drive_train_omni_drive" value="Omni Drive">Omni Drive</option>
<option name="pit_rating_drive_train" id="pit_rating_drive_train_mecanum_drive" value="Mecanum Drive">Mecanum Drive</option>
<option name="pit_rating_drive_train" id="pit_rating_drive_train_swerve_drive" value="Swerve rive">Swerve Drive</option>
</select>
</div>
<hr class="divider-hor" style="width:750px">
<div class="form-group">
<label class="col-md-2 control-label" for="pit_rating_weight">Weight:</label>
<input class="form-control js-counter-textbox" style="display:inline-block;width:70px;" type="number" name="pit_rating_weight" value="0" />
</div>
</div>
<div class="col-md-12 panel panel-default">Elevator:</div>
<div class="form-group">
<label class="col-md-2 control-label" for="pit_rating_elevator_height">Max Height(feet):</label>
<input class="form-control js-counter-textbox" style="display:inline-block;width:70px;" type="number" name="pit_rating_elevator_height" value="0" />
</div>
<div class="col-md-12 panel panel-default">Autonomous:</div>
<div class="form-group">
<label class="col-md-2 control-label" for="pit_rating_cross_base_line">Cross Base Line:</label>
<div class="col-md-2" style="text-align: right;right:50px">
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary">
<input type="radio" name="pit_rating_cross_base_line" id="pit_rating_cross_base_line_1"
value="1" autocomplete="off">Yes</label>
<label class="btn btn-primary active">
<input type="radio" name="pit_rating_cross_base_line" id="pit_rating_cross_base_line_0"
value="0" autocomplete="off" checked="checked">No</label>
</div>
</div>
</div>
<div class="col-md-12 panel panel-default">Notes:</div>
<div class="form-group">
<label class="col-md-2 control-label" for="pit_rating_notes">Notes:</label>
<textarea name="pit_rating_notes" style="width:500px;height:150px;"></textarea>
</div>
</fieldset>
<div class="col-md-6">
<button id="submit" type="button" class="btn btn-primary btn-lg">Submit Scouting Report</button>
<span id="error" class="help-block" style="color:red;font-weight:bold;"></span>
</div>
</form>
</div>
</div>
</div>
<script>
$(function () {
// add new user scouting report
$("#submit").on("click", function (ev) {
ev.preventDefault();
$('.loaderImage').show();
// map from data into json object
var data = {};
$.each($('#reportForm').serializeArray(), function (k, v) {
data[v.name] = v.value;
});
var match_key = AppUtility.getUrlParameter('match_key');
if (match_key) data['match_key'] = match_key;
//console.log(data);
// add scouting report
ParadoxScout.addPitReport(data, function (error) {
$('.loaderImage').hide();
if (error) {
AppUtility.showErrorMsg("An error occurred!", error);
}
else {
AppUtility.showSuccessMsg("Scouting Report Saved!", '', function () {
setTimeout("location.href = '" + siteUrl + "/pit-reports'", 3000);
});
}
});
});
// *** onload ***
// 1. build teams dropdown
$('.loaderImage').show();
ParadoxScout.buildTeamsDropdown($('#teams'), null, function (error) {
$('.loaderImage').hide();
if (error) {
AppUtility.showErrorMsg("An error occurred!", error);
}
else {
// if a team key is included in querystring, select that team
var selectedTeamKey = AppUtility.getUrlParameter('team_id');
if (selectedTeamKey && $("#teams option[value='" + selectedTeamKey + "']").length > 0) {
$('#teams').val(selectedTeamKey);
}
}
});
// 3. ensure counters are >= 0
$('.js-counter-textbox').on('change', function (ev) {
$(this).val(Math.max(parseFloat($(this).val()), 0) || 0)
});
// 2. add in increments of 5
$(".js-counter-btn").on("click", function (ev) {
var input = $("input[name=" + $(this).data('counter-for') + "]");
var currentVal = parseFloat(input.val());
input.val(Math.max((currentVal + 5), 0) || 0);
});
// 3. add in increments of 1
$(".js-counter-btn-1").on("click", function (ev) {
var input = $("input[name=" + $(this).data('counter-for') + "]");
var currentVal = parseFloat(input.val());
input.val(Math.max((currentVal + 1), 0) || 0);
});
});
</script>