]> git.sesse.net Git - pkanalytics/commitdiff
Make soft +/- span both columns.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 21 May 2023 08:43:28 +0000 (10:43 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 21 May 2023 08:43:28 +0000 (10:43 +0200)
ultimate.js

index ff979ff1a38f3444a309d241ae425f3c3741de10..3ff7de822afd50a13d052fe9e773d036615acaaa 100644 (file)
@@ -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);
        }