<commit_before>function getTeamname(){
    const parameters = retrieveGetParameters();
    return parameters["teamname"];
}

function getPossibleIngredients(){
    let responseJSON;

    $.ajax({
        url: '/pizzas/ingredients',
        success: (data) => {
            responseJSON = JSON.parse(data)
        },
        async: false
    })
    return responseJSON;
}

function getCheckboxForIngredient(ingredient){
    const $inputElement = $('<input>')
        .attr('type', 'checkbox')
        .attr('id', 'checkbox' + ingredient)
        .attr('name', ingredient)
        .attr('value', ingredient)
    const $label = $('<label>')
        .attr('for', 'checkbox' + ingredient)
        .text(ingredient)
    return $('<div></div>')
        .append($inputElement)
        .append($label)
}

function addCheckboxesToForm(){
    getPossibleIngredients().forEach((currentElement) => {
        $('#selector')
            .append(getCheckboxForIngredient(currentElement))
    })
}

function submitProposal(){
    let proposedIngredients = [];
    $('#selector')
        .find("input[type='checkbox']")
        .each((index, element) => {
            if($(element).is(':checked')){
                proposedIngredients.push($(element).attr('value'))
            }
        });

    if(proposedIngredients.length > 4){
        alert('Please select at most 4 ingredients!')
    }

    $.ajax({
        url: '/pizza/suggestions',
        method: "POST",
        data: {
            teamname: getTeamname(),
            ingredients: proposedIngredients
        },
        success: () => {
            console.log("Your ingredients have been proposed.")
        }
    })
}

window.addEventListener('load', () => {
    addCheckboxesToForm()
})<commit_msg>Fix link for suggestion POST<commit_after>function getTeamname(){
    const parameters = retrieveGetParameters();
    return parameters["teamname"];
}

function getPossibleIngredients(){
    let responseJSON;

    $.ajax({
        url: '/pizzas/ingredients',
        success: (data) => {
            responseJSON = JSON.parse(data)
        },
        async: false
    })
    return responseJSON;
}

function getCheckboxForIngredient(ingredient){
    const $inputElement = $('<input>')
        .attr('type', 'checkbox')
        .attr('id', 'checkbox' + ingredient)
        .attr('name', ingredient)
        .attr('value', ingredient)
    const $label = $('<label>')
        .attr('for', 'checkbox' + ingredient)
        .text(ingredient)
    return $('<div></div>')
        .append($inputElement)
        .append($label)
}

function addCheckboxesToForm(){
    getPossibleIngredients().forEach((currentElement) => {
        $('#selector')
            .append(getCheckboxForIngredient(currentElement))
    })
}

function submitProposal(){
    let proposedIngredients = [];
    $('#selector')
        .find("input[type='checkbox']")
        .each((index, element) => {
            if($(element).is(':checked')){
                proposedIngredients.push($(element).attr('value'))
            }
        });

    if(proposedIngredients.length > 4){
        alert('Please select at most 4 ingredients!')
    }

    $.ajax({
        url: '/pizzas/suggestions',
        method: "POST",
        data: {
            teamname: getTeamname(),
            ingredients: proposedIngredients
        },
        success: () => {
            console.log("Your ingredients have been proposed.")
        }
    })
}

window.addEventListener('load', () => {
    addCheckboxesToForm()
})
{'fraction_non_alphanumeric': 0.1573546180159635, 'fraction_numerical': 0.0011402508551881414, 'mean_word_length': 2.3903381642512076, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, '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': '1503556', 'n_tokens_mistral': 1025, 'n_tokens_neox': 991, 'n_words': 180}