<commit_before>import { h } from 'snabbdom'
import { VNode } from 'snabbdom/vnode'
import { AnalyseData, MaybeVNodes } from './interfaces';
import { AutoplayDelay } from './autoplay';
import AnalyseController from './ctrl';
import { router } from 'game';
import { synthetic, bind, dataIcon } from './util';
import * as pgnExport from './pgnExport';

interface AutoplaySpeed {
  name: string;
  delay: AutoplayDelay;
}

const baseSpeeds: AutoplaySpeed[] = [{
  name: 'fast',
  delay: 1000
}, {
  name: 'slow',
  delay: 5000
}];

const allSpeeds = baseSpeeds.concat({
  name: 'realtime',
  delay: 'realtime'
});

const cplSpeeds: AutoplaySpeed[] = [{
  name: 'by CPL',
  delay: 'cpl_slow'
}];

function deleteButton(data: AnalyseData, userId: string): VNode | undefined {
  const g = data.game;
  if (g.source === 'import' &&
    g.importedBy && g.importedBy === userId)
  return h('form.delete', {
    attrs: {
      method: 'post',
      action: '/' + g.id + '/delete'
    },
    hook: bind('submit', _ => confirm('Delete this imported game?'))
  }, [
    h('button.button.text.thin', {
      attrs: {
        type: 'submit',
        'data-icon': 'q'
      }
    }, 'Delete')
  ]);
  return;
}

function autoplayButtons(ctrl: AnalyseController): VNode {
  const d = ctrl.data;
  let speeds = (d.game.moveCentis && d.game.moveCentis.length) ? allSpeeds : baseSpeeds;
  speeds = d.analysis ? speeds.concat(cplSpeeds) : speeds;
  return h('div.autoplay', speeds.map(speed => {
    return h('a.fbt', {
      class: { active: ctrl.autoplay.active(speed.delay) },
      hook: bind('click', () => ctrl.togglePlay(speed.delay))<commit_msg>ui/analyse autoplay redraw<commit_after>import { h } from 'snabbdom'
import { VNode } from 'snabbdom/vnode'
import { AnalyseData, MaybeVNodes } from './interfaces';
import { AutoplayDelay } from './autoplay';
import AnalyseController from './ctrl';
import { router } from 'game';
import { synthetic, bind, dataIcon } from './util';
import * as pgnExport from './pgnExport';

interface AutoplaySpeed {
  name: string;
  delay: AutoplayDelay;
}

const baseSpeeds: AutoplaySpeed[] = [{
  name: 'fast',
  delay: 1000
}, {
  name: 'slow',
  delay: 5000
}];

const allSpeeds = baseSpeeds.concat({
  name: 'realtime',
  delay: 'realtime'
});

const cplSpeeds: AutoplaySpeed[] = [{
  name: 'by CPL',
  delay: 'cpl_slow'
}];

function deleteButton(data: AnalyseData, userId: string): VNode | undefined {
  const g = data.game;
  if (g.source === 'import' &&
    g.importedBy && g.importedBy === userId)
  return h('form.delete', {
    attrs: {
      method: 'post',
      action: '/' + g.id + '/delete'
    },
    hook: bind('submit', _ => confirm('Delete this imported game?'))
  }, [
    h('button.button.text.thin', {
      attrs: {
        type: 'submit',
        'data-icon': 'q'
      }
    }, 'Delete')
  ]);
  return;
}

function autoplayButtons(ctrl: AnalyseController): VNode {
  const d = ctrl.data;
  let speeds = (d.game.moveCentis && d.game.moveCentis.length) ? allSpeeds : baseSpeeds;
  speeds = d.analysis ? speeds.concat(cplSpeeds) : speeds;
  return h('div.autoplay', speeds.map(speed => {
    return h('a.fbt', {
      class: { active: ctrl.autoplay.active(speed.delay) },
      hook: bind('click', () => ctrl.togglePlay(speed.delay), ctrl.redraw)
{'fraction_non_alphanumeric': 0.17001216545012166, 'fraction_numerical': 0.004866180048661801, 'mean_word_length': 3.4931693989071038, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '7193990', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1149, 'n_words': 270}