<commit_before>function promptUserName() {
    return prompt("Please enter a user name")
}

function message(obj) {
    var el = document.createElement('p')
    if ('announcement' in obj) {
        el.innerHTML = '<em>' + esc(obj.announcement) + '</em>'
    }
    else if ('message' in obj) {
        el.innerHTML = '<b>' + esc(obj.message[0]) + ':</b> ' + esc(obj.message[1])
    }
    document.getElementById('chat').appendChild(el)
    document.getElementById('chat').scrollTop = 1000000
}

function send() {
    var val = document.getElementById('text').value
      , nameVal = document.getElementById('username').value
      , userName = (nameVal === '') ? 'Default' : nameVal
    socket.send( [userName
                 , val].join(":") )
    message( { message: ['you', val] } )
    document.getElementById('text').value = ''
}

function esc(msg) {
  return String(msg).replace(/</g, '&lt;').replace(/>/g, '&gt;')
}

var socket = new io.Socket(null, {port: 8080, rememberTransport: false})
socket.connect()
socket.on('message', function(obj) {
    if ('buffer' in obj) {
        document.getElementById('form').style.display='block'
        document.getElementById('chat').innerHTML = ''
    
        for (var i in obj.buffer) {
            message(obj.buffer[i])
        }
    }
    else {
        message(obj)
    }
})

document.addEventListener( "DOMContentLoaded", function() {
    document.getElementById('username').value = promptUserName()
}, false)<commit_msg>change to main.js<commit_after>function promptUserName() {
    return prompt("Please enter a user name")
}

function message(obj) {
    var el = document.createElement('p')
    if ('announcement' in obj) {
        el.innerHTML = '<em>' + esc(obj.announcement) + '</em>'
    }
    else if ('message' in obj) {
        var vals = obj.message
        el.innerHTML = '<b>' + esc(vals.userName) + ':</b> ' + esc(vals.message)
    }
    document.getElementById('chat').appendChild(el)
    document.getElementById('chat').scrollTop = 1000000
}

function send() {
    var val = document.getElementById('text').value
      , nameVal = document.getElementById('username').value
      , userName = (nameVal === '') ? 'Default' : nameVal

    socket.send({ event : 'user_message', message : {'userName' : userName, 'message' : val} })
    message({ event : 'user_message', message : {'message': val, userName: 'you' } })
    document.getElementById('text').value = ''
}

function esc(msg) {
  return String(msg).replace(/</g, '&lt;').replace(/>/g, '&gt;')
}

var socket = new io.Socket(null, {port: 8080, rememberTransport: false})
socket.connect()
socket.on('message', function(obj) {
    if (obj.event === 'user_error_duplicate') {
        message(obj)
        handleUserName()
        return
    }
    if ('buffer' in obj) {
        document.getElementById('form').style.display='block'
        document.getElementById('chat').innerHTML = ''
    
        for (var i in obj.buffer) {
            message(obj.buffer[i])
        }
    }
    else {
        message(obj)
    }
})

function handleUserName() {
    var input = document.getElementById('username').value = promptUserName()
    socket.send({ event : 'user_connected', userName : input, announcement : input + " entered the chat room." })
}

document.addEventListener( "DOMContentLoaded", handleUserName, false)
{'fraction_non_alphanumeric': 0.1707170717071707, 'fraction_numerical': 0.0072007200720072, 'mean_word_length': 3.1779448621553885, 'pattern_counts': {'":': 1, '<': 13, '<?xml version=': 0, '>': 13, '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': '5855088', 'n_tokens_mistral': 1013, 'n_tokens_neox': 990, 'n_words': 214}