<commit_before>var m = require('mithril');
var contextMenu = require('../contextMenu');
var raf = require('chessground').util.requestAnimationFrame;
var util = require('../util');
var defined = util.defined;
var empty = util.empty;
var game = require('game').game;

var autoScroll = util.throttle(300, false, function(el) {
  raf(function() {
    var target = el.querySelector('.active') || el.querySelector('move:first-child');
    if (!target) return;
    var cont = el.parentNode;
    var scroll = target.offsetTop - cont.offsetHeight / 2 + target.offsetHeight / 2;
    // console.log(scroll);
    // cont.scrollTop = scroll;
  });
});

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

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

function renderChildrenOf(ctx, node, opts) {
  var cs = node.children;
  var main = cs[0];
  if (!main) return;
  if (opts.isMainline) {
    var isWhite = main.ply % 2 === 1;
    var commentTags = renderMainlineCommentsOf(ctx, main);
    if (!cs[1] && empty(commentTags)) return [
      isWhite ? renderIndex(main.ply, false) : null,
      renderMoveAndChildrenOf(ctx, main, opts)
    ];
    return [
      isWhite ? renderIndex(main.ply, false) : null,
      renderMoveOf(ctx, main, {
        parentPath: opts.parentPath,
        isMainline: true
      }),
      isWhite ? emptyMove() : null,
      m('interrupt', [
        commentTags,
        renderLines(ctx, cs.slice(1), {
          parentPath: opts.parentPath
        })
      ]),
      isWhite ? [
        renderIndex(main.ply, false),
        emptyMove()
      ] : null,
      renderChildrenOf(ctx, main, {
        parentPath: opts.parentPath + main.id,
        isMainline: true
      })
    ];<commit_msg>fix view of last comment<commit_after>var m = require('mithril');
var contextMenu = require('../contextMenu');
var raf = require('chessground').util.requestAnimationFrame;
var util = require('../util');
var defined = util.defined;
var empty = util.empty;
var game = require('game').game;

var autoScroll = util.throttle(300, false, function(el) {
  raf(function() {
    var target = el.querySelector('.active') || el.querySelector('move:first-child');
    if (!target) return;
    var cont = el.parentNode;
    var scroll = target.offsetTop - cont.offsetHeight / 2 + target.offsetHeight / 2;
    // console.log(scroll);
    // cont.scrollTop = scroll;
  });
});

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

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

function renderChildrenOf(ctx, node, opts) {
  var cs = node.children;
  var main = cs[0];
  if (!main) return;
  if (opts.isMainline) {
    var isWhite = main.ply % 2 === 1;
    var commentTags = renderMainlineCommentsOf(ctx, main);
    if (!cs[1] && empty(commentTags)) return [
      isWhite ? renderIndex(main.ply, false) : null,
      renderMoveAndChildrenOf(ctx, main, opts)
    ];
    var mainChildren = renderChildrenOf(ctx, main, {
      parentPath: opts.parentPath + main.id,
      isMainline: true
    });
    return [
      isWhite ? renderIndex(main.ply, false) : null,
      renderMoveOf(ctx, main, {
        parentPath: opts.parentPath,
        isMainline: true
      }),
      isWhite ? emptyMove() : null,
      m('interrupt', [
        commentTags,
        renderLines(ctx, cs.slice(1), {
          parentPath: opts.parentPath
        })
      ]),
      isWhite && mainChildren ? [
        renderIndex(main.ply, false),
        emptyMove()
      ] : null,
      mainChildren
    ];
{'fraction_non_alphanumeric': 0.15508021390374332, 'fraction_numerical': 0.008021390374331552, 'mean_word_length': 2.7298105682951146, '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': '906951', 'n_tokens_mistral': 1230, 'n_tokens_neox': 1201, 'n_words': 274}