<commit_before>import { h } from 'snabbdom'
import SimulCtrl from '../ctrl';
import { Applicant } from '../interfaces';
import xhr from '../xhr';
import * as util from './util';
import { VNode } from 'snabbdom/vnode';

export default function(showText: (ctrl: SimulCtrl) => VNode) {
  return (ctrl: SimulCtrl) => {
    const candidates = ctrl.candidates().sort(byName),
      accepted = ctrl.accepted().sort(byName),
      isHost = ctrl.createdByMe();
    const variantIconFor = (a: Applicant) => {
      const variant = ctrl.data.variants.find(v => a.variant == v.key);
      return variant && h('td.variant', {
        attrs: {
          'data-icon': variant.icon
        }
      });
    }
    return [
      h('div.box__top', [
        util.title(ctrl),
        h('div.box__top__actions',
          ctrl.opts.userId ? (
            isHost ? [
              startOrCancel(ctrl, accepted),
              randomButton(ctrl)
            ] : (
                ctrl.containsMe() ?
                  h('a.button', {
                    hook: util.bind('click', () => xhr.withdraw(ctrl.data.id))
                  }, ctrl.trans('withdraw')) :
                  h('a.button.text' + (ctrl.teamBlock() ? '.disabled' : ''), {
                    attrs: {
                      disabled: ctrl.teamBlock(),
                      'data-icon': 'G'
                    },
                    hook: ctrl.teamBlock() ? null : util.bind('click', () => {
                      if (ctrl.data.variants.length === 1)
                        xhr.join(ctrl.data.id, ctrl.data.variants[0].key);
                      else {
                        $.modal($('.simul .continue-with'));
                        $('#modal-wrap .continue-with a').click(function(this: HTMLElement) {
                          $.modal.close();
                          xhr.join(ctrl.data.id, $(this).data('variant'));
                        });
                      }
                    })
                  },
                    ctrl.teamBlock() ? ctrl.trans('mustBeInTeam', ctrl.data.team.name) : ctrl.trans('join'))
              )) : h('a.button.text', {
                attrs: {
                  'data-icon': 'G',
                  href: '/login?referrer=' + window.location.pathname
                }
              }, ctrl.trans('signIn'))
        )
      ]),
      showText(ctrl),
      ctrl.acceptedContainsMe() ? h('p.instructions',
        'You have been selected! Hold still, the simul is about to begin.'<commit_msg>fix ui/simul<commit_after>import { h } from 'snabbdom'
import SimulCtrl from '../ctrl';
import { Applicant } from '../interfaces';
import xhr from '../xhr';
import * as util from './util';
import { VNode } from 'snabbdom/vnode';

export default function(showText: (ctrl: SimulCtrl) => VNode) {
  return (ctrl: SimulCtrl) => {
    const candidates = ctrl.candidates().sort(byName),
      accepted = ctrl.accepted().sort(byName),
      isHost = ctrl.createdByMe();
    const variantIconFor = (a: Applicant) => {
      const variant = ctrl.data.variants.find(v => a.variant == v.key);
      return variant && h('td.variant', {
        attrs: {
          'data-icon': variant.icon
        }
      });
    }
    return [
      h('div.box__top', [
        util.title(ctrl),
        h('div.box__top__actions',
          ctrl.opts.userId ? (
            isHost ? [
              startOrCancel(ctrl, accepted),
              randomButton(ctrl)
            ] : (
                ctrl.containsMe() ?
                  h('a.button', {
                    hook: util.bind('click', () => xhr.withdraw(ctrl.data.id))
                  }, ctrl.trans('withdraw')) :
                  h('a.button.text' + (ctrl.teamBlock() ? '.disabled' : ''), {
                    attrs: {
                      disabled: ctrl.teamBlock(),
                      'data-icon': 'G'
                    },
                    hook: ctrl.teamBlock() ? {} : util.bind('click', () => {
                      if (ctrl.data.variants.length === 1)
                        xhr.join(ctrl.data.id, ctrl.data.variants[0].key);
                      else {
                        $.modal($('.simul .continue-with'));
                        $('#modal-wrap .continue-with a').click(function(this: HTMLElement) {
                          $.modal.close();
                          xhr.join(ctrl.data.id, $(this).data('variant'));
                        });
                      }
                    })
                  },
                    ctrl.teamBlock() ? ctrl.trans('mustBeInTeam', ctrl.data.team.name) : ctrl.trans('join'))
              )) : h('a.button.text', {
                attrs: {
                  'data-icon': 'G',
                  href: '/login?referrer=' + window.location.pathname
                }
              }, ctrl.trans('signIn'))
        )
      ]),
      showText(ctrl),
      ctrl.acceptedContainsMe() ? h('p.instructions',
        'You have been selected! Hold still, the simul is about to begin.'
{'fraction_non_alphanumeric': 0.15664588779408808, 'fraction_numerical': 0.0008043434546551378, 'mean_word_length': 1.3994211287988423, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '3600578', 'n_tokens_mistral': 1413, 'n_tokens_neox': 1364, 'n_words': 249}