<commit_before>$(function() {
    "use strict";

    var worker, readFile, submitFile, processFileList, uiHandler;

 // jQuery creates its own event object, and it doesn't have a
 // dataTransfer property yet. This adds dataTransfer to the event object.
    $.event.props.push("dataTransfer");

 // Initialize worker.
    worker = new Worker("scripts/crumbs-worker.js");

 // Reads the given file and puts its content into the callback.
    readFile = function (file, callback) {
        var reader;
        reader = new FileReader();
        reader.onload = function (ev) {
            callback(null, ev.target.result);
        };
        reader.readAsText(file);
    };

 // Submits a file to the worker.
    submitFile = function (file, options, callback) {
        readFile(file, function (err, data) {
            var payload;
            payload = {
                data: data,
                options: options.config
            };
            worker.onmessage = function (message) {
                if (message.data === 0) {
                    callback(null);
                } else {
                    callback(new Error("Something went wrong."));
                }
            };
            worker.postMessage(payload);
        });
    };

 // Iterate through fileList, delegating files to submitFile.
 // fileList is of type FileList, a DOM type.
    processFileList = function processFileList(fileList, options, callback) {
        var file;
        if (fileList.length === 0 || options.currentFileIdx === fileList.length) {
         // Don't start if there are no files, and stop if every file has been processed.
            callback(null);
        } else {
            options.currentFileIdx = options.currentFileIdx || 0;
            file = fileList[options.currentFileIdx];
            submitFile(file, options, function (err) {
                if (err !== null) {
                    callback(err);
                } else {
                    options.currentFileIdx++;
                    processFileList(fileList, options, callback);
                }
            });
        }
    };

 // Handle option extraction and status indicator.
    uiHandler = function (fileList) {
        var options, button;
        options = {
            config: {
                fieldNames: $("[name='optionFieldNames']:checked").val() || "none",
                documentCreation: $("#optionDocumentCreation").val(),
                delimiter: $("#optionDelimiter").val()
            }
        };
        button = $("input[type='submit']");
        button.button("loading");
        processFileList(fileList, options, function (err) {
            if (err !== null) {
                alert(err);
            } else {
                alert("Import complete.");
            }
            button.button("reset");
        });
    };

 // File picker handler.
    $("form").submit(function (ev) {
        var fileList;
        ev.preventDefault();
        fileList = $("#filePicker").get(0).files;
        uiHandler(fileList);
    });

 // Drag-and-Drop handlers.
    $("#dropzone").bind("dragover", function (ev) {
        ev.preventDefault();
        $(this).addClass("alert-success");
    });
    $("#dropzone").bind("dragleave", function (ev) {
        ev.preventDefault();
        $(this).removeClass("alert-success");
    });
    $("#dropzone").bind("drop", function (ev) {
        var fileList;
        ev.preventDefault();
        $(this).removeClass("alert-success");
        fileList = ev.dataTransfer.files;
        uiHandler(fileList);
    });

 // Advanced options handler.
    $("#toggle-advanced-options").click(function (ev) {
        ev.preventDefault();
        $(".advanced-option").toggle();
    });

});<commit_msg>Do not trigger import automatically when files are dropped into the dropzone.<commit_after>$(function() {
    "use strict";

    var worker, fileList, readFile, submitFile, processFileList;

 // jQuery creates its own event object, and it doesn't have a
 // dataTransfer property yet. This adds dataTransfer to the event object.
    $.event.props.push("dataTransfer");

 // Initialize worker.
    worker = new Worker("scripts/crumbs-worker.js");

 // Keep file list.
    fileList = [];

 // Reads the given file and puts its content into the callback.
    readFile = function (file, callback) {
        var reader;
        reader = new FileReader();
        reader.onload = function (ev) {
            callback(null, ev.target.result);
        };
        reader.readAsText(file);
    };

 // Submits a file to the worker.
    submitFile = function (file, options, callback) {
        readFile(file, function (err, data) {
            var payload;
            payload = {
                data: data,
                options: options.config
            };
            worker.onmessage = function (message) {
                if (message.data === 0) {
                    callback(null);
                } else {
                    callback(new Error("Something went wrong."));
                }
            };
            worker.postMessage(payload);
        });
    };

 // Iterate through fileList, delegating files to submitFile.
 // fileList is of type FileList, a DOM type.
    processFileList = function processFileList(fileList, options, callback) {
        var file;
        if (fileList.length === 0 || options.currentFileIdx === fileList.length) {
         // Don't start if there are no files, and stop if every file has been processed.
            callback(null);
        } else {
            options.currentFileIdx = options.currentFileIdx || 0;
            file = fileList[options.currentFileIdx];
            submitFile(file, options, function (err) {
                if (err !== null) {
                    callback(err);
                } else {
                    options.currentFileIdx++;
                    processFileList(fileList, options, callback);
                }
            });
        }
    };

 // Handle option extraction and status indicator on submit.
    $("form").submit(function (ev) {
        var options, button;
        ev.preventDefault();
        options = {
            config: {
                fieldNames: $("[name='optionFieldNames']:checked").val() || "none",
                documentCreation: $("#optionDocumentCreation").val(),
                delimiter: $("#optionDelimiter").val()
            }
        };
        button = $("input[type='submit']");
        button.button("loading");
        processFileList(fileList, options, function (err) {
            if (err !== null) {
                alert(err);
            } else {
                alert("Import complete.");
            }
            button.button("reset");
        });
    });

 // File picker handler.
    $("#filePicker").change(function (ev) {
        fileList = ev.target.files;
    });

 // Drag-and-Drop handlers.
    $("#dropzone").bind("dragover", function (ev) {
        ev.preventDefault();
        $(this).addClass("alert-success");
    });
    $("#dropzone").bind("dragleave", function (ev) {
        ev.preventDefault();
        $(this).removeClass("alert-success");
    });
    $("#dropzone").bind("drop", function (ev) {
        ev.preventDefault();
        $(this).removeClass("alert-success");
        fileList = ev.dataTransfer.files;
        if (fileList.length === 1) {
            $(this).text(fileList[0].name);
        } else {
            $(this).text(fileList.length + " files");
        }
    });

 // Advanced options handler.
    $("#toggle-advanced-options").click(function (ev) {
        ev.preventDefault();
        $(".advanced-option").toggle();
    });

});
{'fraction_non_alphanumeric': 0.137565445026178, 'fraction_numerical': 0.0011780104712041885, 'mean_word_length': 1.8331479421579533, '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': '5604278', 'n_tokens_mistral': 1986, 'n_tokens_neox': 1936, 'n_words': 487}