<commit_before>﻿function onPageLoad() {
}

function onSubmitClick() {
    var nodeKind = document.getElementById("nodeKind").value;
    var openCurlyOnNewLine = getCheckboxValue("openCurlyOnNewLine");
    var closeCurlyOnNewLine = getCheckboxValue("closeCurlyOnNewLine");
    var preserveOriginalWhitespace = getCheckboxValue("preserveOriginalWhitespace");
    var keepRedundantApiCalls = getCheckboxValue("keepRedundantApiCalls");
    var avoidUsingStatic = getCheckboxValue("avoidUsingStatic");
    var query = "api/quoter/?sourceText=" + encodeURIComponent(inputBox.value);

    query = query + "&nodeKind=" + nodeKind;

    if (openCurlyOnNewLine) {
        query = query + "&openCurlyOnNewLine=true";
    }

    if (closeCurlyOnNewLine) {
        query = query + "&closeCurlyOnNewLine=true";
    }

    if (preserveOriginalWhitespace) {
        query = query + "&preserveOriginalWhitespace=true";
    }

    if (keepRedundantApiCalls) {
        query = query + "&keepRedundantApiCalls=true";
    }

    if (avoidUsingStatic) {
        query = query + "&avoidUsingStatic=true";
    }

    getUrl(query, loadResults);
}

function getCheckboxValue(id) {
    return document.getElementById(id).checked;
}

function getUrl(url, callback) {
    enableSubmit(false);
    var xhr = new XMLHttpRequest();
    xhr.open("GET", url, true);
    xhr.setRequestHeader("Accept", "text/html");
    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4) {
            var data = xhr.responseText;
            if (typeof data === "string" && data.length > 0) {
                callback(data);
            }
        }

        enableSubmit(true);
    };
    xhr.send();
    return xhr;
}

function enableSubmit(enabled) {
    var submitButton = document.getElementById("submitButton");
    submitButton.disabled = !enabled;

    var working = document.getElementById("working");
    if (enabled) {
        working.style.display = "none";
    } else {
        working.style.display = "inline";
        setResult("");
    }
}

function setResult(data) {
    var container = document.getElementById("outputDiv");
    if (container) {
        container.innerHTML = data;
    }
}

function loadResults(data) {
    setResult(data);
}<commit_msg>Use innerText instead of innerHTML<commit_after>﻿function onPageLoad() {
}

function onSubmitClick() {
    var nodeKind = document.getElementById("nodeKind").value;
    var openCurlyOnNewLine = getCheckboxValue("openCurlyOnNewLine");
    var closeCurlyOnNewLine = getCheckboxValue("closeCurlyOnNewLine");
    var preserveOriginalWhitespace = getCheckboxValue("preserveOriginalWhitespace");
    var keepRedundantApiCalls = getCheckboxValue("keepRedundantApiCalls");
    var avoidUsingStatic = getCheckboxValue("avoidUsingStatic");
    var query = "api/quoter/?sourceText=" + encodeURIComponent(inputBox.value);

    query = query + "&nodeKind=" + nodeKind;

    if (openCurlyOnNewLine) {
        query = query + "&openCurlyOnNewLine=true";
    }

    if (closeCurlyOnNewLine) {
        query = query + "&closeCurlyOnNewLine=true";
    }

    if (preserveOriginalWhitespace) {
        query = query + "&preserveOriginalWhitespace=true";
    }

    if (keepRedundantApiCalls) {
        query = query + "&keepRedundantApiCalls=true";
    }

    if (avoidUsingStatic) {
        query = query + "&avoidUsingStatic=true";
    }

    getUrl(query, loadResults);
}

function getCheckboxValue(id) {
    return document.getElementById(id).checked;
}

function getUrl(url, callback) {
    enableSubmit(false);
    var xhr = new XMLHttpRequest();
    xhr.open("GET", url, true);
    xhr.setRequestHeader("Accept", "text/html");
    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4) {
            var data = xhr.responseText;
            if (typeof data === "string" && data.length > 0) {
                callback(data);
            }
        }

        enableSubmit(true);
    };
    xhr.send();
    return xhr;
}

function enableSubmit(enabled) {
    var submitButton = document.getElementById("submitButton");
    submitButton.disabled = !enabled;

    var working = document.getElementById("working");
    if (enabled) {
        working.style.display = "none";
    } else {
        working.style.display = "inline";
        setResult("");
    }
}

function setResult(data) {
    var container = document.getElementById("outputDiv");
    if (container) {
        container.innerText = data;
    }
}

function loadResults(data) {
    setResult(data);
}
{'fraction_non_alphanumeric': 0.11956288836511678, 'fraction_numerical': 0.0008570816370259267, 'mean_word_length': 2.779757085020243, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2739864', 'n_tokens_mistral': 1418, 'n_tokens_neox': 1364, 'n_words': 250}