<commit_before>/*
 * jQuery ShogiBoard plugin
 */
(function($) {


var _suffix = 0;

var boardCell = function(x, y, suffix) {
  return $('#jsb_'+x+'_'+y+'_'+suffix);
};

var boardSet = function(board, config) {
  var suffix = config['suffix'];
  for (var x = 1; x <= 9; x++) {
    for (var y = 1; y <= 9; y++) {
      var cell  = boardCell(x, y, suffix).empty();
      var piece = board[x][y];
      if (piece) {
        cell.append(pieceImgTag(piece['piece'], piece['black'], config));
      } else {
        cell.append('&nbsp;');
      }
    }
  }
};

var moveNext = function(kifu, config) {
  var move = kifu.next();
  if (!move || move['type'] != 'move') {
    return;
  }

  var from  = move['from'];
  var to    = move['to'];
  var black = move['black'];
  var piece = to['piece'];
  var stand = move['stand'];

  if (from['x'] == 0) {
    standRemove(piece, black, config);
  } else {
    pieceRemove(from['x'], from['y'], config);
  }

  pieceSet(to['x'], to['y'], piece, black, config);

  if (stand) {
    standSet(stand['stand'], black, config);
  }

  var suffix = config['suffix'];
  $('#jsb_moves_'+suffix).val(kifu.step);
  $('#jsb_comment_'+suffix).text(move['comment']);
};

var movePrev = function(kifu, config) {
  var move = kifu.prev();
  if (!move || move['type'] != 'move') {
    return;
  }

  var from  = move['from'];
  var to    = move['to'];
  var black = move['black'];
  var piece = to['piece'];
  var stand = move['stand'];

  if (from['x']) {
    pieceSet(from['x'], from['y'], from['piece'], black, config);
  } else {
    standSet(from['piece'], black, config);
  }

  if (stand) {
    pieceSet(to['x'], to['y'], stand['piece'], !black, config);
    standRemove(stand['stand'], black, config);
  } else {
    pieceRemove(to['x'], to['y'], config);
  }

  $('#jsb_moves_'+config['suffix']).val(kifu.step);
};

var moveStringsSet = function(moves, suffix) {
  var ele = $('#jsb_moves_'+suffix);
  for (var i in moves) {
    var move = moves[i];
    if (move['str']) {
      ele.append($('<option>').attr({value: i}).text(i+' '+move['str']));
    }
  }
};

var pieceImgTag = function(piece, black, config) {
  var name = piece.toLowerCase();
  if (!black) {
    name += '_r';
  }
  var image_url = config['url_prefix'] + '/images/' + name + '.png';

  return '<img src="' + image_url + '" />';
};<commit_msg>fixed comments<commit_after>/*
 * jQuery ShogiBoard plugin
 */
(function($) {


var _suffix = 0;

var boardCell = function(x, y, suffix) {
  return $('#jsb_'+x+'_'+y+'_'+suffix);
};

var boardSet = function(board, config) {
  var suffix = config['suffix'];
  for (var x = 1; x <= 9; x++) {
    for (var y = 1; y <= 9; y++) {
      var cell  = boardCell(x, y, suffix).empty();
      var piece = board[x][y];
      if (piece) {
        cell.append(pieceImgTag(piece['piece'], piece['black'], config));
      } else {
        cell.append('&nbsp;');
      }
    }
  }
};

var moveNext = function(kifu, config) {
  var move = kifu.next();
  if (!move || move['type'] != 'move') {
    return;
  }

  var from  = move['from'];
  var to    = move['to'];
  var black = move['black'];
  var piece = to['piece'];
  var stand = move['stand'];

  if (from['x'] == 0) {
    standRemove(piece, black, config);
  } else {
    pieceRemove(from['x'], from['y'], config);
  }

  pieceSet(to['x'], to['y'], piece, black, config);

  if (stand) {
    standSet(stand['stand'], black, config);
  }

  var suffix = config['suffix'];
  $('#jsb_moves_'+suffix).val(kifu.step);
  if (move['comment']) {
    $('#jsb_comment_'+suffix).text(move['comment']);
  } else {
    $('#jsb_comment_'+suffix).text('');
  }
};

var movePrev = function(kifu, config) {
  var move = kifu.prev();
  if (!move || move['type'] != 'move') {
    return;
  }

  var from  = move['from'];
  var to    = move['to'];
  var black = move['black'];
  var piece = to['piece'];
  var stand = move['stand'];

  if (from['x']) {
    pieceSet(from['x'], from['y'], from['piece'], black, config);
  } else {
    standSet(from['piece'], black, config);
  }

  if (stand) {
    pieceSet(to['x'], to['y'], stand['piece'], !black, config);
    standRemove(stand['stand'], black, config);
  } else {
    pieceRemove(to['x'], to['y'], config);
  }

  var move_prev = kifu.moves.get(kifu.step);
  var suffix = config['suffix'];
  $('#jsb_moves_'+suffix).val(kifu.step);
  if (move_prev['comment']) {
    $('#jsb_comment_'+suffix).text(move_prev['comment']);
  } else {
    $('#jsb_comment_'+suffix).text('');
  }
};

var moveStringsSet = function(moves, suffix) {
  var ele = $('#jsb_moves_'+suffix);
  for (var i in moves) {
    var move = moves[i];
    if (move['str']) {
      ele.append($('<option>').attr({value: i}).text(i+' '+move['str']));
    }
  }
};

var pieceImgTag = function(piece, black, config) {
  var name = piece.toLowerCase();
  if (!black) {
    name += '_r';
  }
  var image_url = config['url_prefix'] + '/images/' + name + '.png';

  return '<img src="' + image_url + '" />';
};
{'fraction_non_alphanumeric': 0.2312022517088862, 'fraction_numerical': 0.0024125452352231603, 'mean_word_length': 3.3449781659388647, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '1520802', 'n_tokens_mistral': 1859, 'n_tokens_neox': 1813, 'n_words': 412}