<commit_before>/* ©Copyright Utrecht University (Department of Information and Computing Sciences) */

var Parameters;

(function()
{
    "use strict";

    var defaultContainer = { byId: {}, sequence: [] };

    Parameters =
    {
        counter: 0,
        timeId: null,
        container: $.extend(true, {}, defaultContainer),
        reset: reset,
        dialog: dialog,
        atLeastOneUserDefined: atLeastOneUserDefined,
        insertInto: insertInto,
        hasWithType: hasWithType
    };

    $(document).ready(function()
    {
         var parameterScreenHTML = Parts.getParameterScreenHTML();
        $("#parameterScreen").html(parameterScreenHTML);
        $("#editParameters").on('click', dialog);

        $("#params").on("focus", ".description", function()
        {
            $(this).animate({ height: "10em" }, 500);
        });
        $("#params").on("focusout", ".description", function()
        {
            $(this).animate({height:"1em"}, 500);
        });
        $("#params").on('click', '.deleteParent', function()
        {
            var tr = $(this).closest('tr');
            tr.addClass("removedParameter");
            if(tr[0].id === "t" && tr.not(".removedParameter"))
            {
                // for time parameter: make visible when Time-parameter has been removed
                $("#addTimeParameter").removeClass("hidden");
            }
            if ($("#params").children().not(".removedParameter").length === 0)
                $("#paramsTableHead").addClass("hidden");
        });

        $("#addParameter").on('click', function()
        {
            var addedDiv = addDefaultDefinition();
            Utils.focusFirstTabindexedDescendant(addedDiv);
            $("#paramsTableHead").removeClass("hidden");
        });

        $("#addTimeParameter").on('click', function()
        {
            var isTime = $("#params").find(".isT").length;
            var isTimeRemoved = $("#params").find(".isT.removedParameter").length;

            // if the timeParameterObject is empty, or if it is filled, but
            // the parameter in the dialog has been removed (in that case the
            // timeParameterObject has not been updated yet)
            if (Parameters.timeId === null || isTimeRemoved === isTime)
            {
                $("#params").append(Parts.getParameterDefinitionHTML());
                var div = $("#params").children().last();
                // div.children().children().prop('disabled', true);
                $(div).prop('id', 't');
                div.find(".name").val(i18next.t('parameters:time'));
                div.find(".parameter-type-select").val(Types.primitives.integer.name);
                div.find(".parameter-type-select").prop("disabled", "disabled");
                div.find(".parameter-initial-value-container").remove();

                Utils.focusFirstTabindexedDescendant($("#params").children().last());
                $("#paramsTableHead").removeClass("hidden");
                $("#addTimeParameter").addClass("hidden");
            }
        });
    });

    // Resets the parameters to the default
    function reset()
    {
        Parameters.container = $.extend(true, {}, defaultContainer);
        Parameters.counter = 0;
        Parameters.timeId = null;
    }

    function dialog()
    {
        if (Parameters.timeId !== null)
        {
            $("#addTimeParameter").addClass("hidden");
        }
        else
        {
            $("#addTimeParameter").removeClass("hidden");
        }

        $("#parameterScreen").dialog(
        {
            title: i18next.t('parameters:title'),
            height: Constants.heightParameterScreen,
            width: Constants.widthParameterScreen,
            modal: true,
            buttons: [
            {
                text: i18next.t('common:confirm'),
                click: function()
                {
                    save();
                    $(this).dialog('close');
                }
            },
            {
                text: i18next.t('common:cancel'),
                click: function()
                {
                    $(this).dialog('close');
                }
            }],
            close: function()
            {
                $("#main").focus();
            }
        });

        $("#params").empty();
        $("#paramsTableHead").addClass("hidden");

        Parameters.container.sequence.forEach(function(parameter)
        {
            var addedDiv = addDefaultDefinition();
            addedDiv.removeClass("newParameter").addClass("existingParameter");

            addedDiv.prop('id', parameter.id);

            var typeSelect = addedDiv.find(".parameter-type-select");

            if (parameter.id === "t")
            {
                addedDiv.addClass("isT");
                typeSelect.val(Types.primitives.integer.name);
                typeSelect.prop("disabled", "disabled");
                addedDiv.find(".parameter-initial-value-container").remove();
                addedDiv.find(".parameter-min-container").remove();
                addedDiv.find(".parameter-max-container").remove();
            }

            addedDiv.find(".name").val(parameter.name);

            if (parameter.type.name === Types.primitives.enumeration.name)
            {
                parameter.type.insertTypeIntoDOM(typeSelect.parent());
            }
            typeSelect.val(parameter.type.name).trigger('change');
            addedDiv.removeClass("changedTypeParameter");

            addedDiv.find(".parameter-evaluated").prop('checked', parameter.evaluated);

            parameter.type.setInDOM(addedDiv.find(".parameter-initial-value-container"), parameter.type.defaultValue);

            if ('minimum' in parameter.type) parameter.type.setInDOM(addedDiv.find(".parameter-min-container"), parameter.type.minimum);
            if ('maximum' in parameter.type) parameter.type.setInDOM(addedDiv.find(".parameter-max-container"), parameter.type.maximum);<commit_msg>Fixed removal of evaluated when parameter is time<commit_after>/* ©Copyright Utrecht University (Department of Information and Computing Sciences) */

var Parameters;

(function()
{
    "use strict";

    var defaultContainer = { byId: {}, sequence: [] };

    Parameters =
    {
        counter: 0,
        timeId: null,
        container: $.extend(true, {}, defaultContainer),
        reset: reset,
        dialog: dialog,
        atLeastOneUserDefined: atLeastOneUserDefined,
        insertInto: insertInto,
        hasWithType: hasWithType
    };

    $(document).ready(function()
    {
         var parameterScreenHTML = Parts.getParameterScreenHTML();
        $("#parameterScreen").html(parameterScreenHTML);
        $("#editParameters").on('click', dialog);

        $("#params").on("focus", ".description", function()
        {
            $(this).animate({ height: "10em" }, 500);
        });
        $("#params").on("focusout", ".description", function()
        {
            $(this).animate({height:"1em"}, 500);
        });
        $("#params").on('click', '.deleteParent', function()
        {
            var tr = $(this).closest('tr');
            tr.addClass("removedParameter");
            if(tr[0].id === "t" && tr.not(".removedParameter"))
            {
                // for time parameter: make visible when Time-parameter has been removed
                $("#addTimeParameter").removeClass("hidden");
            }
            if ($("#params").children().not(".removedParameter").length === 0)
                $("#paramsTableHead").addClass("hidden");
        });

        $("#addParameter").on('click', function()
        {
            var addedDiv = addDefaultDefinition();
            Utils.focusFirstTabindexedDescendant(addedDiv);
            $("#paramsTableHead").removeClass("hidden");
        });

        $("#addTimeParameter").on('click', function()
        {
            var isTime = $("#params").find(".isT").length;
            var isTimeRemoved = $("#params").find(".isT.removedParameter").length;

            // if the timeParameterObject is empty, or if it is filled, but
            // the parameter in the dialog has been removed (in that case the
            // timeParameterObject has not been updated yet)
            if (Parameters.timeId === null || isTimeRemoved === isTime)
            {
                $("#params").append(Parts.getParameterDefinitionHTML());
                var div = $("#params").children().last();
                // div.children().children().prop('disabled', true);
                $(div).prop('id', 't');
                div.find(".name").val(i18next.t('parameters:time'));
                div.find(".parameter-type-select").val(Types.primitives.integer.name);
                div.find(".parameter-type-select").prop("disabled", "disabled");
                div.find(".parameter-evaluated").remove();
                div.find(".parameter-initial-value-container").remove();

                Utils.focusFirstTabindexedDescendant($("#params").children().last());
                $("#paramsTableHead").removeClass("hidden");
                $("#addTimeParameter").addClass("hidden");
            }
        });
    });

    // Resets the parameters to the default
    function reset()
    {
        Parameters.container = $.extend(true, {}, defaultContainer);
        Parameters.counter = 0;
        Parameters.timeId = null;
    }

    function dialog()
    {
        if (Parameters.timeId !== null)
        {
            $("#addTimeParameter").addClass("hidden");
        }
        else
        {
            $("#addTimeParameter").removeClass("hidden");
        }

        $("#parameterScreen").dialog(
        {
            title: i18next.t('parameters:title'),
            height: Constants.heightParameterScreen,
            width: Constants.widthParameterScreen,
            modal: true,
            buttons: [
            {
                text: i18next.t('common:confirm'),
                click: function()
                {
                    save();
                    $(this).dialog('close');
                }
            },
            {
                text: i18next.t('common:cancel'),
                click: function()
                {
                    $(this).dialog('close');
                }
            }],
            close: function()
            {
                $("#main").focus();
            }
        });

        $("#params").empty();
        $("#paramsTableHead").addClass("hidden");

        Parameters.container.sequence.forEach(function(parameter)
        {
            var addedDiv = addDefaultDefinition();
            addedDiv.removeClass("newParameter").addClass("existingParameter");

            addedDiv.prop('id', parameter.id);

            var typeSelect = addedDiv.find(".parameter-type-select");

            if (parameter.id === "t")
            {
                addedDiv.addClass("isT");
                typeSelect.val(Types.primitives.integer.name);
                typeSelect.prop("disabled", "disabled");
                addedDiv.find(".parameter-evaluated").remove();
                addedDiv.find(".parameter-initial-value-container").remove();
                addedDiv.find(".parameter-min-container").remove();
                addedDiv.find(".parameter-max-container").remove();
            }

            addedDiv.find(".name").val(parameter.name);

            if (parameter.type.name === Types.primitives.enumeration.name)
            {
                parameter.type.insertTypeIntoDOM(typeSelect.parent());
            }
            typeSelect.val(parameter.type.name).trigger('change');
            addedDiv.removeClass("changedTypeParameter");

            addedDiv.find(".parameter-evaluated").prop('checked', parameter.evaluated);

            parameter.type.setInDOM(addedDiv.find(".parameter-initial-value-container"), parameter.type.defaultValue);

            if ('minimum' in parameter.type) parameter.type.setInDOM(addedDiv.find(".parameter-min-container"), parameter.type.minimum);
            if ('maximum' in parameter.type) parameter.type.setInDOM(addedDiv.find(".parameter-max-container"), parameter.type.maximum);
{'fraction_non_alphanumeric': 0.15687885010266941, 'fraction_numerical': 0.0034496919917864476, 'mean_word_length': 1.918504314477469, 'pattern_counts': {'":': 0, '<': 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': '5795685', 'n_tokens_mistral': 3041, 'n_tokens_neox': 2930, 'n_words': 484}