<commit_before>function add (ul, name, text) {
  if (!text) return
  var li = document.createElement("li")
  var span = document.createElement("span")
  span.textContent = name + ": "
  var msg = document.createTextNode(text)
  li.appendChild(span)
  li.appendChild(msg)

  ul.appendChild(li)
  ul.scrollTop = ul.scrollHeight
}

function onKeyUp (e) {
  e.preventDefault()
  e.stopPropagation()
  if (e.keyCode != 13) return
  this.submit()
}

function onChat (e) {
  add(this.ul, e.sender, e.context)
}

function Chat (connection) {
  var conn = this.conn = connection
  conn.on("chat", onChat.bind(this))
  this.el = document.createElement("div")
  this.el.className = "chat noselect"
  this.ul = document.createElement("ul")
  this.el.appendChild(this.ul)
  this.input = document.createElement("input")
  this.input.type = "text"
  this.input.placeholder = "Press enter to type..."
  this.input.addEventListener("keyup", onKeyUp.bind(this))
  this.input.addEventListener("blur", this.blur.bind(this))
  this.el.appendChild(this.input)
}

Chat.prototype = {
  submit: function submit() {
    value = this.input.value

    if (!value) return this.blur()

    this.conn.send("chat", value)
    this.input.value = ""
  },

  focus: function focus() {
    this.el.classList.add("focus")
    this.input.placeholder = "Say something..."
    this.input.focus()
  },

  blur: function blur () {
    this.input.blur()
    this.el.classList.remove("focus")
    this.input.placeholder = "Press enter to type..."
  }
}

module.exports = Chat<commit_msg>Fixes.<commit_after>function add (ul, name, text) {
  if (!text) return
  var li = document.createElement("li")
  var span = document.createElement("span")
  span.textContent = name + ": "
  var msg = document.createTextNode(text)
  li.appendChild(span)
  li.appendChild(msg)

  ul.appendChild(li)
  ul.scrollTop = ul.scrollHeight
}

function onKeyUp (e) {
  e.preventDefault()
  e.stopPropagation()
  if (e.keyCode != 13) return
  this.submit()
}

function onChat (e) {
  add(this.ul, e.sender, e.context)
}

function Chat (connection) {
  var conn = this.conn = connection
  conn.on("chat", onChat.bind(this))
  this.el = document.createElement("div")
  this.el.className = "chat noselect"
  this.ul = document.createElement("ul")
  this.el.appendChild(this.ul)
  this.input = document.createElement("input")
  this.input.type = "text"
  this.input.placeholder = "Press enter to type..."
  this.input.addEventListener("keyup", onKeyUp.bind(this))
  this.input.addEventListener("blur", this.blur.bind(this))
  this.el.appendChild(this.input)
}

Chat.prototype = {
  submit: function submit() {
    value = this.input.value

    if (!value) return this.blur()

    this.conn.send("chat", value, {broadcast: true})
    this.input.value = ""
  },

  focus: function focus() {
    this.el.classList.add("focus")
    this.input.placeholder = "Say something..."
    this.input.focus()
  },

  blur: function blur () {
    this.input.blur()
    this.el.classList.remove("focus")
    this.input.placeholder = "Press enter to type..."
  }
}

module.exports = Chat
{'fraction_non_alphanumeric': 0.15848934796642997, 'fraction_numerical': 0.0012911555842479018, 'mean_word_length': 3.611607142857143, 'pattern_counts': {'":': 2, '<': 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': '4181612', 'n_tokens_mistral': 1042, 'n_tokens_neox': 1025, 'n_words': 209}