Improve code
This commit is contained in:
parent
8b8a5a0f2e
commit
d37c2c45e6
1 changed files with 15 additions and 11 deletions
26
main.js
26
main.js
|
@ -1,3 +1,5 @@
|
||||||
|
"use strict"
|
||||||
|
|
||||||
let request = new XMLHttpRequest()
|
let request = new XMLHttpRequest()
|
||||||
request.open(
|
request.open(
|
||||||
"GET",
|
"GET",
|
||||||
|
@ -34,21 +36,23 @@ request.onload = function() {
|
||||||
)
|
)
|
||||||
|
|
||||||
// Set the toggle function for & display the checkbox
|
// Set the toggle function for & display the checkbox
|
||||||
shadows.oninput = shadows_on = function() {
|
shadows.oninput = checkbox_toggle
|
||||||
results_shadowed.style.display = "block"
|
|
||||||
results.style.display = "none"
|
|
||||||
// Toggle off function
|
|
||||||
shadows.oninput = function() {
|
|
||||||
results.style.display = "block"
|
|
||||||
results_shadowed.style.display = "none"
|
|
||||||
shadows.oninput = shadows_on
|
|
||||||
}
|
|
||||||
}
|
|
||||||
shadows.style.display = "block"
|
shadows.style.display = "block"
|
||||||
|
|
||||||
document.getElementById("progress").remove()
|
document.getElementById("progress").remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkbox_toggle() {
|
||||||
|
results_shadowed.style.display = "block"
|
||||||
|
results.style.display = "none"
|
||||||
|
// Toggle off function
|
||||||
|
shadows.oninput = function() {
|
||||||
|
results.style.display = "block"
|
||||||
|
results_shadowed.style.display = "none"
|
||||||
|
shadows.oninput = checkbox_toggle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function display_teams(totals, teams, div_container, hitters_fn, pitchers_fn) {
|
function display_teams(totals, teams, div_container, hitters_fn, pitchers_fn) {
|
||||||
const ENDING = x => (Math.abs(x) === 1 ? "" : "s")
|
const ENDING = x => (Math.abs(x) === 1 ? "" : "s")
|
||||||
// Make the headers & lists for teams
|
// Make the headers & lists for teams
|
||||||
|
@ -58,7 +62,7 @@ function display_teams(totals, teams, div_container, hitters_fn, pitchers_fn) {
|
||||||
div_container.insertAdjacentHTML("afterbegin",
|
div_container.insertAdjacentHTML("afterbegin",
|
||||||
`<h1>${total} player${ENDING(total)}</h1>
|
`<h1>${total} player${ENDING(total)}</h1>
|
||||||
<ul id="${div_container.id}_tlist${total}"></ul>`)
|
<ul id="${div_container.id}_tlist${total}"></ul>`)
|
||||||
})
|
})
|
||||||
// Put the teams in the lists
|
// Put the teams in the lists
|
||||||
teams.forEach(function(team, pos) {
|
teams.forEach(function(team, pos) {
|
||||||
let hitters = hitters_fn(team)
|
let hitters = hitters_fn(team)
|
||||||
|
|
Loading…
Reference in a new issue