From 9e06d96d5303be1af1a3074a58cb162fa79cac29 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 21 May 2023 10:43:28 +0200 Subject: [PATCH] Make soft +/- span both columns. --- ultimate.js | 85 +++++++++++++++++++++++++++++------------------------ 1 file changed, 46 insertions(+), 39 deletions(-) diff --git a/ultimate.js b/ultimate.js index ff979ff..3ff7de8 100644 --- a/ultimate.js +++ b/ultimate.js @@ -33,10 +33,17 @@ function take_off_field(player, t, live_since) { function add_cell(tr, element_type, text) { let element = document.createElement(element_type); element.textContent = text; - if (element_type === 'th') { + tr.appendChild(element); + return element; +} + +function add_th(tr, text, colspan) { + let element = add_cell(tr, 'th', text); + if (colspan > 0) { + element.setAttribute('colspan', colspan); + } else { element.setAttribute('colspan', '3'); } - tr.appendChild(element); return element; } @@ -560,12 +567,12 @@ function make_table_general(players) { let rows = []; { let header = document.createElement('tr'); - add_cell(header, 'th', 'Player'); - add_cell(header, 'th', '+/-'); - add_cell(header, 'th', 'Soft +/-'); - add_cell(header, 'th', 'O efficiency'); - add_cell(header, 'th', 'D efficiency'); - add_cell(header, 'th', 'Points played'); + add_th(header, 'Player'); + add_th(header, '+/-'); + add_th(header, 'Soft +/-'); + add_th(header, 'O efficiency'); + add_th(header, 'D efficiency'); + add_th(header, 'Points played'); rows.push(header); } @@ -605,17 +612,17 @@ function make_table_offense(players) { let rows = []; { let header = document.createElement('tr'); - add_cell(header, 'th', 'Player'); - add_cell(header, 'th', 'Goals'); - add_cell(header, 'th', 'Assists'); - add_cell(header, 'th', 'Hockey assists'); - add_cell(header, 'th', 'Throws'); - add_cell(header, 'th', 'Throwaways'); - add_cell(header, 'th', '%OK'); - add_cell(header, 'th', 'Catches'); - add_cell(header, 'th', 'Drops'); - add_cell(header, 'th', '%OK'); - add_cell(header, 'th', 'Soft +/-'); + add_th(header, 'Player'); + add_th(header, 'Goals'); + add_th(header, 'Assists'); + add_th(header, 'Hockey assists'); + add_th(header, 'Throws'); + add_th(header, 'Throwaways'); + add_th(header, '%OK'); + add_th(header, 'Catches'); + add_th(header, 'Drops'); + add_th(header, '%OK'); + add_th(header, 'Soft +/-', 6); rows.push(header); } @@ -686,12 +693,12 @@ 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 +/-'); + add_th(header, 'Player'); + add_th(header, 'Ds'); + add_th(header, 'Pulls'); + add_th(header, 'OOB pulls'); + add_th(header, 'Avg. hang time (IB)'); + add_th(header, 'Soft +/-', 6); rows.push(header); } for (const [q,p] of Object.entries(players)) { @@ -728,12 +735,12 @@ function make_table_playing_time(players) { let rows = []; { let header = document.createElement('tr'); - add_cell(header, 'th', 'Player'); - add_cell(header, 'th', 'Points played'); - add_cell(header, 'th', 'Time played'); - add_cell(header, 'th', 'Time on field'); - add_cell(header, 'th', 'O points'); - add_cell(header, 'th', 'D points'); + add_th(header, 'Player'); + add_th(header, 'Points played'); + add_th(header, 'Time played'); + add_th(header, 'Time on field'); + add_th(header, 'O points'); + add_th(header, 'D points'); rows.push(header); } @@ -767,14 +774,14 @@ function make_table_per_point(players) { let rows = []; { let header = document.createElement('tr'); - add_cell(header, 'th', 'Player'); - add_cell(header, 'th', 'Goals'); - add_cell(header, 'th', 'Assists'); - add_cell(header, 'th', 'Hockey assists'); - add_cell(header, 'th', 'Ds'); - add_cell(header, 'th', 'Throwaways'); - add_cell(header, 'th', 'Drops'); - add_cell(header, 'th', 'Touches'); + add_th(header, 'Player'); + add_th(header, 'Goals'); + add_th(header, 'Assists'); + add_th(header, 'Hockey assists'); + add_th(header, 'Ds'); + add_th(header, 'Throwaways'); + add_th(header, 'Drops'); + add_th(header, 'Touches'); rows.push(header); } -- 2.39.2