<commit_before>var m = require('mithril');
var fixCrazySan = require('chess').fixCrazySan;
var normalizeEval = require('chess').renderEval;
var defined = require('common').defined;
var getBestEval = require('ceval').view.getBestEval;

function plyToTurn(ply) {
  return Math.floor((ply - 1) / 2) + 1;
}

function renderGlyphs(glyphs) {
  return glyphs.map(function(glyph) {
    return {
      tag: 'glyph',
      attrs: {
        title: glyph.name
      },
      children: [glyph.symbol]
    };
  });
}

function renderEval(e) {
  return {
    tag: 'eval',
    children: [e]
  };
}

function renderIndex(ply, withDots) {
  return {
    tag: 'index',
    children: [
      plyToTurn(ply) + (withDots ? (ply % 2 === 1 ? '.' : '...') : '')
    ]
  };
}

function renderMove(ctx, node) {
  var eval = getBestEval({client: node.ceval, server: node.eval});
  return [
    fixCrazySan(node.san), (node.glyphs && ctx.showGlyphs) ? renderGlyphs(node.glyphs) : null,
    ctx.showEval ? (
      defined(eval.cp) ? renderEval(normalizeEval(eval.cp)) : (
        defined(eval.mate) ? renderEval('#' + eval.mate) : null
      )
    ) : null,
  ];
}

module.exports = {
  renderIndexAndMove: function(ctx, node) {
    return node.uci ? [
      renderIndex(node.ply, ctx.withDots),
      renderMove(ctx, node)
    ] : m('span.init', 'Initial position');
  },
  renderIndex: renderIndex,
  renderMove: renderMove,
  renderGlyphs: renderGlyphs
};<commit_msg>fix analysis moveView.renderMove<commit_after>var m = require('mithril');
var fixCrazySan = require('chess').fixCrazySan;
var normalizeEval = require('chess').renderEval;
var defined = require('common').defined;
var getBestEval = require('ceval').view.getBestEval;

function plyToTurn(ply) {
  return Math.floor((ply - 1) / 2) + 1;
}

function renderGlyphs(glyphs) {
  return glyphs.map(function(glyph) {
    return {
      tag: 'glyph',
      attrs: {
        title: glyph.name
      },
      children: [glyph.symbol]
    };
  });
}

function renderEval(e) {
  return {
    tag: 'eval',
    children: [e]
  };
}

function renderIndex(ply, withDots) {
  return {
    tag: 'index',
    children: [
      plyToTurn(ply) + (withDots ? (ply % 2 === 1 ? '.' : '...') : '')
    ]
  };
}

function renderMove(ctx, node) {
  var eval = getBestEval({client: node.ceval, server: node.eval}) || {};
  return [
    fixCrazySan(node.san), (node.glyphs && ctx.showGlyphs) ? renderGlyphs(node.glyphs) : null,
    ctx.showEval ? (
      defined(eval.cp) ? renderEval(normalizeEval(eval.cp)) : (
        defined(eval.mate) ? renderEval('#' + eval.mate) : null
      )
    ) : null,
  ];
}

module.exports = {
  renderIndexAndMove: function(ctx, node) {
    return node.uci ? [
      renderIndex(node.ply, ctx.withDots),
      renderMove(ctx, node)
    ] : m('span.init', 'Initial position');
  },
  renderIndex: renderIndex,
  renderMove: renderMove,
  renderGlyphs: renderGlyphs
};
{'fraction_non_alphanumeric': 0.16626506024096385, 'fraction_numerical': 0.0034423407917383822, 'mean_word_length': 3.175287356321839, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2198499', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1022, 'n_words': 192}