<commit_before>/* lastTarget is set first on dragenter, then
   compared with during dragleave. */
var lastTarget = null;

window.addEventListener("dragenter", function(e) {
    lastTarget = e.target; // cache the last target here
    // unhide our dropzone overlay
    document.querySelector(".dropzone").style.visibility = "";
    document.querySelector(".dropzone").style.opacity = 1;
});

window.addEventListener("dragleave", function(e) {
    // this is the magic part. when leaving the window,
    // e.target happens to be exactly what we want: what we cached
    // at the start, the dropzone we dragged into.
    // so..if dragleave target matches our cache, we hide the dropzone.
    if(e.target === lastTarget) {
        document.querySelector(".dropzone").style.visibility = "hidden";
        document.querySelector(".dropzone").style.opacity = 0;
    }
});

window.addEventListener("drop", function(e) {
    e.preventDefault();
    e.stopPropagation();

    var data = new FormData();

    var files = e.dataTransfer.files;
    for (var i = 0; i < files.length; i++) {
        data.append('file', files[i], files[i]["name"]);
    }
    var request = new XMLHttpRequest();
    request.open('POST', '/upload', true);
    request.onreadystatechange = function() {
	      if (request.readyState > 3 && request.status === 200) {
            window.location.reload(true);
        }
	  };
    request.send(data);
    document.querySelector(".dropzone").classList.add("spinner");
});
window.addEventListener("dragover", function(e) {
    e.preventDefault();
    e.stopPropagation();
});

document.addEventListener('keydown', function(e) {
    if (e.key === "Escape") {
        if (window.location.href !== "/") {
            window.setTimeout(function () {
                window.location.href = "/";
            }, 0);
        }
    }
});
<commit_msg>Rather than going home, have escape go back (until home)<commit_after>/* lastTarget is set first on dragenter, then
   compared with during dragleave. */
var lastTarget = null;

window.addEventListener("dragenter", function(e) {
    lastTarget = e.target; // cache the last target here
    // unhide our dropzone overlay
    document.querySelector(".dropzone").style.visibility = "";
    document.querySelector(".dropzone").style.opacity = 1;
});

window.addEventListener("dragleave", function(e) {
    // this is the magic part. when leaving the window,
    // e.target happens to be exactly what we want: what we cached
    // at the start, the dropzone we dragged into.
    // so..if dragleave target matches our cache, we hide the dropzone.
    if(e.target === lastTarget) {
        document.querySelector(".dropzone").style.visibility = "hidden";
        document.querySelector(".dropzone").style.opacity = 0;
    }
});

window.addEventListener("drop", function(e) {
    e.preventDefault();
    e.stopPropagation();

    var data = new FormData();

    var files = e.dataTransfer.files;
    for (var i = 0; i < files.length; i++) {
        data.append('file', files[i], files[i]["name"]);
    }
    var request = new XMLHttpRequest();
    request.open('POST', '/upload', true);
    request.onreadystatechange = function() {
	      if (request.readyState > 3 && request.status === 200) {
            window.location.reload(true);
        }
	  };
    request.send(data);
    document.querySelector(".dropzone").classList.add("spinner");
});
window.addEventListener("dragover", function(e) {
    e.preventDefault();
    e.stopPropagation();
});

document.addEventListener('keydown', function(e) {
    if (e.key === "Escape") {
        if (window.location.pathname !== "/") {
            window.setTimeout(function () {
                window.history.go(-1);
            }, 0);
        }
    }
});

{'fraction_non_alphanumeric': 0.1538871139510117, 'fraction_numerical': 0.004526091586794462, 'mean_word_length': 2.9299163179916317, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4687850', 'n_tokens_mistral': 1085, 'n_tokens_neox': 1070, 'n_words': 267}