From 72890d3213ee83390652bd72346d9c5cdca698b8 Mon Sep 17 00:00:00 2001 From: endie Date: Sun, 28 Mar 2021 03:08:20 +0000 Subject: [PATCH] Upload code --- index.html | 20 ++++++++++++++++++++ main.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ style.css | 9 +++++++++ 3 files changed, 75 insertions(+) create mode 100644 index.html create mode 100644 main.js create mode 100644 style.css diff --git a/index.html b/index.html new file mode 100644 index 0000000..cbab511 --- /dev/null +++ b/index.html @@ -0,0 +1,20 @@ + + + + + Blaseball Roster Sizes + + + +

+ Loading... +

+ + + diff --git a/main.js b/main.js new file mode 100644 index 0000000..45886e3 --- /dev/null +++ b/main.js @@ -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", "

" + + item + + " players

") + }) + // Put the teams in the lists + teams.forEach(function(item, pos) { + document.getElementById("tlist" + totals[pos]).insertAdjacentHTML("beforeend", "
  • " + + item.fullName + + " (" + + item.lineup.length + + " hitters, " + + item.rotation.length + + " pitchers)
  • ") + }) + + progress.remove() +} diff --git a/style.css b/style.css new file mode 100644 index 0000000..ab25313 --- /dev/null +++ b/style.css @@ -0,0 +1,9 @@ +body { + background-color: #ddd; + color: #333; + text-align: center; +} + +li { + list-style: decimal-leading-zero; +}