getSelection()
getRecipeList()

function getRecipeList(){
    $.get(getWebAppBackendUrl('/get_list'), function(response) {
        var select = document.getElementById("suggestions");
        var options = JSON.parse(response)["values"];

        for(var i = 0; i < options.length; i++) {
            var opt = options[i];
            var el = document.createElement("option");
            el.textContent = opt;
            el.value = opt;
            select.appendChild(el);
        }
    });
};

function selectRecipe(){
    console.log(document.querySelector('#recipe_selector').value
);
    params = {};
    params["molecule_id"] = document.querySelector('#recipe_selector').value;
    $.post(getWebAppBackendUrl('/set_variable'),  JSON.stringify(params));
};

document.getElementById("saveButton").addEventListener ("click", selectRecipe, false);$.getJSON(getWebAppBackendUrl('/first_api_call'), function(data) {
    console.log('Received data from backend', data)
    const output = $('<pre />').text('Backend reply: ' + JSON.stringify(data));
    $('body').append(output)
});
