]> git.sesse.net Git - pkanalytics/commitdiff
Change pulls to defense in the viewer.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 10 May 2023 18:41:01 +0000 (20:41 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 10 May 2023 18:41:01 +0000 (20:41 +0200)
ultimate.js

index e4b0928631b72eb6793a213a96fc56288ab8ed0e..4ccb9d59e5d4a401fed2341bb693e6c877356009 100644 (file)
@@ -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;