<commit_before>var m = require('mithril');
var Chessground = require('chessground').Chessground;

module.exports = function(ctrl) {
  return m('div.cg-board-wrap', {
    config: function(el, isUpdate, ctx) {
      if (!isUpdate) {
        ctrl.chessground = Chessground(el, makeConfig(ctrl));
        ctrl.setAutoShapes();
        if (ctrl.vm.node.shapes) ctrl.chessground.setShapes(ctrl.vm.node.shapes);
        ctx.onunload = ctrl.chessground.destroy;
      }
    }
  });
}

var global3d = document.getElementById('top').classList.contains('is3d');

function makeConfig(ctrl) {
  var opts = ctrl.makeCgOpts();
  var config = {
    fen: opts.fen,
    check: opts.check,
    lastMove: opts.lastMove,
    orientation: ctrl.data.orientation,
    coordinates: ctrl.data.pref.coords !== 0,
    addPieceZIndex: ctrl.data.pref.is3d || global3d,
    viewOnly: !!ctrl.embed,
    movable: {
      free: false,
      color: opts.movable.color,
      dests: opts.movable.dests,
      rookCastle: ctrl.data.pref.rookCastle
    },
    events: {
      move: ctrl.userMove,
      dropNewPiece: ctrl.userNewPiece
    },
    premovable: {
      enabled: opts.premovable
    },
    drawable: {
      enabled: true,
      eraseOnClick: !ctrl.opts.study || ctrl.opts.practice
    },
    highlight: {
      lastMove: ctrl.data.pref.highlight,
      check: ctrl.data.pref.highlight
    },
    animation: {
      enabled: true,
      duration: ctrl.data.pref.animationDuration
    },
    disableContextMenu: true
  };
  ctrl.study && ctrl.study.mutateCgConfig(config);
  return config;
}

module.exports.promote = function(ground, key, role) {
  var pieces = {};
  var piece = ground.state.pieces[key];
  if (piece && piece.role == 'pawn') {
    pieces[key] = {
      color: piece.color,
      role: role
    };
    ground.setPieces(pieces);
  }
}
<commit_msg>fix hack<commit_after>var m = require('mithril');
var Chessground = require('chessground').Chessground;

module.exports = function(ctrl) {
  return m('div.cg-board-wrap', {
    config: function(el, isUpdate, ctx) {
      if (!isUpdate) {
        ctrl.chessground = Chessground(el, makeConfig(ctrl));
        ctrl.setAutoShapes();
        if (ctrl.vm.node.shapes) ctrl.chessground.setShapes(ctrl.vm.node.shapes);
        ctx.onunload = ctrl.chessground.destroy;
      }
    }
  });
}

var global3d = !!document.querySelector('#top.is3d');

function makeConfig(ctrl) {
  var opts = ctrl.makeCgOpts();
  var config = {
    fen: opts.fen,
    check: opts.check,
    lastMove: opts.lastMove,
    orientation: ctrl.data.orientation,
    coordinates: ctrl.data.pref.coords !== 0,
    addPieceZIndex: ctrl.data.pref.is3d || global3d,
    viewOnly: !!ctrl.embed,
    movable: {
      free: false,
      color: opts.movable.color,
      dests: opts.movable.dests,
      rookCastle: ctrl.data.pref.rookCastle
    },
    events: {
      move: ctrl.userMove,
      dropNewPiece: ctrl.userNewPiece
    },
    premovable: {
      enabled: opts.premovable
    },
    drawable: {
      enabled: true,
      eraseOnClick: !ctrl.opts.study || ctrl.opts.practice
    },
    highlight: {
      lastMove: ctrl.data.pref.highlight,
      check: ctrl.data.pref.highlight
    },
    animation: {
      enabled: true,
      duration: ctrl.data.pref.animationDuration
    },
    disableContextMenu: true
  };
  ctrl.study && ctrl.study.mutateCgConfig(config);
  return config;
}

module.exports.promote = function(ground, key, role) {
  var pieces = {};
  var piece = ground.state.pieces[key];
  if (piece && piece.role == 'pawn') {
    pieces[key] = {
      color: piece.color,
      role: role
    };
    ground.setPieces(pieces);
  }
}

{'fraction_non_alphanumeric': 0.1408605097286928, 'fraction_numerical': 0.0027404768429706767, 'mean_word_length': 2.7590113285272913, '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': '1428072', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1246, 'n_words': 219}