Change formatting
This commit is contained in:
parent
8cba1e3a3c
commit
3932f996dc
1 changed files with 23 additions and 22 deletions
21
main.js
21
main.js
|
@ -1,24 +1,24 @@
|
|||
var request = new XMLHttpRequest()
|
||||
request.open("GET", "https://cors-proxy.blaseball-reference.com/database/allTeams", true)
|
||||
request.open(
|
||||
"GET",
|
||||
"https://cors-proxy.blaseball-reference.com/database/allTeams",
|
||||
true)
|
||||
request.send();
|
||||
|
||||
request.onload = function() {
|
||||
var teams = JSON.parse(this.response)
|
||||
var totals = teams.map(team => team.lineup.length + team.rotation.length)
|
||||
// Get all player counts that there are from greatest to least
|
||||
var playercounts = totals.slice().sort(
|
||||
function (x, y) {
|
||||
var playercounts = totals.slice().sort(function (x, y) {
|
||||
return y - x
|
||||
}
|
||||
).filter(
|
||||
function (item, pos, array) {
|
||||
}).filter(function (item, pos, array) {
|
||||
return !pos || item != array[pos - 1]
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
// Now make headers & lists for all the player counts
|
||||
playercounts.forEach(function(item) {
|
||||
document.body.insertAdjacentHTML("beforeend", "<h1>"
|
||||
document.body.insertAdjacentHTML("beforeend",
|
||||
"<h1>"
|
||||
+ item
|
||||
+ " players</h1><ul id='tlist"
|
||||
+ item
|
||||
|
@ -26,7 +26,8 @@ request.onload = function() {
|
|||
})
|
||||
// Put the teams in the lists
|
||||
teams.forEach(function(item, pos) {
|
||||
document.getElementById("tlist" + totals[pos]).insertAdjacentHTML("beforeend", "<li>"
|
||||
document.getElementById("tlist" + totals[pos]).insertAdjacentHTML("beforeend",
|
||||
"<li>"
|
||||
+ item.fullName
|
||||
+ " ("
|
||||
+ item.lineup.length
|
||||
|
|
Loading…
Reference in a new issue