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;
}
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);
}
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);
}
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)) {
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);
}
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);
}