-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtableMatchData.php
126 lines (109 loc) · 4.14 KB
/
tableMatchData.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
<title>Match Data</title>
<html lang="en">
<?php include('navbar.php'); ?>
<body class="bg-body">
<div class="container row-offcanvas row-offcanvas-left">
<div class="well column col-lg-12 col-sm-12 col-xs-12" id="content">
<div class="row pt-3 pb-3 mb-3">
<!-- Left column -->
<div class="col-lg-12 col-sm-12 col-xs-12 gx-3">
<div class="card">
<div class="card-body">
<div class="table-responsive">
<table id='datatable' class="table table-striped-columns table-hover sortable">
<thead>
<tr>
<th scope="col">Team</th>
<th scope="col">Match</th>
<th scope="col">Scout</th>
<th scope="col">Auto Mobility</th>
<th scope="col">Auto Cone Level 1</th>
<th scope="col">Auto Cone Level 2</th>
<th scope="col">Auto Cone Level 3</th>
<th scope="col">Auto Cube Level 1</th>
<th scope="col">Auto Cube Level 2</th>
<th scope="col">Auto Cube Level 3</th>
<th scope="col">Auto Charge Station</th>
<th scope="col">Teleop Cone Level 1</th>
<th scope="col">Teleop Cone Level 2</th>
<th scope="col">Teleop Cone Level 3</th>
<th scope="col">Teleop Cube Level 1</th>
<th scope="col">Teleop Cube Level 2</th>
<th scope="col">Teleop Cube Level 3</th>
<th scope="col">Teleop Charge Station</th>
<th scope="col">Canned Comments</th>
<th scope="col">Additional Comments</th>
</tr>
</thead>
<tbody id='tableBody'>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<?php include("footer.php"); ?>
<script>
function createRow(rowData){
/*Create HTML row for data.
Args:
rowData: Dictionary of keys and values needed for row.
Returns:
HTML row for table.
*/
var list_row = [`<tr>`,
` <th scope="row">${rowData['teamNumber']}</th>`,
` <td>${rowData['matchNumber']}</td>`,
` <td>${rowData['scout']}</td>`,
` <td>${rowData['autoMobility']}</td>`,
` <td>${rowData['autoConeLevel1']}</td>`,
` <td>${rowData['autoConeLevel2']}</td>`,
` <td>${rowData['autoConeLevel3']}</td>`,
` <td>${rowData['autoCubeLevel1']}</td>`,
` <td>${rowData['autoCubeLevel2']}</td>`,
` <td>${rowData['autoCubeLevel3']}</td>`,
` <td>${rowData['autoChargeStation']}</td>`,
` <td>${rowData['teleopConeLevel1']}</td>`,
` <td>${rowData['teleopConeLevel2']}</td>`,
` <td>${rowData['teleopConeLevel3']}</td>`,
` <td>${rowData['teleopCubeLevel1']}</td>`,
` <td>${rowData['teleopCubeLevel2']}</td>`,
` <td>${rowData['teleopCubeLevel3']}</td>`,
` <td>${rowData['teleopChargeStation']}</td>`,
` <td>${rowData['cannedComments']}</td>`,
` <td>${rowData['textComments']}</td>`,
`</tr>`];
return list_row.join('')
}
function updateTable(data){
/*Update table from API.
Args:
List of dictionaries of rows.
*/
$('#tableBody').empty();
for(var i = 0; i < data.length; ++i){
var currentRow = data[i];
$('#tableBody').append(createRow(currentRow));
}
}
function loadData(){
/* Loads data and populates table. */
$.post("readAPI.php", {
"readAllMatchData": true
}, function(data) {
data = JSON.parse(data);
console.log(data);
updateTable(data);
var newTableObject = document.getElementById('datatable');
sorttable.makeSortable(newTableObject);
});
}
$(document).ready(function() {
loadData();
});
</script>
</html>