<commit_before>var utils = require('./utils');
var http = require('./http');
var settings = require('./settings');
var i18n = require('./i18n');
var moment = window.moment;
var session = require('./session');

function newAiGame() {
  var config = settings.game.ai;
  return http.request('/setup/ai', {
    method: 'POST',
    data: {
      variant: config.variant(),
      timeMode: config.timeMode(),
      days: config.days(),
      time: config.time(),
      increment: config.increment(),
      level: config.level(),
      color: config.color()
    }
  }, true);
}

function seekGame() {
  var config = settings.game.human;
  return http.request('/setup/hook/' + utils.lichessSri, {
    method: 'POST',
    data: {
      variant: config.variant(),
      timeMode: config.timeMode(),
      days: config.days(),
      time: config.time(),
      increment: config.increment(),
      color: 'random',
      mode: session.isConnected() ? config.mode() : '0',
      ratingRange: config.ratingMin() + '-' + config.ratingMax()
    }
  }, true);
}

function inviteFriend(userId) {
  var config = settings.game.challenge;
  return http.request('/setup/friend', {
    method: 'POST',
    data: {
      user: userId,
      variant: config.variant(),
      timeMode: config.timeMode(),
      days: config.days(),
      time: config.time(),
      increment: config.increment(),
      color: config.color(),
      mode: session.isConnected() ? config.mode() : '0'
    }
  }, true);
}

function cancelChallenge(url) {
  return http.request(url + '/cancel');
}

function joinChallenge(id) {
  return http.request('/' + id + '/join', { method: 'POST' }, true);
}

function getChallenge(id) {
  return http.request('/' + id, { background: true });
}

function declineChallenge(id) {
  return http.request('/setup/decline?gameId=' + id, {
    method: 'POST',
    deserialize: v => v
  }, true);
}

function lobby(feedback) {
  return http.request('/', null, feedback);
}

function seeks(feedback) {
  return http.request('/lobby/seeks', null, feedback);
}

function game(id, color) {
  var url = '/' + id;
  if (color) url += ('/' + color);
  return http.request(url, { background: true });
}

function toggleGameBookmark(id) {
  return http.request('/bookmark/' + id, {
    method: 'POST',
    deserialize: v => v
  });
}

function featured(flip) {
  return http.request('/tv/lichess', flip ? { data: { flip: 1 }} : {});
}

function status() {
  return http.request('/api/status', {
    background: true
  }).then(function(data) {
    if (data.api.current !== http.apiVersion) {
      for (var i = 0, len = data.api.olds.length; i < len; i++) {<commit_msg>new TV API URL (BC ensured by server)<commit_after>var utils = require('./utils');
var http = require('./http');
var settings = require('./settings');
var i18n = require('./i18n');
var moment = window.moment;
var session = require('./session');

function newAiGame() {
  var config = settings.game.ai;
  return http.request('/setup/ai', {
    method: 'POST',
    data: {
      variant: config.variant(),
      timeMode: config.timeMode(),
      days: config.days(),
      time: config.time(),
      increment: config.increment(),
      level: config.level(),
      color: config.color()
    }
  }, true);
}

function seekGame() {
  var config = settings.game.human;
  return http.request('/setup/hook/' + utils.lichessSri, {
    method: 'POST',
    data: {
      variant: config.variant(),
      timeMode: config.timeMode(),
      days: config.days(),
      time: config.time(),
      increment: config.increment(),
      color: 'random',
      mode: session.isConnected() ? config.mode() : '0',
      ratingRange: config.ratingMin() + '-' + config.ratingMax()
    }
  }, true);
}

function inviteFriend(userId) {
  var config = settings.game.challenge;
  return http.request('/setup/friend', {
    method: 'POST',
    data: {
      user: userId,
      variant: config.variant(),
      timeMode: config.timeMode(),
      days: config.days(),
      time: config.time(),
      increment: config.increment(),
      color: config.color(),
      mode: session.isConnected() ? config.mode() : '0'
    }
  }, true);
}

function cancelChallenge(url) {
  return http.request(url + '/cancel');
}

function joinChallenge(id) {
  return http.request('/' + id + '/join', { method: 'POST' }, true);
}

function getChallenge(id) {
  return http.request('/' + id, { background: true });
}

function declineChallenge(id) {
  return http.request('/setup/decline?gameId=' + id, {
    method: 'POST',
    deserialize: v => v
  }, true);
}

function lobby(feedback) {
  return http.request('/', null, feedback);
}

function seeks(feedback) {
  return http.request('/lobby/seeks', null, feedback);
}

function game(id, color) {
  var url = '/' + id;
  if (color) url += ('/' + color);
  return http.request(url, { background: true });
}

function toggleGameBookmark(id) {
  return http.request('/bookmark/' + id, {
    method: 'POST',
    deserialize: v => v
  });
}

function featured(flip) {
  return http.request('/tv', flip ? { data: { flip: 1 }} : {});
}

function status() {
  return http.request('/api/status', {
    background: true
  }).then(function(data) {
    if (data.api.current !== http.apiVersion) {
      for (var i = 0, len = data.api.olds.length; i < len; i++) {
{'fraction_non_alphanumeric': 0.1820067898906073, 'fraction_numerical': 0.003017729158807997, 'mean_word_length': 3.114041892940264, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4784829', 'n_tokens_mistral': 1716, 'n_tokens_neox': 1701, 'n_words': 403}