-
Notifications
You must be signed in to change notification settings - Fork 1
/
scoreEstimate.php
136 lines (122 loc) · 3.8 KB
/
scoreEstimate.php
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
<html>
<?php
include("header.php");
include("navBar.php");
?>
<?php
$blueEstimate = 0;
$redEstimate = 0;
function filter($str)
{
return filter_var($str, FILTER_SANITIZE_STRING);
}
if (
isset($_POST['team1Blue']) && isset($_POST['team2Blue']) && isset($_POST['team3Blue'])
&& isset($_POST['team1Red']) && isset($_POST['team2Red']) && isset($_POST['team3Red'])
) {
include("databaseLibrary.php");
$team1Blue = filter($_POST['team1Blue']);
$team2Blue = filter($_POST['team2Blue']);
$team3Blue = filter($_POST['team3Blue']);
$team1Red = filter($_POST['team1Red']);
$team2Red = filter($_POST['team2Red']);
$team3Red = filter($_POST['team3Red']);
$blue1Estimate = getAvgscore($team1Blue);
$blue2Estimate = getAvgscore($team2Blue);
$blue3Estimate = getAvgscore($team3Blue);
$red1Estimate = getAvgscore($team1Red);
$red2Estimate = getAvgscore($team2Red);
$red3Estimate = getAvgscore($team3Red);
$blueEstimate = $blue1Estimate + $blue2Estimate + $blue3Estimate;
$redEstimate = $red1Estimate + $red2Estimate + $red3Estimate;
$blueEstimate += getAvgPenalties($team1Red) + getAvgPenalties($team2Red) + getAvgPenalties($team3Red);
$redEstimate += getAvgPenalties($team1Blue) + getAvgPenalties($team2Blue) + getAvgPenalties($team3Blue);
}
?>
<body>
<div class="container row-offcanvas row-offcanvas-left">
<a>
<h3><b><u>Red Alliance:</u></b></h3>
</a>
<div class="well column col-lg-12 col-sm-12 col-xs-12" id="content">
<div class="row" style="text-align: center;">
<div class="col-md-2">
Team 1:
<input type="text" name="team1Red" id="team1Red" size="8" class="form-control">
</div>
<div class="col-md-2">
Team 2:
<input type="text" name="team2Red" id="team2Red" size="8" class="form-control">
</div>
<div class="col-md-2">
Team 3:
<input type="text" name="team3Red" id="team3Red" size="8" class="form-control">
</div>
</div>
</div>
</div>
<div class="container row-offcanvas row-offcanvas-left">
<a>
<h3><b><u>Blue Alliance:</u></b></h3>
</a>
<div class="well column col-lg-12 col-sm-12 col-xs-12" id="content">
<div class="row" style="text-align: center;">
<div class="col-md-2">
Team 1:
<input type="text" name="team1Blue" id="team1Blue" size="8" class="form-control">
</div>
<div class="col-md-2">
Team 2:
<input type="text" name="team2Blue" id="team2Blue" size="8" class="form-control">
</div>
<div class="col-md-2">
Team 3:
<input type="text" name="team3Blue" id="team3Blue" size="8" class="form-control">
</div>
</div>
</div>
<div class="col-md-4">
<br />
<button id="submit" class="btn btn-primary" onclick="postwith('');">Submit Data</button>
<br />
<h1 style="margin-left:5px;"> Red Score:<spam style="color:red"><?php echo ($redEstimate); ?></spam>
</h1>
<h1 style="margin-left:5px;">Blue Score:<spam style="color:blue"><?php echo ($blueEstimate); ?></spam>
</h1>
</div>
</div>
</body>
<script>
function postwith(to) {
var myForm = document.createElement("form");
myForm.method = "post";
myForm.action = to;
var names = [
'team1Blue',
'team2Blue',
'team3Blue',
'team1Red',
'team2Red',
'team3Red'
];
var nums = [
document.getElementById('team1Blue').value,
document.getElementById('team2Blue').value,
document.getElementById('team3Blue').value,
document.getElementById('team1Red').value,
document.getElementById('team2Red').value,
document.getElementById('team3Red').value
];
for (var i = 0; i != names.length; i++) {
var myInput = document.createElement("input");
myInput.setAttribute("name", names[i]);
myInput.setAttribute("value", nums[i]);
myForm.appendChild(myInput);
}
document.body.appendChild(myForm);
myForm.submit();
document.body.removeChild(myForm);
}
</script>
<?php include("footer.php"); ?>
</html>