<commit_before>var Upload = {
    xhr : null,
    attached : new Array(),
    get : null,

    init : function() {
        document.getElementById('file').addEventListener('change', function(){
            var file = this.files[0];
            Upload_ajaxSend({
                name: file.name,
                size: file.size,
                type: file.type
            });
        });
    },

    attach : function(func) {
        if(typeof(func) === "function") {
            this.attached.push(func);
        }
    },

    launchAttached : function() {
        for(var i = 0; i < Upload.attached.length; i++) {
            Upload.attached[i]();
        }
    },

    request : function(get, put) {
        Upload.get = get;

        var file = document.getElementById('file').files[0];

        Upload.xhr = new XMLHttpRequest();

        Upload.xhr.upload.addEventListener('progress', function(evt) {
            var percent = Math.floor(evt.loaded/evt.total*100);
            document.querySelector('#dialog ul li p').innerHTML = percent + '%';
        }, false);

        Upload.xhr.onreadystatechange = function() {
            if(Upload.xhr.readyState == 4 ) {
                Dialog.clear();
                Upload.launchAttached();
            }
        }

        Upload.xhr.open("PUT", put, true);

        Upload.xhr.setRequestHeader('Content-Type', 'text/plain');
        Upload.xhr.send(file);
    }
}

MovimWebsocket.attach(function()
{
});<commit_msg>Only accept valid and fully finished uploads<commit_after>var Upload = {
    xhr : null,
    attached : new Array(),
    get : null,

    init : function() {
        document.getElementById('file').addEventListener('change', function(){
            var file = this.files[0];
            Upload_ajaxSend({
                name: file.name,
                size: file.size,
                type: file.type
            });
        });
    },

    attach : function(func) {
        if(typeof(func) === "function") {
            this.attached.push(func);
        }
    },

    launchAttached : function() {
        for(var i = 0; i < Upload.attached.length; i++) {
            Upload.attached[i]();
        }
    },

    request : function(get, put) {
        Upload.get = get;

        var file = document.getElementById('file').files[0];

        Upload.xhr = new XMLHttpRequest();

        Upload.xhr.upload.addEventListener('progress', function(evt) {
            var percent = Math.floor(evt.loaded/evt.total*100);
            document.querySelector('#dialog ul li p').innerHTML = percent + '%';
        }, false);

        Upload.xhr.onreadystatechange = function() {
            if(Upload.xhr.readyState == 4
            && Upload.xhr.status == 200) {
                Dialog.clear();
                Upload.launchAttached();
            }
        }

        Upload.xhr.open("PUT", put, true);

        Upload.xhr.setRequestHeader('Content-Type', 'text/plain');
        Upload.xhr.send(file);
    }
}

MovimWebsocket.attach(function()
{
});
{'fraction_non_alphanumeric': 0.1461794019933555, 'fraction_numerical': 0.005647840531561462, 'mean_word_length': 1.7931354359925789, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3193020', 'n_tokens_mistral': 909, 'n_tokens_neox': 853, 'n_words': 152}