<commit_before>var m = require('mithril');
var title = require('./title');
var blur = require('./blur');
var round = require('./round');
var game = require('game').game;
var status = require('game').status;
var keyboard = require('./keyboard');
var k = Mousetrap;

module.exports = {

  startPly: function(data) {
    var lp = round.lastPly(data);
    if (data.player.spectator) return lp;
    if ((lp % 2 === 1) === (data.player.color === 'white')) return lp;
    return Math.max(lp - 1, round.firstPly(data));
  },
  yolo: function(ctrl) {

    var d = ctrl.data;

    title.init(ctrl);
    ctrl.setTitle();
    blur.init(ctrl);

    if (game.isPlayerPlaying(d) && game.nbMoves(d, d.player.color) === 0) $.sound.genericNotify();

    if (game.isPlayerPlaying(d)) {
      window.addEventListener('beforeunload', function(e) {
        if (!lichess.hasToReload && !ctrl.data.blind && game.playable(ctrl.data) && ctrl.data.clock) {
          document.body.classList.remove('fpmenu');
          ctrl.socket.send('bye');
          var msg = 'There is a game in progress!';
          (e || window.event).returnValue = msg;
          return msg;
        }
      });
      k.bind(['esc'], ctrl.chessground.cancelMove);
    }

    keyboard.init(ctrl);

    if (!ctrl.data.player.spectator && ctrl.vm.ply !== round.lastPly(ctrl.data))
      setTimeout(function() {
        ctrl.vm.initializing = false;
        if (ctrl.jump(round.lastPly(ctrl.data))) m.redraw();
      }, 500);
    else ctrl.vm.initializing = false;
  }
};
<commit_msg>play initial move faster<commit_after>var m = require('mithril');
var title = require('./title');
var blur = require('./blur');
var round = require('./round');
var game = require('game').game;
var status = require('game').status;
var keyboard = require('./keyboard');
var k = Mousetrap;

module.exports = {

  startPly: function(data) {
    var lp = round.lastPly(data);
    if (data.player.spectator) return lp;
    if ((lp % 2 === 1) === (data.player.color === 'white')) return lp;
    return Math.max(lp - 1, round.firstPly(data));
  },
  yolo: function(ctrl) {

    var d = ctrl.data;

    title.init(ctrl);
    ctrl.setTitle();
    blur.init(ctrl);

    if (game.isPlayerPlaying(d) && game.nbMoves(d, d.player.color) === 0) $.sound.genericNotify();

    if (game.isPlayerPlaying(d)) {
      window.addEventListener('beforeunload', function(e) {
        if (!lichess.hasToReload && !ctrl.data.blind && game.playable(ctrl.data) && ctrl.data.clock) {
          document.body.classList.remove('fpmenu');
          ctrl.socket.send('bye');
          var msg = 'There is a game in progress!';
          (e || window.event).returnValue = msg;
          return msg;
        }
      });
      k.bind(['esc'], ctrl.chessground.cancelMove);
    }

    keyboard.init(ctrl);

    if (!ctrl.data.player.spectator && ctrl.vm.ply !== round.lastPly(ctrl.data))
      setTimeout(function() {
        ctrl.vm.initializing = false;
        if (ctrl.jump(round.lastPly(ctrl.data))) m.redraw();
      }, 200);
    else ctrl.vm.initializing = false;
  }
};

{'fraction_non_alphanumeric': 0.18193674600586893, 'fraction_numerical': 0.004564721225953701, 'mean_word_length': 2.9033078880407124, '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': '3353795', 'n_tokens_mistral': 1032, 'n_tokens_neox': 999, 'n_words': 205}