From 6e190dd3d8e9ff50419a08a6801d8d7b24ebefaa Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Wed, 10 May 2023 20:41:01 +0200 Subject: [PATCH] Change pulls to defense in the viewer. --- ultimate.js | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/ultimate.js b/ultimate.js index e4b0928..4ccb9d5 100644 --- a/ultimate.js +++ b/ultimate.js @@ -195,17 +195,17 @@ function process_matches(json) { rows = make_table_general(players); } else if (chosen_category === 'offense') { rows = make_table_offense(players); - } else if (chosen_category === 'pulls') { - rows = make_table_pulls(players); + } else if (chosen_category === 'defense') { + rows = make_table_defense(players); } document.getElementById('stats').replaceChildren(...rows); } function get_chosen_category() { - if (window.location.hash === '#pulls') { - return 'pulls'; - } else if (window.location.hash === '#offense') { + if (window.location.hash === '#offense') { return 'offense'; + } else if (window.location.hash === '#defense') { + return 'defense'; } else { return 'general'; } @@ -223,22 +223,22 @@ function write_main_menu(chosen_category) { } elems.push(document.createTextNode(' | ')); - if (chosen_category === 'pulls') { - elems.push(document.createTextNode('Pulls')); + if (chosen_category === 'offense') { + elems.push(document.createTextNode('Offense')); } else { let a = document.createElement('a'); - a.appendChild(document.createTextNode('Pulls')); - a.setAttribute('href', '#pulls'); + a.appendChild(document.createTextNode('Offense')); + a.setAttribute('href', '#offense'); elems.push(a); } elems.push(document.createTextNode(' | ')); - if (chosen_category === 'offense') { - elems.push(document.createTextNode('Offense')); + if (chosen_category === 'defense') { + elems.push(document.createTextNode('Defense')); } else { let a = document.createElement('a'); - a.appendChild(document.createTextNode('Offense')); - a.setAttribute('href', '#offense'); + a.appendChild(document.createTextNode('Defense')); + a.setAttribute('href', '#defense'); elems.push(a); } @@ -312,20 +312,19 @@ function make_table_offense(players) { return rows; } -function make_table_pulls(players) { +function make_table_defense(players) { let rows = []; { let header = document.createElement('tr'); add_cell(header, 'th', 'Player'); + add_cell(header, 'th', 'Ds'); add_cell(header, 'th', 'Pulls'); add_cell(header, 'th', 'OOB pulls'); add_cell(header, 'th', 'Avg. hang time (IB)'); + add_cell(header, 'th', 'Soft +/-'); rows.push(header); } for (const [q,p] of Object.entries(players)) { - if (p.pulls === 0) { - continue; - } let sum_time = 0; for (const t of p.pull_times) { sum_time += t; @@ -335,13 +334,20 @@ function make_table_pulls(players) { let row = document.createElement('tr'); add_cell(row, 'td', p.name); // TODO: number? + add_cell(row, 'td', p.defenses); add_cell(row, 'td', p.pulls); - add_cell(row, 'td', p.oob_pulls + ' (' + oob_pct.toFixed(0) + '%)'); + if (p.pulls === 0) { + add_cell(row, 'td', 'N/A'); + } else { + add_cell(row, 'td', p.oob_pulls + ' (' + oob_pct.toFixed(0) + '%)'); + } if (p.pulls > p.oob_pulls) { add_cell(row, 'td', avg_time.toFixed(1) + ' sec'); } else { add_cell(row, 'td', 'N/A'); } + add_cell(row, 'td', '+' + p.defensive_soft_plus); + add_cell(row, 'td', '-' + p.defensive_soft_minus); rows.push(row); } return rows; -- 2.39.2