<commit_before>require(['jquery'], function ($) {
  var jsonBase      = wity_base_url + 'm/crs/json',
      refreshTimer  = 1, // In seconds
      $crs_app      = $('.wity-app-crs.wity-app-crs-index'),
      $heroes_list  = $crs_app.find('ul.heroes-list'),
      $players_list = $crs_app.find('ul.players-list'),
      $safari_timer = $crs_app.find('div.safari-timer');

  function refreshContent() {
    $.getJSON(jsonBase, function (json) {
      var result = json.result;

      // Display the target on the correct hero
      $heroes_list
        .find('li')
        .removeClass('target');

      $heroes_list
        .find('li:nth-child(' + result.target + ')')
        .addClass('target');

      // Refresh target kill count
      var players = result.players,
                i = 1;

      $players_list.empty();

      players.forEach(function (player) {
        $player = $('<li>').addClass('player-' + i).text(player.name + ' : ' + player.kills);

        $players_list.append($player);

        i++;
      });

      // Refresh safari timer
      var options = result.options;
      if ('timer' in options) {
        var timer = options.timer;

        $safari_timer
          .css('top', (parseInt($players_list.css('top'), 10) + parseInt($players_list.css('height'), 10) + 10) + 'px')
          .text('Safari : ' + timer);
      }
    });
  }

  // When the DOM is ready
  $(function () {
    refreshContent();

    setInterval(refreshContent, refreshTimer * 1000);
  });
});<commit_msg>Améliorations du code JS<commit_after>require(['jquery'], function ($) {
  var jsonBase      = wity_base_url + 'm/crs/json',
      refreshTimer  = 1, // In seconds
      $crs_app      = $('.wity-app-crs.wity-app-crs-index'),
      $heroes_list  = $crs_app.find('ul.heroes-list'),
      $players_list = $crs_app.find('ul.players-list'),
      $safari_timer = $crs_app.find('div.safari-timer');

  function refreshContent() {
    $.getJSON(jsonBase, function (json) {
      if (!('result' in json)) {
        return;
      }

      var result = json.result;

      // Display the target on the correct hero
      $heroes_list
        .find('li')
        .removeClass('target');

      if ('target' in result) {
        $heroes_list
          .find('li:nth-child(' + result.target + ')')
          .addClass('target');
      }

      // Refresh target kill count
      $players_list.empty();

      if ('players' in result) {
        var players = result.players;

        $.each(players, function (index, player) {
          var $player = $('<li>').addClass('player-' + (index + 1)).text(player.name + ' : ' + player.kills);

          $players_list.append($player);
        });
      }

      // Refresh safari timer
      if ('options' in result) {
        var options = result.options;

        if ('timer' in options) {
          var timer = options.timer;

          $safari_timer
            .css('top', (parseInt($players_list.css('top'), 10) + parseInt($players_list.css('height'), 10) + 10) + 'px')
            .text('Safari : ' + timer);
        }
      }
    });
  }

  // When the DOM is ready
  $(function () {
    refreshContent();

    setInterval(refreshContent, refreshTimer * 1000);
  });
});
{'fraction_non_alphanumeric': 0.16791277258566978, 'fraction_numerical': 0.007476635514018692, 'mean_word_length': 2.188679245283019, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3554363', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1038, 'n_words': 203}