<commit_before><!doctype html>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>COBRA SBML validator</title>

<!--dropzone-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.2.0/min/dropzone.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.2.0/min/dropzone.min.js"></script>

<!--bootstrap-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">


<style>
div.row {
    margin-top: 1em;
    padding: 0.5em;
    border-radius: 0.5em;
}
</style>

<script>

function update_result(file, response) {
    result_list_div = document.getElementById("results");
    result_div = result_list_div.appendChild(document.createElement("div"));
    result_div.className = "row";
    results = response;  // results = JSON.parse(response); (for text/html)

    // build the result str
    result_str = "<strong>" + file.name + "</strong>&nbsp;-&nbsp;";
    if (results.errors.length == 0 && results.warnings.length == 0) {
        result_div.className += " bg-success";
        result_str += "No errors<br>"
        file.previewElement.querySelector(".dz-success-mark").style.opacity = 1;
    }
    else {
        result_str += results.errors.length + " error";
        if (results.errors.length > 1 || results.errors.length == 0) result_str += "s";
        if (results.warnings.length > 0) {
            result_str += " and " +  results.warnings.length + " warning";
            if (results.warnings.length > 1) result_str += "s";
        }
        // update the error message on the dropzone preview
        msg = file.previewElement.querySelector(".dz-error-message").getElementsByTagName("span")[0];
        msg.innerHTML = result_str;
        // color as error (or warning if no errors)
        if (results.errors.length > 0) {
            file.previewElement.classList.remove("dz-success");
            file.previewElement.classList.add("dz-error");
            result_div.className += " bg-danger";
        }
        else {
            result_div.className += " bg-warning";
        }

        // display the rest of the errors in the result_list
        result_str += "<br>";
        for (var i = 0; i < results.errors.length; i++) {
            result_str += "Error: " + results.errors[i] + "<br>";
        }
        for (var i = 0; i < results.warnings.length; i++) {
            result_str += "Warning: " + results.warnings[i] + "<br>";
        }
    }
    if ('objective' in results)
        result_str += "objective value: " + results.objective;

    // add result str to result_div
    span = result_div.appendChild(document.createElement("span"));
    span.innerHTML = result_str;
}

function onUploadFail(file, errorMsg, was_xhr) {
    result_list_div = document.getElementById("results");
    result_div = result_list_div.appendChild(document.createElement("div"));
    result_div.className = "row bg-danger";
    result_str = "<strong>" + file.name + "</strong>&nbsp;-&nbsp;";
    result_str += "Invalid file<br>" + errorMsg;
    result_div.innerHTML = result_str;
}

Dropzone.options.uploader = {
    uploadMultiple: false,
    maxFilesize: 25,
    init: function () {
        this.on("success", update_result);
        this.on("error", onUploadFail);
    },
};

</script>

<body>
    <h1>Validate COBRA models in SBML or JSON</h1>
    <div id="dropzone" class="container">
        <form action="upload" class="dropzone" id="uploader">
            <div class="dz-message">Drop SBML/JSON files here or click to upload. Compressed (gz and bz2) files are also accepted.</div>
        </form>
    </div>
    <div id="results" class="container"></div>
</body>
<commit_msg>add link to github source<commit_after><!doctype html>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>COBRA SBML validator</title>

<!--dropzone-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.2.0/min/dropzone.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.2.0/min/dropzone.min.js"></script>

<!--bootstrap-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">


<style>
div.row {
    margin-top: 1em;
    padding: 0.5em;
    border-radius: 0.5em;
}
</style>

<script>

function update_result(file, response) {
    result_list_div = document.getElementById("results");
    result_div = result_list_div.appendChild(document.createElement("div"));
    result_div.className = "row";
    results = response;  // results = JSON.parse(response); (for text/html)

    // build the result str
    result_str = "<strong>" + file.name + "</strong>&nbsp;-&nbsp;";
    if (results.errors.length == 0 && results.warnings.length == 0) {
        result_div.className += " bg-success";
        result_str += "No errors<br>"
        file.previewElement.querySelector(".dz-success-mark").style.opacity = 1;
    }
    else {
        result_str += results.errors.length + " error";
        if (results.errors.length > 1 || results.errors.length == 0) result_str += "s";
        if (results.warnings.length > 0) {
            result_str += " and " +  results.warnings.length + " warning";
            if (results.warnings.length > 1) result_str += "s";
        }
        // update the error message on the dropzone preview
        msg = file.previewElement.querySelector(".dz-error-message").getElementsByTagName("span")[0];
        msg.innerHTML = result_str;
        // color as error (or warning if no errors)
        if (results.errors.length > 0) {
            file.previewElement.classList.remove("dz-success");
            file.previewElement.classList.add("dz-error");
            result_div.className += " bg-danger";
        }
        else {
            result_div.className += " bg-warning";
        }

        // display the rest of the errors in the result_list
        result_str += "<br>";
        for (var i = 0; i < results.errors.length; i++) {
            result_str += "Error: " + results.errors[i] + "<br>";
        }
        for (var i = 0; i < results.warnings.length; i++) {
            result_str += "Warning: " + results.warnings[i] + "<br>";
        }
    }
    if ('objective' in results)
        result_str += "objective value: " + results.objective;

    // add result str to result_div
    span = result_div.appendChild(document.createElement("span"));
    span.innerHTML = result_str;
}

function onUploadFail(file, errorMsg, was_xhr) {
    result_list_div = document.getElementById("results");
    result_div = result_list_div.appendChild(document.createElement("div"));
    result_div.className = "row bg-danger";
    result_str = "<strong>" + file.name + "</strong>&nbsp;-&nbsp;";
    result_str += "Invalid file<br>" + errorMsg;
    result_div.innerHTML = result_str;
}

Dropzone.options.uploader = {
    uploadMultiple: false,
    maxFilesize: 25,
    init: function () {
        this.on("success", update_result);
        this.on("error", onUploadFail);
    },
};

</script>

<body>
    <h1>Validate COBRA models in SBML or JSON</h1>
    <div id="dropzone" class="container">
        <form action="upload" class="dropzone" id="uploader">
            <div class="dz-message">Drop SBML/JSON files here or click to upload. Compressed (gz and bz2) files are also accepted.</div>
        </form>
    </div>
    <div id="results" class="container"></div>
    <!-- github ribbon -->
    <a href="https://github.com/aebrahim/cobra_sbml_validator">
        <img style="position: absolute; top: 0; right: 0; border;" src="https://camo.githubusercontent.com/a6677b08c955af8400f44c6298f40e7d19cc5b2d/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677261795f3664366436642e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png">
    </a>
</body>

{'fraction_non_alphanumeric': 0.1579794478147827, 'fraction_numerical': 0.02575213569394577, 'mean_word_length': 3.0470941883767537, 'pattern_counts': {'":': 0, '<': 85, '<?xml version=': 0, '>': 89, 'https://': 9, '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': '5354031', 'n_tokens_mistral': 2718, 'n_tokens_neox': 2585, 'n_words': 509}