<commit_before>var host = location.origin.replace(/^http/, 'ws');
var client = new WebSocket(host);

var textbox = document.getElementsByTagName('input')[0];
var button = document.getElementsByTagName('button')[0];

client.onmessage = function(message) {

  if (message.data === 'loginSuccess') {
    button.innerHTML = 'Send';
    textbox.placeholder = 'Message';
    textbox.parentElement.className += ' has-success';
    return;

  } else if (message.data === 'loginFailed') {
    textbox.parentElement.className += ' has-error';
    return;
  }

  var chatbox = document.getElementById('chatbox');
  var div = document.createElement('div');
  div.innerHTML = message.data.replace(/(@\w+)/ig, '<b>$1</b>');
  
  chatbox.appendChild(div);
  chatbox.scrollTop = chatbox.scrollHeight;
};

function send() {

  var message = {
    type: 'message',
    data: textbox.value
  };
  

  if (button.innerHTML === 'Login') {
    message.type = 'login';
  }
  
  client.send(JSON.stringify(message));<commit_msg>some fixes.<commit_after>var host = location.origin.replace(/^http/, 'ws');
var client = new WebSocket(host);

var textbox = document.getElementsByTagName('input')[0];
var button = document.getElementsByTagName('button')[0];

client.onmessage = function(message) {

  if (message.data === 'loginSuccess') {
    button.innerHTML = 'Send';
    textbox.placeholder = 'Write message';
    textbox.parentElement.className += ' has-success';
    return;

  } else if (message.data === 'loginFailed') {
    textbox.parentElement.className += ' has-error';
    textbox.placeholder = 'Username is already used by another user';
    return;
  }

  var chatbox = document.getElementById('chatbox');
  var div = document.createElement('div');
  div.innerHTML = message.data.replace(/(@\w+)/ig, '<b>$1</b>');
  
  chatbox.appendChild(div);
  chatbox.scrollTop = chatbox.scrollHeight;
};

function send() {

  if (! textbox.value)
    return;

  var message = {
    type: 'message',
    data: textbox.value
  };
  

  if (button.innerHTML === 'Login') {
    message.type = 'login';
  }
  
  client.send(JSON.stringify(message));
{'fraction_non_alphanumeric': 0.1676109537299339, 'fraction_numerical': 0.0028328611898017, 'mean_word_length': 3.8824884792626726, 'pattern_counts': {'":': 0, '<': 7, '<?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': '760892', 'n_tokens_mistral': 680, 'n_tokens_neox': 667, 'n_words': 130}