-
Notifications
You must be signed in to change notification settings - Fork 0
/
leadScoutData.php
100 lines (83 loc) · 2.51 KB
/
leadScoutData.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
<title>Lead Scout 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">Match</th>
<th scope="col">Rank 1</th>
<th scope="col">Rank 2</th>
<th scope="col">Rank 3</th>
<th scope="col">Rank 5</th>
<th scope="col">Rank 5</th>
<th scope="col">Rank 6</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['matchNum']}</th>`,
` <td>${rowData['team1']}</td>`,
` <td>${rowData['team2']}</td>`,
` <td>${rowData['team3']}</td>`,
` <td>${rowData['team4']}</td>`,
` <td>${rowData['team5']}</td>`,
` <td>${rowData['team6']}</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", {
"readAllLSData": 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>