<commit_before>$(function(){

  var socket = io();

  $.get('/get/messages', function( data ) {
    $.each(data.messages, function( index, message ) {
      if( ! message.user )
        addBotMessage( message.time, message.message );
      else
        addMessage( message.time, message.user, message.message );
    });
  }, 'json');

  $('.form-chat').submit(function(){
    send($('#message').val());
    $('#message').val('');
    return false;
  });

  $( window ).focus(function() {
    titleNotification.off();
  });

  socket.on('user_new', function() {
    $("ul#clients").text("");
  });

  socket.on('user_connected', function( user ) {
    $("ul#clients").append('<li style="color:' + user.groupColor + ';" class="' + user.id + '"> <img class="img-circle" src="' + user.avatar + '">' + user.name + '</li>');
  });

  socket.on('user_disconnected', function( userid ) {
    $("ul#clients li." + userid).remove();
  });

  socket.on('already_connected', function() {
    alert('Vous êtes déjà connecté, connexion au chat impossible !');
  });

  socket.on('message', function( time, user, message ) {
    addMessage( time, user, message );
  });

  socket.on('botMessage', function( time, message ) {
    addBotMessage( time, message );
  });

  var send = function( message ) {
    socket.emit('message', message);
  };

  var addMessage = function( time, user, message ) {
    if( ! document.hasFocus() ) {
      titleNotification.on("Nouveau message !");
    }
    $('#messages').append('<li>(' + time + ') <b><span style="color:' + user.groupColor + ';">' + user.name + '</span>:</b> ' + message + '</li>');
    $("#messages").scrollTop($("#messages")[0].scrollHeight);
  };<commit_msg>Correction d'un problème de synchronisation<commit_after>$(function(){

  var socket = io();

  socket.on('connect', function() {

    socket.on('user_new', function() {
      $("ul#clients").text("");
    });

    socket.on('user_connected', function( user ) {
      $("ul#clients").append('<li style="color:' + user.groupColor + ';" class="' + user.id + '"> <img class="img-circle" src="' + user.avatar + '">' + user.name + '</li>');
    });

    socket.on('user_disconnected', function( userid ) {
      $("ul#clients li." + userid).remove();
    });

    socket.on('already_connected', function() {
      alert('Vous êtes déjà connecté, connexion au chat impossible !');
    });

    initMessageList(function() {
      socket.on('message', function( time, user, message ) {
        addMessage( time, user, message );
      });

      socket.on('botMessage', function( time, message ) {
        addBotMessage( time, message );
      });
    });
  });

  $('.form-chat').submit(function(){
    send($('#message').val());
    $('#message').val('');
    return false;
  });

  $( window ).focus(function() {
    titleNotification.off();
  });

  var initMessageList = function( callback ) {
    $.get('/get/messages', function( data ) {
      $.each(data.messages, function( index, message ) {
        if( ! message.user )
          addBotMessage( message.time, message.message );
        else
          addMessage( message.time, message.user, message.message );
      });
      callback();
    }, 'json');
  };

  var send = function( message ) {
    socket.emit('message', message);
  };

  var addMessage = function( time, user, message ) {
    if( ! document.hasFocus() ) {
      titleNotification.on("Nouveau(x) message(s) !");
    }
    $('#messages').append('<li>(' + time + ') <b><span style="color:' + user.groupColor + ';">' + user.name + '</span>:</b> ' + message + '</li>');
    $("#messages").scrollTop($("#messages")[0].scrollHeight);
  };
{'fraction_non_alphanumeric': 0.21960569550930997, 'fraction_numerical': 0.000547645125958379, 'mean_word_length': 3.2133794694348325, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '2614111', 'n_tokens_mistral': 1161, 'n_tokens_neox': 1130, 'n_words': 222}