-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathversus.js
48 lines (41 loc) · 1.19 KB
/
versus.js
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
// thanks https://stackoverflow.com/a/35970894
let getJSON = function(url, callback) {
let xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'json';
xhr.onload = function() {
let status = xhr.status;
if (status === 200) {
callback(null, xhr.response);
} else {
callback(status, xhr.response);
}
};
xhr.send();
};
function loadData() {
getJSON('./sheet.json.php',
function(err, results) {
if (err !== null) {
console.log('Something went wrong fetching player JSON: ' + err);
} else {
const vbp1 = document.getElementById('vp1');
const vbp2 = document.getElementById('vp2');
vbp1.innerHTML = '';
vbp2.innerHTML = '';
var slot = 0;
for(const count in results.data){
const person = results.data[count];
if (person.vstate > 0) {
if (slot == 0) {
vbp1.innerHTML = person.name;
slot = 1 ;
} else {
vbp2.innerHTML = person.name;
return;
}
}
}
}
});
}