<commit_before>var utils = require('../utils');
var xhr = require('../xhr');
var settings = require('../settings');
var iScroll = require('iscroll');
var session = require('../session');
var i18n = require('../i18n');
var formWidgets = require('./_formWidgets');
var moment = require('moment');

var gamesMenu = {};

var isOpen = false;
var newGameCardSwapped = false;

gamesMenu.open = function() {
  isOpen = true;
};

gamesMenu.close = function() {
  isOpen = false;
};

gamesMenu.joinGame = function(id) {
  m.route('/play/' + id);
};

function startAIGame() {
  return xhr.newAiGame().then(function(data) {
    m.route('/play' + data.url.round);
  }, function(error) {
    utils.handleXhrError(error);
    throw new Error(error);
  });
}

function seekHumanGame() {
  return xhr.seekGame().then(function(data) {
    m.route('/seek/' + data.hook.id);
  }, function(error) {
    utils.handleXhrError(error);
    throw new Error(error);
  });
}

function swapCard() {
  newGameCardSwapped = !newGameCardSwapped;
}

function tupleOf(x) {
  return [x, x];
}

var humanVariants = [
  ['Standard', '1'],
  ['Chess960', '2'],
  ['King of the hill', '4'],
  ['Antichess', '6']
];
var aiVariants = [
  ['Standard', '1'],
  ['Chess960', '2'],
  ['King of the hill', '4']
];

function renderForm(action, settingsObj, variants) {
  var timeMode = settingsObj.timeMode();
  var hasClock = timeMode === '1';
  // var hasCorresp = timeMode === '2';

  var generalFieldset = [
    m('div.select_input', [
      formWidgets.renderSelect(i18n('color'), 'color', [
        [i18n('white'), 'white'],
        [i18n('black'), 'black'],
        [i18n('randomColor'), 'random']
      ], settingsObj.color),
    ]),
    m('div.select_input', [
      formWidgets.renderSelect(i18n('variant'), 'variant', variants, settingsObj.variant),
    ])
  ];
  if (settingsObj.level) {
    generalFieldset.push(m('div.select_input', [
      formWidgets.renderSelect(i18n('level'), 'ailevel', [
        '1', '2', '3', '4', '5', '6', '7', '8'
      ].map(tupleOf), settingsObj.level)
    ]));
  }
  if (settingsObj.mode) {
    generalFieldset.push(m('div.select_input', [
      formWidgets.renderSelect(i18n('mode'), 'mode', [
        [i18n('casual'), '0'],
        [i18n('rated'), '1']
      ], settingsObj.mode)
    ]));
  }

  var timeFieldset = [
    m('div.select_input', [
      formWidgets.renderSelect(i18n('clock'), 'timeMode', [
        [i18n('unlimited'), '0'],
        [i18n('realTime'), '1']
      ], settingsObj.timeMode)
    ])
  ];
  if (settingsObj.time && settingsObj.increment && hasClock) {
    timeFieldset.push(
      m('div.select_input.inline', [
        formWidgets.renderSelect(i18n('time'), 'time', [
          '2', '5', '10', '30', '60'
        ].map(tupleOf), settingsObj.time, false)
      ]),
      m('div.select_input.inline', [
        formWidgets.renderSelect(i18n('increment'), 'increment', [
          '0', '1', '2', '3', '5', '10'
        ].map(tupleOf), settingsObj.increment, false)
      ])
    );
  }
  if (settingsObj.timePreset && hasClock) {
    timeFieldset.push(m('div.select_input', [
      formWidgets.renderSelect(i18n('time'), 'timepreset', [
        '3+0', '3+2', '5+0', '5+3', '10+0', '30+0'
      ].map(tupleOf), settingsObj.timePreset, false)
    ]));
  }
  // if (hasCorresp) {
  //   timeFieldset.push(m('div.select_input', [
  //     formWidgets.renderSelect('Days per turn:', 'days', [
  //       '1', '2', '3', '5', '7', '10', '14'
  //       ].map(tupleOf), settingsObj.days, false)<commit_msg>Disable unlimited mode for now<commit_after>var utils = require('../utils');
var xhr = require('../xhr');
var settings = require('../settings');
var iScroll = require('iscroll');
var session = require('../session');
var i18n = require('../i18n');
var formWidgets = require('./_formWidgets');
var moment = require('moment');

var gamesMenu = {};

var isOpen = false;
var newGameCardSwapped = false;

gamesMenu.open = function() {
  isOpen = true;
};

gamesMenu.close = function() {
  isOpen = false;
};

gamesMenu.joinGame = function(id) {
  m.route('/play/' + id);
};

function startAIGame() {
  return xhr.newAiGame().then(function(data) {
    m.route('/play' + data.url.round);
  }, function(error) {
    utils.handleXhrError(error);
    throw new Error(error);
  });
}

function seekHumanGame() {
  return xhr.seekGame().then(function(data) {
    m.route('/seek/' + data.hook.id);
  }, function(error) {
    utils.handleXhrError(error);
    throw new Error(error);
  });
}

function swapCard() {
  newGameCardSwapped = !newGameCardSwapped;
}

function tupleOf(x) {
  return [x, x];
}

var humanVariants = [
  ['Standard', '1'],
  ['Chess960', '2'],
  ['King of the hill', '4'],
  ['Antichess', '6']
];
var aiVariants = [
  ['Standard', '1'],
  ['Chess960', '2'],
  ['King of the hill', '4']
];

function renderForm(action, settingsObj, variants) {
  var timeMode = settingsObj.timeMode();
  var hasClock = timeMode === '1';
  // var hasCorresp = timeMode === '2';

  var generalFieldset = [
    m('div.select_input', [
      formWidgets.renderSelect(i18n('color'), 'color', [
        [i18n('white'), 'white'],
        [i18n('black'), 'black'],
        [i18n('randomColor'), 'random']
      ], settingsObj.color),
    ]),
    m('div.select_input', [
      formWidgets.renderSelect(i18n('variant'), 'variant', variants, settingsObj.variant),
    ])
  ];
  if (settingsObj.level) {
    generalFieldset.push(m('div.select_input', [
      formWidgets.renderSelect(i18n('level'), 'ailevel', [
        '1', '2', '3', '4', '5', '6', '7', '8'
      ].map(tupleOf), settingsObj.level)
    ]));
  }
  if (settingsObj.mode) {
    generalFieldset.push(m('div.select_input', [
      formWidgets.renderSelect(i18n('mode'), 'mode', [
        [i18n('casual'), '0'],
        [i18n('rated'), '1']
      ], settingsObj.mode)
    ]));
  }

  var timeFieldset = [
    m('div.select_input', [
      formWidgets.renderSelect(i18n('clock'), 'timeMode', [
        // [i18n('unlimited'), '0'],
        [i18n('realTime'), '1']
      ], settingsObj.timeMode)
    ])
  ];
  if (settingsObj.time && settingsObj.increment && hasClock) {
    timeFieldset.push(
      m('div.select_input.inline', [
        formWidgets.renderSelect(i18n('time'), 'time', [
          '2', '5', '10', '30', '60'
        ].map(tupleOf), settingsObj.time, false)
      ]),
      m('div.select_input.inline', [
        formWidgets.renderSelect(i18n('increment'), 'increment', [
          '0', '1', '2', '3', '5', '10'
        ].map(tupleOf), settingsObj.increment, false)
      ])
    );
  }
  if (settingsObj.timePreset && hasClock) {
    timeFieldset.push(m('div.select_input', [
      formWidgets.renderSelect(i18n('time'), 'timepreset', [
        '3+0', '3+2', '5+0', '5+3', '10+0', '30+0'
      ].map(tupleOf), settingsObj.timePreset, false)
    ]));
  }
  // if (hasCorresp) {
  //   timeFieldset.push(m('div.select_input', [
  //     formWidgets.renderSelect('Days per turn:', 'days', [
  //       '1', '2', '3', '5', '7', '10', '14'
  //       ].map(tupleOf), settingsObj.days, false)
{'fraction_non_alphanumeric': 0.21139132898838198, 'fraction_numerical': 0.028053272881836216, 'mean_word_length': 3.237094837935174, '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': '3603496', 'n_tokens_mistral': 2619, 'n_tokens_neox': 2530, 'n_words': 455}