<commit_before>import { h, VNode } from 'snabbdom';
import { onInsert } from './util';
import { ChatPlugin } from 'chat';
import { Team, TourPlayer } from 'game';

export interface TourStandingCtrl extends ChatPlugin {
  set(players: TourPlayer[]): void;
}

export function tourStandingCtrl(players: TourPlayer[], team: Team | undefined, name: string): TourStandingCtrl {
  return {
    set(d: TourPlayer[]) {
      players = d;
    },
    tab: {
      key: 'tourStanding',
      name: name,
    },
    view(): VNode {
      return h(
        'div',
        {
          hook: onInsert(_ => {
            lichess.loadCssPath('round.tour-standing');
          }),
        },
        [
          team
            ? h(
                'h3.text',
                {
                  attrs: { 'data-icon': '' },
                },
                team.name
              )
            : null,
          h('table.slist', [
            h(
              'tbody',
              players.map((p: TourPlayer, i: number) => {
                return h('tr.' + p.n, [
                  h('td.name', [
                    h('span.rank', '' + (i + 1)),
                    h(
                      'a.user-link.ulpt',
                      {
                        attrs: { href: `/@/${p.n}` },
                      },
                      (p.t ? p.t + ' ' : '') + p.n
                    ),
                  ]),
                  h(
                    'td.total',
                    p.f
                      ? {
                          class: { 'is-gold': true },
                          attrs: { 'data-icon': '' },
                        }
                      : {},
                    '' + p.s
                  ),
                ]);
              })
            ),
          ]),
        ]
      );
    },
  };
}<commit_msg>code golf<commit_after>import { h, VNode } from 'snabbdom';
import { onInsert } from './util';
import { ChatPlugin } from 'chat';
import { Team, TourPlayer } from 'game';

export interface TourStandingCtrl extends ChatPlugin {
  set(players: TourPlayer[]): void;
}

export const tourStandingCtrl = (players: TourPlayer[], team: Team | undefined, name: string): TourStandingCtrl => ({
    set(d: TourPlayer[]) {
      players = d;
    },
    tab: {
      key: 'tourStanding',
      name: name,
    },
    view(): VNode {
      return h(
        'div',
        {
          hook: onInsert(_ => lichess.loadCssPath('round.tour-standing')),
        },
        [
          team
            ? h(
                'h3.text',
                {
                  attrs: { 'data-icon': '' },
                },
                team.name
              )
            : null,
          h('table.slist', [
            h(
              'tbody',
              players.map((p: TourPlayer, i: number) => {
                return h('tr.' + p.n, [
                  h('td.name', [
                    h('span.rank', '' + (i + 1)),
                    h(
                      'a.user-link.ulpt',
                      {
                        attrs: { href: `/@/${p.n}` },
                      },
                      (p.t ? p.t + ' ' : '') + p.n
                    ),
                  ]),
                  h(
                    'td.total',
                    p.f
                      ? {
                          class: { 'is-gold': true },
                          attrs: { 'data-icon': '' },
                        }
                      : {},
                    '' + p.s
                  ),
                ]);
              })
            ),
          ]),
        ]
      );
    },
  });
{'fraction_non_alphanumeric': 0.14724605590921672, 'fraction_numerical': 0.0011071132023249377, 'mean_word_length': 0.8252525252525252, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1979272', 'n_tokens_mistral': 1031, 'n_tokens_neox': 977, 'n_words': 189}