<commit_before>var socket = io.connect('http://localhost:3000');

FastClick.attach(document.body);

$('html').bind('keypress', function(e) {
   if(e.keyCode == 13) {
      return false;
   }
});

$('.js-ip-config').bind('click', function(e) {
    e.preventDefault();
    showIpConfig();
});

if(localStorage.getItem('ipAddress') === null) {
    showIpConfig();
} else {
    socket.emit('setIpAddress', localStorage.getItem('ipAddress'));
    start();
}

function showIpConfig() {
    $("#ipModal").modal();
    $(".js-ip-save").on("click", function(e) {
        e.preventDefault();

        socket.emit('setIpAddress', $('#ipField').val());
        socket.on('ipAddressSetResult', function (result) {
            if(result.ip) {
                localStorage.setItem('ipAddress', ipAddress);
                $("#ipModal").modal("hide");
            } else if (result.error) {
                alert("Invalid IP address");
            }
        });
    });
}

function start() {
    $(".btn-action").on("click", function(e) {
        e.preventDefault();
        $(this).blur();

        socket.emit('action', {action: $(this).data('action')});
    });

    socket.on('volume', function(result) {
        $(".vol").text("Volume - " + result.volume);
    });
}<commit_msg>Use vanilla JS selectors and event listeners<commit_after>var socket = io.connect(window.location.href);

var ipConfigButton = document.querySelector('.js-ip-config')
    , actionButtons = document.querySelectorAll('.btn-action')
    , ipModal = document.querySelector('#ipModal')
    , ipModalField = document.querySelector('#ipField')
    , ipModalSave = document.querySelector('.js-ip-save')
    , statusText = document.querySelector('.vol')


// Helper event function
function addEvent(evnt, elem, func) {
    if (elem.addEventListener) {
        elem.addEventListener(evnt, func, false);
    } else if (elem.attachEvent) {
        elem.attachEvent("on" + evnt, func);
    } else {
        elem[evnt] = func;
    }
}


FastClick.attach(document.body);

addEvent('keypress', document, function(e) {
   if(e.keyCode == 13) {
      return false;
   }
});

addEvent("click", ipConfigButton, function(e) {
    e.preventDefault();
    showIpConfig();
});

if(localStorage.getItem('ipAddress') === null) {
    showIpConfig();
} else {
    socket.emit('setIpAddress', localStorage.getItem('ipAddress'));
    start();
}

function showIpConfig() {
    $("ipModal").modal();
    addEvent('click', ipModalSave, function(e) {
        e.preventDefault();

        socket.emit('setIpAddress', ipModalField.value);
        socket.on('ipAddressSetResult', function (result) {
            if(result.ip) {
                localStorage.setItem('ipAddress', ipAddress);
                $("#ipModal").modal("hide");
            } else if (result.error) {
                alert("Invalid IP address");
            }
        });
    });
}

function start() {
    Array.prototype.forEach.call(actionButtons, function(button) {
        addEvent('click', button, function(e) {
            e.preventDefault();
            button.blur();

            socket.emit('action', { action: button.getAttribute('data-action') });
        });
    });

    socket.on('volume', function(result) {
        statusText.textContent = "Volume - " + result.volume;
    });
}
{'fraction_non_alphanumeric': 0.18192844147968465, 'fraction_numerical': 0.002425712553062462, 'mean_word_length': 2.8138728323699422, 'pattern_counts': {'":': 0, '<': 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': '5959128', 'n_tokens_mistral': 984, 'n_tokens_neox': 981, 'n_words': 157}