<commit_before>var mode = "";

function init() {
    processParams();
}

function processParams() {
    var params = getParams();
    if (params.mode) {
        changeMode(params.mode);
    }

    if (params.inventoryId) {
        $("#inventoryId").val(parseInt(params.inventoryId));
    }

    if (params.runId) {
        $("#runId").val(parseInt(params.runId));
    }

    if (params.runDate) {
        $("#runDate").val(params.runDate);
    }

    if (params.batchAmount) {
        $("#batchAmount").val(parseInt(params.batchAmount));
    }

    if (params.batchLocation) {
        $("#batchLocation").val(params.batchLocation);
    }
}

function getParams() {
    var params = {};
    location.search.substr(1).split("&").forEach(function(each) {
        if (each !== "") {
            var pair = each.split("=");
            params[pair[0]] = pair[1];
        }
    });

    return params;
}

function changeMode(newMode) {
    hideAllFields();

    mode = newMode;

    switch (mode) {
        case "addRun":
            $("#modeHeading").text("Add Run");
            $("#inventoryIdField").show();
            $("#runDateField").show();
            break;
        case "removeRun":
            $("#modeHeading").text("Remove Run");
            $("#runIdField").show();		
            break;
        case "addBatch":
            $("#modeHeading").text("Add Batch");
            $("#runIdField").show();
            $("#batchAmountField").show();
            $("#batchLocationField").show();
            break;
        case "removeBatch":
            $("#modeHeading").text("Remove Batch");
            $("#runIdField").show();
            $("#batchAmountField").show();
            $("#batchLocationField").show();		
            break;
        default:
            $("#input").hide();
            return;
            break;
    }

    $("#input").show();
}

function hideAllFields() {
    $("#inventoryIdField").hide();
    $("#runIdField").hide();
    $("#runDateField").hide();
    $("#batchAmountField").hide();
    $("#batchLocationField").hide();
}

function submit() {
    var inventoryId = parseInt($("#inventoryId").val());
    var runId = parseInt($("#runId").val());
    var runDate = $("#runDate").val();
    var batchAmount = parseInt($("#batchAmount").val());
    var batchLocation = $("#batchLocation").val();

    var host;

    switch (mode) {
        case "addRun":
            host = "http://localhost:50001/addRun/" + inventoryId + "/" + runDate;
            break;
        case "removeRun":
            host = "http://localhost:50001/removeRun/" + runId		
            break;
        case "addBatch":
            host = "http://localhost:50001/addBatch/" + runId + "/" + batchAmount + "/" + batchLocation;
            break;
        case "removeBatch":
            host = "http://localhost:50001/removeBatch/" + runId + "/" + batchAmount + "/" + batchLocation;
            break;
        default:
            $("#response").text("Error");
            return;
            break;<commit_msg>IM-52: Updated change inventory to use new routes<commit_after>var mode = "";

function init() {
    processParams();
}

function processParams() {
    var params = getParams();
    if (params.mode) {
        changeMode(params.mode);
    }

    if (params.inventoryId) {
        $("#inventoryId").val(parseInt(params.inventoryId));
    }

    if (params.runId) {
        $("#runId").val(parseInt(params.runId));
    }

    if (params.runDate) {
        $("#runDate").val(params.runDate);
    }

    if (params.batchAmount) {
        $("#batchAmount").val(parseInt(params.batchAmount));
    }

    if (params.batchLocation) {
        $("#batchLocation").val(params.batchLocation);
    }
}

function getParams() {
    var params = {};
    location.search.substr(1).split("&").forEach(function(each) {
        if (each !== "") {
            var pair = each.split("=");
            params[pair[0]] = pair[1];
        }
    });

    return params;
}

function changeMode(newMode) {
    hideAllFields();

    mode = newMode;

    switch (mode) {
        case "addRun":
            $("#modeHeading").text("Add Run");
            $("#inventoryIdField").show();
            $("#runDateField").show();
            break;
        case "removeRun":
            $("#modeHeading").text("Remove Run");
            $("#runIdField").show();
            break;
        case "addBatch":
            $("#modeHeading").text("Add Batch");
            $("#runIdField").show();
            $("#batchAmountField").show();
            $("#batchLocationField").show();
            break;
        case "removeBatch":
            $("#modeHeading").text("Remove Batch");
            $("#runIdField").show();
            $("#batchAmountField").show();
            $("#batchLocationField").show();
            break;
        default:
            $("#input").hide();
            return;
            break;
    }

    $("#input").show();
}

function hideAllFields() {
    $("#inventoryIdField").hide();
    $("#runIdField").hide();
    $("#runDateField").hide();
    $("#batchAmountField").hide();
    $("#batchLocationField").hide();
}

function submit() {
    var inventoryId = parseInt($("#inventoryId").val());
    var runId = parseInt($("#runId").val());
    var runDate = $("#runDate").val();
    var batchAmount = parseInt($("#batchAmount").val());
    var batchLocation = $("#batchLocation").val();

    var host;

    switch (mode) {
        case "addRun":
            host = "http://localhost:50001/changeInventory/addRun/" + inventoryId + "/" + runDate;
            break;
        case "removeRun":
            host = "http://localhost:50001/changeInventory/removeRun/" + runId
            break;
        case "addBatch":
            host = "http://localhost:50001/changeInventory/addBatch/" + runId + "/" + batchAmount + "/" + batchLocation;
            break;
        case "removeBatch":
            host = "http://localhost:50001/changeInventory/removeBatch/" + runId + "/" + batchAmount + "/" + batchLocation;
            break;
        default:
            $("#response").text("Error");
            return;
            break;
{'fraction_non_alphanumeric': 0.19052287581699345, 'fraction_numerical': 0.00784313725490196, 'mean_word_length': 2.102382159148505, 'pattern_counts': {'":': 16, '<': 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': '1066201', 'n_tokens_mistral': 1738, 'n_tokens_neox': 1750, 'n_words': 294}