3 // No frameworks, no compilers, no npm, just JavaScript. :-)
7 addEventListener('hashchange', () => { process_matches(global_json); });
9 .then(response => response.json())
10 .then(response => { global_json = response; process_matches(global_json); });
12 function attribute_player_time(player, to, from, offense) {
14 if (player.on_field_since > from) {
15 // Player came in while play happened (without a stoppage!?).
16 delta_time = to - player.on_field_since;
18 delta_time = to - from;
20 player.playing_time_ms += delta_time;
21 if (offense === true) {
22 player.offensive_playing_time_ms += delta_time;
23 } else if (offense === false) {
24 player.defensive_playing_time_ms += delta_time;
28 function take_off_field(player, t, live_since, offense) {
29 if (live_since === null) {
30 // Play isn't live, so nothing to do.
32 attribute_player_time(player, t, live_since, offense);
34 if (player.on_field_since !== null) { // Just a safeguard; out without in should never happen.
35 player.field_time_ms += t - player.on_field_since;
37 player.on_field_since = null;
40 function add_cell(tr, element_type, text) {
41 let element = document.createElement(element_type);
42 element.textContent = text;
43 tr.appendChild(element);
47 function add_th(tr, text, colspan) {
48 let element = add_cell(tr, 'th', text);
50 element.setAttribute('colspan', colspan);
52 element.setAttribute('colspan', '3');
57 function add_3cell(tr, text, cls) {
58 let p1 = add_cell(tr, 'td', '');
59 let element = add_cell(tr, 'td', text);
60 let p2 = add_cell(tr, 'td', '');
62 p1.classList.add('pad');
63 p2.classList.add('pad');
64 if (cls === undefined) {
65 element.classList.add('num');
67 element.classList.add(cls);
72 function add_3cell_with_filler_ci(tr, text, cls) {
73 let element = add_3cell(tr, text, cls);
75 let svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
76 svg.classList.add('fillerci');
77 svg.setAttribute('width', ci_width);
78 svg.setAttribute('height', ci_height);
79 element.appendChild(svg);
84 function add_3cell_ci(tr, ci) {
86 add_3cell_with_filler_ci(tr, 'N/A');
91 if (ci.format === 'percentage') {
92 text = (100 * ci.val).toFixed(0) + '%';
94 text = ci.val.toFixed(2);
96 let element = add_3cell(tr, text);
97 let to_x = (val) => { return ci_width * (val - ci.min) / (ci.max - ci.min); };
100 let svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
101 if (ci.inverted === true) {
102 svg.classList.add('invertedci');
104 svg.classList.add('ci');
106 svg.setAttribute('width', ci_width);
107 svg.setAttribute('height', ci_height);
109 // The good (green) and red (bad) ranges.
110 let s0 = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
111 s0.classList.add('range');
112 s0.classList.add('s0');
113 s0.setAttribute('width', to_x(ci.desired));
114 s0.setAttribute('height', ci_height);
115 s0.setAttribute('x', '0');
117 let s1 = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
118 s1.classList.add('range');
119 s1.classList.add('s1');
120 s1.setAttribute('width', ci_width - to_x(ci.desired));
121 s1.setAttribute('height', ci_height);
122 s1.setAttribute('x', to_x(ci.desired));
125 let bar = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
126 bar.classList.add('bar');
127 bar.setAttribute('width', to_x(ci.upper_ci) - to_x(ci.lower_ci));
128 bar.setAttribute('height', ci_height / 3);
129 bar.setAttribute('x', to_x(ci.lower_ci));
130 bar.setAttribute('y', ci_height / 3);
132 // Marker line for average.
133 let marker = document.createElementNS('http://www.w3.org/2000/svg', 'line');
134 marker.classList.add('marker');
135 marker.setAttribute('x1', to_x(ci.val));
136 marker.setAttribute('x2', to_x(ci.val));
137 marker.setAttribute('y1', ci_height / 6);
138 marker.setAttribute('y2', ci_height * 5 / 6);
142 svg.appendChild(bar);
143 svg.appendChild(marker);
145 element.appendChild(svg);
148 function process_matches(json) {
150 for (const player of json['players']) {
151 players[player['player_id']] = {
152 'name': player['name'],
153 'number': player['number'],
167 'playing_time_ms': 0,
168 'offensive_playing_time_ms': 0,
169 'defensive_playing_time_ms': 0,
173 'offensive_points_completed': 0,
174 'offensive_points_won': 0,
175 'defensive_points_completed': 0,
176 'defensive_points_won': 0,
178 'offensive_soft_plus': 0,
179 'offensive_soft_minus': 0,
180 'defensive_soft_plus': 0,
181 'defensive_soft_minus': 0,
188 'last_point_seen': null,
189 'on_field_since': null,
194 players['globals'] = {
196 'playing_time_ms': 0,
197 'offensive_playing_time_ms': 0,
198 'defensive_playing_time_ms': 0,
201 'offensive_points_completed': 0,
202 'offensive_points_won': 0,
203 'defensive_points_completed': 0,
204 'defensive_points_won': 0,
206 let globals = players['globals'];
208 for (const match of json['matches']) {
212 let prev_handler = null;
213 let live_since = null;
214 let offense = null; // True/false/null (unknown).
216 let pull_started = null;
217 let last_pull_was_ours = null; // Effectively whether we're playing an O or D point (not affected by turnovers).
219 let game_started = null;
220 let last_goal = null;
221 for (const [q,p] of Object.entries(players)) {
222 p.on_field_since = null;
223 p.last_point_seen = null;
225 for (const e of match['events']) {
227 let type = e['type'];
228 let p = players[e['player']];
231 if (type === 'in' && p.on_field_since === null) {
232 p.on_field_since = t;
233 } else if (type === 'out') {
234 take_off_field(p, t, live_since, offense);
237 // Liveness management
238 if (type === 'pull' || type === 'their_pull' || type === 'restart') {
240 } else if (type === 'catch' && last_pull_was_ours === null) {
241 // Someone forgot to add the pull, so we'll need to wing it.
242 console.log('Missing pull on ' + our_score + '\u2013' + their_score + ' in ' + match['description'] + '; pretending to have one.');
244 last_pull_was_ours = !offense;
245 } else if (type === 'goal' || type === 'their_goal' || type === 'stoppage') {
246 for (const [q,p] of Object.entries(players)) {
247 if (p.on_field_since === null) {
250 if (type !== 'stoppage' && p.last_point_seen !== point_num) {
251 // In case the player did nothing this point,
252 // not even subbing in.
253 p.last_point_seen = point_num;
256 attribute_player_time(p, t, live_since, offense);
258 if (type !== 'stoppage') {
259 if (last_pull_was_ours === true) { // D point.
260 ++p.defensive_points_completed;
261 if (type === 'goal') {
262 ++p.defensive_points_won;
264 } else if (last_pull_was_ours === false) { // O point.
265 ++p.offensive_points_completed;
266 if (type === 'goal') {
267 ++p.offensive_points_won;
273 if (type !== 'stoppage') {
275 ++globals.points_played;
276 if (last_pull_was_ours === true) { // D point.
277 ++globals.defensive_points_completed;
278 if (type === 'goal') {
279 ++globals.defensive_points_won;
281 } else if (last_pull_was_ours === false) { // O point.
282 ++globals.offensive_points_completed;
283 if (type === 'goal') {
284 ++globals.offensive_points_won;
288 if (live_since !== null) {
289 globals.playing_time_ms += t - live_since;
290 if (offense === true) {
291 globals.offensive_playing_time_ms += t - live_since;
292 } else if (offense === false) {
293 globals.defensive_playing_time_ms += t - live_since;
301 if (type === 'goal') {
303 } else if (type === 'their_goal') {
307 // Point count management
308 if (p !== undefined && type !== 'out' && p.last_point_seen !== point_num) {
309 p.last_point_seen = point_num;
312 if (type === 'goal' || type === 'their_goal') {
316 if (type !== 'out' && game_started === null) {
321 if (type === 'pull') {
322 puller = e['player'];
325 } else if (type === 'in' || type === 'out' || type === 'stoppage' || type === 'restart' || type === 'unknown' || type === 'set_defense' || type === 'set_offense') {
326 // No effect on pull.
327 } else if (type === 'pull_landed' && puller !== null) {
328 players[puller].pull_times.push(t - pull_started);
329 } else if (type === 'pull_oob' && puller !== null) {
330 ++players[puller].oob_pulls;
332 // Not pulling (if there was one, we never recorded its outcome, but still count it).
333 puller = pull_started = null;
336 // Offense/defense management
337 let last_offense = offense;
338 if (type === 'set_defense' || type === 'goal' || type === 'throwaway' || type === 'drop') {
340 } else if (type === 'set_offense' || type === 'their_goal' || type === 'their_throwaway' || type === 'defense' || type === 'interception') {
343 if (last_offense !== offense && live_since !== null) {
344 // Switched offense/defense status, so attribute this drive as needed,
345 // and update live_since to take that into account.
346 for (const [q,p] of Object.entries(players)) {
347 if (p.on_field_since === null) {
350 attribute_player_time(p, t, live_since, last_offense);
352 globals.playing_time_ms += t - live_since;
353 if (offense === true) {
354 globals.offensive_playing_time_ms += t - live_since;
355 } else if (offense === false) {
356 globals.defensive_playing_time_ms += t - live_since;
361 if (type === 'pull') {
362 last_pull_was_ours = true;
363 } else if (type === 'their_pull') {
364 last_pull_was_ours = false;
365 } else if (type === 'set_offense' && last_pull_was_ours === null) {
366 // set_offense could either be “changed to offense for some reason
367 // we could not express”, or “we started in the middle of a point,
368 // and we are offense”. We assume that if we already saw the pull,
369 // it's the former, and if not, it's the latter; thus, the === null
370 // test above. (It could also be “we set offense before the pull,
371 // so that we get the right button enabled”, in which case it will
372 // be overwritten by the next pull/their_pull event anyway.)
373 last_pull_was_ours = false;
374 } else if (type === 'set_defense' && last_pull_was_ours === null) {
376 last_pull_was_ours = true;
377 } else if (type === 'goal' || type === 'their_goal') {
378 last_pull_was_ours = null;
382 if (type === 'catch' || type === 'goal') {
383 if (handler !== null) {
384 ++players[handler].num_throws;
389 if (type === 'goal') {
390 if (prev_handler !== null) {
391 ++players[prev_handler].hockey_assists;
393 if (handler !== null) {
394 ++players[handler].assists;
397 handler = prev_handler = null;
399 // Update hold history.
400 prev_handler = handler;
401 handler = e['player'];
403 } else if (type === 'throwaway') {
406 handler = prev_handler = null;
407 } else if (type === 'drop') {
409 handler = prev_handler = null;
410 } else if (type === 'defense') {
412 } else if (type === 'interception') {
417 handler = e['player'];
418 } else if (type === 'offensive_soft_plus' || type === 'offensive_soft_minus' || type === 'defensive_soft_plus' || type === 'defensive_soft_minus') {
420 } else if (type !== 'in' && type !== 'out' && type !== 'pull' &&
421 type !== 'their_goal' && type !== 'stoppage' && type !== 'restart' && type !== 'unknown' &&
422 type !== 'set_defense' && type !== 'goal' && type !== 'throwaway' &&
423 type !== 'drop' && type !== 'set_offense' && type !== 'their_goal' &&
424 type !== 'pull' && type !== 'pull_landed' && type !== 'pull_oob' && type !== 'their_pull' &&
425 type !== 'their_throwaway' && type !== 'defense' && type !== 'interception') {
426 console.log("Unknown event:", e);
430 // Add field time for all players still left at match end.
431 for (const [q,p] of Object.entries(players)) {
432 if (p.on_field_since !== null && last_goal !== null) {
433 p.field_time_ms += last_goal - p.on_field_since;
436 if (game_started !== null && last_goal !== null) {
437 globals.field_time_ms += last_goal - game_started;
439 if (live_since !== null && last_goal !== null) {
440 globals.playing_time_ms += last_goal - live_since;
441 if (offense === true) {
442 globals.offensive_playing_time_ms += last_goal - live_since;
443 } else if (offense === false) {
444 globals.defensive_playing_time_ms += last_goal - live_since;
449 let chosen_category = get_chosen_category();
450 write_main_menu(chosen_category);
453 if (chosen_category === 'general') {
454 rows = make_table_general(players);
455 } else if (chosen_category === 'offense') {
456 rows = make_table_offense(players);
457 } else if (chosen_category === 'defense') {
458 rows = make_table_defense(players);
459 } else if (chosen_category === 'playing_time') {
460 rows = make_table_playing_time(players);
461 } else if (chosen_category === 'per_point') {
462 rows = make_table_per_point(players);
464 document.getElementById('stats').replaceChildren(...rows);
467 function get_chosen_category() {
468 if (window.location.hash === '#offense') {
470 } else if (window.location.hash === '#defense') {
472 } else if (window.location.hash === '#playing_time') {
473 return 'playing_time';
474 } else if (window.location.hash === '#per_point') {
481 function write_main_menu(chosen_category) {
483 if (chosen_category === 'general') {
484 let span = document.createElement('span');
485 span.innerText = 'General';
488 let a = document.createElement('a');
489 a.appendChild(document.createTextNode('General'));
490 a.setAttribute('href', '#general');
494 if (chosen_category === 'offense') {
495 let span = document.createElement('span');
496 span.innerText = 'Offense';
499 let a = document.createElement('a');
500 a.appendChild(document.createTextNode('Offense'));
501 a.setAttribute('href', '#offense');
505 if (chosen_category === 'defense') {
506 let span = document.createElement('span');
507 span.innerText = 'Defense';
510 let a = document.createElement('a');
511 a.appendChild(document.createTextNode('Defense'));
512 a.setAttribute('href', '#defense');
516 if (chosen_category === 'playing_time') {
517 let span = document.createElement('span');
518 span.innerText = 'Playing time';
521 let a = document.createElement('a');
522 a.appendChild(document.createTextNode('Playing time'));
523 a.setAttribute('href', '#playing_time');
527 if (chosen_category === 'per_point') {
528 let span = document.createElement('span');
529 span.innerText = 'Per point';
532 let a = document.createElement('a');
533 a.appendChild(document.createTextNode('Per point'));
534 a.setAttribute('href', '#per_point');
538 document.getElementById('mainmenu').replaceChildren(...elems);
541 // https://en.wikipedia.org/wiki/1.96#History
544 const ci_width = 100;
545 const ci_height = 20;
547 function make_binomial_ci(val, num, z) {
550 // https://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval#Wilson_score_interval
551 let low = (avg + z*z/(2*num) - z * Math.sqrt(avg * (1.0 - avg) / num + z*z/(4*num*num))) / (1 + z*z/num);
552 let high = (avg + z*z/(2*num) + z * Math.sqrt(avg * (1.0 - avg) / num + z*z/(4*num*num))) / (1 + z*z/num);
554 // Fix the signs so that we don't get -0.00.
555 low = Math.max(low, 0.0);
565 // These can only happen once per point, but you get -1 and +1
566 // instead of 0 and +1. After we rewrite to 0 and 1, it's a binomial,
567 // and then we can rewrite back.
568 function make_efficiency_ci(points_won, points_completed, z)
570 let ci = make_binomial_ci(points_won, points_completed, z);
571 ci.val = 2.0 * ci.val - 1.0;
572 ci.lower_ci = 2.0 * ci.lower_ci - 1.0;
573 ci.upper_ci = 2.0 * ci.upper_ci - 1.0;
576 ci.desired = 0.0; // Desired = positive efficiency.
580 // Ds, throwaways and drops can happen multiple times per point,
581 // so they are Poisson distributed.
583 // Modified Wald (recommended by http://www.ine.pt/revstat/pdf/rs120203.pdf
584 // since our rates are definitely below 2 per point).
585 function make_poisson_ci(val, num, z, inverted)
587 let low = (val == 0) ? 0.0 : ((val - 0.5) - Math.sqrt(val - 0.5)) / num;
588 let high = (val == 0) ? -Math.log(0.025) / num : ((val + 0.5) + Math.sqrt(val + 0.5)) / num;
590 // Fix the signs so that we don't get -0.00.
591 low = Math.max(low, 0.0);
593 // The display range of 0 to 0.25 is fairly arbitrary. So is the desired 0.05 per point.
602 'inverted': inverted,
606 function make_table_general(players) {
609 let header = document.createElement('tr');
610 add_th(header, 'Player');
611 add_th(header, '+/-');
612 add_th(header, 'Soft +/-');
613 add_th(header, 'O efficiency');
614 add_th(header, 'D efficiency');
615 add_th(header, 'Points played');
619 for (const [q,p] of Object.entries(players)) {
620 if (q === 'globals') continue;
621 let row = document.createElement('tr');
622 let pm = p.goals + p.assists + p.hockey_assists + p.defenses - p.throwaways - p.drops;
623 let soft_pm = p.offensive_soft_plus + p.defensive_soft_plus - p.offensive_soft_minus - p.defensive_soft_minus;
624 let o_efficiency = make_efficiency_ci(p.offensive_points_won, p.offensive_points_completed, z);
625 let d_efficiency = make_efficiency_ci(p.defensive_points_won, p.defensive_points_completed, z);
626 add_3cell(row, p.name, 'name'); // TODO: number?
627 add_3cell(row, pm > 0 ? ('+' + pm) : pm);
628 add_3cell(row, soft_pm > 0 ? ('+' + soft_pm) : soft_pm);
629 add_3cell_ci(row, o_efficiency);
630 add_3cell_ci(row, d_efficiency);
631 add_3cell(row, p.points_played);
636 let globals = players['globals'];
637 let o_efficiency = make_efficiency_ci(globals.offensive_points_won, globals.offensive_points_completed, z);
638 let d_efficiency = make_efficiency_ci(globals.defensive_points_won, globals.defensive_points_completed, z);
639 let row = document.createElement('tr');
643 add_3cell_ci(row, o_efficiency);
644 add_3cell_ci(row, d_efficiency);
645 add_3cell(row, globals.points_played);
651 function make_table_offense(players) {
654 let header = document.createElement('tr');
655 add_th(header, 'Player');
656 add_th(header, 'Goals');
657 add_th(header, 'Assists');
658 add_th(header, 'Hockey assists');
659 add_th(header, 'Throws');
660 add_th(header, 'Throwaways');
661 add_th(header, '%OK');
662 add_th(header, 'Catches');
663 add_th(header, 'Drops');
664 add_th(header, '%OK');
665 add_th(header, 'Soft +/-', 6);
673 for (const [q,p] of Object.entries(players)) {
674 if (q === 'globals') continue;
675 let throw_ok = make_binomial_ci(p.num_throws - p.throwaways, p.num_throws, z);
676 let catch_ok = make_binomial_ci(p.catches, p.catches + p.drops, z);
678 throw_ok.format = 'percentage';
679 catch_ok.format = 'percentage';
681 // Desire at least 90% percentage. Fairly arbitrary.
682 throw_ok.desired = 0.9;
683 catch_ok.desired = 0.9;
685 let row = document.createElement('tr');
686 add_3cell(row, p.name, 'name'); // TODO: number?
687 add_3cell(row, p.goals);
688 add_3cell(row, p.assists);
689 add_3cell(row, p.hockey_assists);
690 add_3cell(row, p.num_throws);
691 add_3cell(row, p.throwaways);
692 add_3cell_ci(row, throw_ok);
693 add_3cell(row, p.catches);
694 add_3cell(row, p.drops);
695 add_3cell_ci(row, catch_ok);
696 add_3cell(row, '+' + p.offensive_soft_plus);
697 add_3cell(row, '-' + p.offensive_soft_minus);
700 num_throws += p.num_throws;
701 throwaways += p.throwaways;
702 catches += p.catches;
707 let throw_ok = make_binomial_ci(num_throws - throwaways, num_throws, z);
708 let catch_ok = make_binomial_ci(catches, catches + drops, z);
709 throw_ok.format = 'percentage';
710 catch_ok.format = 'percentage';
711 throw_ok.desired = 0.9;
712 catch_ok.desired = 0.9;
714 let row = document.createElement('tr');
719 add_3cell(row, num_throws);
720 add_3cell(row, throwaways);
721 add_3cell_ci(row, throw_ok);
722 add_3cell(row, catches);
723 add_3cell(row, drops);
724 add_3cell_ci(row, catch_ok);
732 function make_table_defense(players) {
735 let header = document.createElement('tr');
736 add_th(header, 'Player');
737 add_th(header, 'Ds');
738 add_th(header, 'Pulls');
739 add_th(header, 'OOB pulls');
740 add_th(header, 'OOB%');
741 add_th(header, 'Avg. hang time (IB)');
742 add_th(header, 'Soft +/-', 6);
745 for (const [q,p] of Object.entries(players)) {
746 if (q === 'globals') continue;
748 for (const t of p.pull_times) {
751 let avg_time = 1e-3 * sum_time / p.pulls;
752 let oob_pct = 100 * p.oob_pulls / p.pulls;
754 let ci_oob = make_binomial_ci(p.oob_pulls, p.pulls, z);
755 ci_oob.format = 'percentage';
756 ci_oob.desired = 0.2; // Arbitrary.
757 ci_oob.inverted = true;
759 let row = document.createElement('tr');
760 add_3cell(row, p.name, 'name'); // TODO: number?
761 add_3cell(row, p.defenses);
762 add_3cell(row, p.pulls);
763 add_3cell(row, p.oob_pulls);
764 add_3cell_ci(row, ci_oob);
765 if (p.pulls > p.oob_pulls) {
766 add_3cell(row, avg_time.toFixed(1) + ' sec');
768 add_3cell(row, 'N/A');
770 add_3cell(row, '+' + p.defensive_soft_plus);
771 add_3cell(row, '-' + p.defensive_soft_minus);
777 function make_table_playing_time(players) {
780 let header = document.createElement('tr');
781 add_th(header, 'Player');
782 add_th(header, 'Points played');
783 add_th(header, 'Time played');
784 add_th(header, 'O time');
785 add_th(header, 'D time');
786 add_th(header, 'Time on field');
787 add_th(header, 'O points');
788 add_th(header, 'D points');
792 for (const [q,p] of Object.entries(players)) {
793 if (q === 'globals') continue;
794 let row = document.createElement('tr');
795 add_3cell(row, p.name, 'name'); // TODO: number?
796 add_3cell(row, p.points_played);
797 add_3cell(row, Math.floor(p.playing_time_ms / 60000) + ' min');
798 add_3cell(row, Math.floor(p.offensive_playing_time_ms / 60000) + ' min');
799 add_3cell(row, Math.floor(p.defensive_playing_time_ms / 60000) + ' min');
800 add_3cell(row, Math.floor(p.field_time_ms / 60000) + ' min');
801 add_3cell(row, p.offensive_points_completed);
802 add_3cell(row, p.defensive_points_completed);
807 let globals = players['globals'];
808 let row = document.createElement('tr');
810 add_3cell(row, globals.points_played);
811 add_3cell(row, Math.floor(globals.playing_time_ms / 60000) + ' min');
812 add_3cell(row, Math.floor(globals.offensive_playing_time_ms / 60000) + ' min');
813 add_3cell(row, Math.floor(globals.defensive_playing_time_ms / 60000) + ' min');
814 add_3cell(row, Math.floor(globals.field_time_ms / 60000) + ' min');
815 add_3cell(row, globals.offensive_points_completed);
816 add_3cell(row, globals.defensive_points_completed);
822 function make_table_per_point(players) {
825 let header = document.createElement('tr');
826 add_th(header, 'Player');
827 add_th(header, 'Goals');
828 add_th(header, 'Assists');
829 add_th(header, 'Hockey assists');
830 add_th(header, 'Ds');
831 add_th(header, 'Throwaways');
832 add_th(header, 'Drops');
833 add_th(header, 'Touches');
839 let hockey_assists = 0;
844 for (const [q,p] of Object.entries(players)) {
845 if (q === 'globals') continue;
847 // Can only happen once per point, so these are binomials.
848 let ci_goals = make_binomial_ci(p.goals, p.points_played, z);
849 let ci_assists = make_binomial_ci(p.assists, p.points_played, z);
850 let ci_hockey_assists = make_binomial_ci(p.hockey_assists, p.points_played, z);
851 // Arbitrarily desire at least 10% (not everybody can score or assist).
852 ci_goals.desired = 0.1;
853 ci_assists.desired = 0.1;
854 ci_hockey_assists.desired = 0.1;
856 let row = document.createElement('tr');
857 add_3cell(row, p.name, 'name'); // TODO: number?
858 add_3cell_ci(row, ci_goals);
859 add_3cell_ci(row, ci_assists);
860 add_3cell_ci(row, ci_hockey_assists);
861 add_3cell_ci(row, make_poisson_ci(p.defenses, p.points_played, z));
862 add_3cell_ci(row, make_poisson_ci(p.throwaways, p.points_played, z, true));
863 add_3cell_ci(row, make_poisson_ci(p.drops, p.points_played, z, true));
864 if (p.points_played > 0) {
865 add_3cell(row, p.touches == 0 ? 0 : (p.touches / p.points_played).toFixed(2));
867 add_3cell(row, 'N/A');
872 assists += p.assists;
873 hockey_assists += p.hockey_assists;
874 defenses += p.defenses;
875 throwaways += p.throwaways;
877 touches += p.touches;
881 let globals = players['globals'];
882 let row = document.createElement('tr');
884 if (globals.points_played > 0) {
885 add_3cell_with_filler_ci(row, goals == 0 ? 0 : (goals / globals.points_played).toFixed(2));
886 add_3cell_with_filler_ci(row, assists == 0 ? 0 : (assists / globals.points_played).toFixed(2));
887 add_3cell_with_filler_ci(row, hockey_assists == 0 ? 0 : (hockey_assists / globals.points_played).toFixed(2));
888 add_3cell_with_filler_ci(row, defenses == 0 ? 0 : (defenses / globals.points_played).toFixed(2));
889 add_3cell_with_filler_ci(row, throwaways == 0 ? 0 : (throwaways / globals.points_played).toFixed(2));
890 add_3cell_with_filler_ci(row, drops == 0 ? 0 : (drops / globals.points_played).toFixed(2));
891 add_3cell(row, touches == 0 ? 0 : (touches / globals.points_played).toFixed(2));
893 add_3cell_with_filler_ci(row, 'N/A');
894 add_3cell_with_filler_ci(row, 'N/A');
895 add_3cell_with_filler_ci(row, 'N/A');
896 add_3cell_with_filler_ci(row, 'N/A');
897 add_3cell_with_filler_ci(row, 'N/A');
898 add_3cell_with_filler_ci(row, 'N/A');
899 add_3cell(row, 'N/A');