Upload code

This commit is contained in:
endie 2021-03-28 03:08:20 +00:00
parent 2dac33bb31
commit 72890d3213
3 changed files with 75 additions and 0 deletions

20
index.html Normal file
View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<title>
Blaseball Roster Sizes
</title>
</head>
<body>
<h1 id="progress">
Loading...
</h1>
<script src="main.js">
</script>
<noscript>
your browser is bad and doesn't support javascript, or you turned it off<br />
this website needs javascript to function<br />
please enable javascript, if you want you can check its not doing anything bad by looking at the source code<br />
if you have enabled it, refreshing the page should work
</noscript>
</body>

46
main.js Normal file
View file

@ -0,0 +1,46 @@
var request = new XMLHttpRequest()
request.open("GET", "https://cors-proxy.blaseball-reference.com/database/allTeams", true)
var progress = document.getElementById("progress")
var progressIndicator = progress.innerHTML
progressIndicator = "Sending request to Blaseball..."
request.send();
request.onload = function() {
progressIndicator = "Parsing data..."
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) {
return y - x
}
).filter(
function (item, pos, array) {
return !pos || item != array[pos - 1]
}
)
progressIndicator = "Displaying data..."
// Now make headers & lists for all the player counts
playercounts.forEach(function(item) {
document.body.insertAdjacentHTML("beforeend", "<h1>"
+ item
+ " players</h1><ul id='tlist"
+ item
+ "'></ul>")
})
// Put the teams in the lists
teams.forEach(function(item, pos) {
document.getElementById("tlist" + totals[pos]).insertAdjacentHTML("beforeend", "<li>"
+ item.fullName
+ " ("
+ item.lineup.length
+ " hitters, "
+ item.rotation.length
+ " pitchers)</li>")
})
progress.remove()
}

9
style.css Normal file
View file

@ -0,0 +1,9 @@
body {
background-color: #ddd;
color: #333;
text-align: center;
}
li {
list-style: decimal-leading-zero;
}