<commit_before>var clientApp = clientApp || {};
var helpers = clientApp.helpers || {};
var parameters = parameters ||  {};
var parametersType = parametersType || {};

var params = {};
var ddl_params = {};

parameters.printParameters = function() {
  params,
  ddl_params = {};
  if (ddl.general.param_description != undefined) displayParametersDescription()
  if (ddl.params && ddl.params.length != 0) {
    $('#parameters').removeClass('di-none');
    var ddlParams = ddl.params;
    addResetButton();
    $('.param-container').remove();
    $("#parameters-container").append('<form id="params-form"></form>');
    for (var i = 0; i < ddlParams.length; i++) {
      var param = ddlParams[i];
      var functionName = $.fn[param.type];
      ddl_params[param.id] = param;

      if ($.isFunction(functionName)) {
        addToParamsObject(param);
        printParameter(param, i);
      } else console.error(param.type + ' param type is not correct');
    }
  }
}

parameters.resetValues = () => {
  for (let [index, parameter] of ddl.params.entries()) {
    if (parameter.type == 'label') continue;
    const defaults = {
      'textarea': "",
      'text': "",
      'checkbox': false,
      'numeric': 0,
      'range': 0
    }
    const parameterSelector = `#${parameter.type}_${parameter.id}`;

    if (parameter.type == 'selection_radio'){
      $(`#param-${parameter.id} > div > input[value="${parameter.default_value}"]`).attr('checked', true);
    };

    let defaultValue = "";
    if (parameter.hasOwnProperty('default_value')) {
      defaultValue = parameter.default_value;
    } else if (parameter.hasOwnProperty('values')) {
      defaultValue = parameter.values.default || defaults[parameter.type];
    } else {
      defaultValue = defaults[parameter.type];
    }
    $(parameterSelector).val(defaultValue);
    updateParamsArrayValue(parameter.id, defaultValue);
  }
}

function displayParametersDescription() {
  $('.parameters-description').remove();
  $('#parameters-container').append(
    '<div class=parameters-description></div>');
  
  var text = typeof ddl.general.param_description != 'string' ? ddl.general.param_description.join('') : ddl.general.param_description;
  $('.parameters-description').append(text);
}

parameters.setParametersValues = function(params_values){
  for (var i = 0; i < ddl.params.length; i++) {
    var param = ddl.params[i];
    updateParamsArrayValue(param.id, params_values[param.id]);
    if(param.type == "range"){
      $('#number_' + param.id).val(parseFloat(params_values[param.id]));
      $('#range_' + param.id).val(parseFloat(params_values[param.id]));
    }
    if(param.type == "selection_radio"){
      var values_keys = Object.keys(param.values);
      for (let j = 0; j < values_keys.length; j++)
        if(param.values[values_keys[j]] == params_values[param.id])
          $('#' + param.id + '_' + j).prop('checked', true);
    }
    if(param.type == "selection_collapsed"){
      $('#selection_collapsed_' + param.id).val(params_values[param.id]);
    }
    if(param.type == "checkbox"){
      $('#' + param.id).prop('checked', (params_values[param.id]));
    }
    if(param.type == "text"){
      $('#text_' + param.id).val(params_values[param.id]);
    }
  }
}

function printParameter(param, index) {
  $('<div class="param-' + index + ' param-container"></div>').appendTo('#params-form');
  $('<div class=param-content-' + index + ' ></div>').appendTo('.param-' + index).addClass("param-content");<commit_msg>[clientApp] checkbox value fixed when reloading an execution<commit_after>var clientApp = clientApp || {};
var helpers = clientApp.helpers || {};
var parameters = parameters ||  {};
var parametersType = parametersType || {};

var params = {};
var ddl_params = {};

parameters.printParameters = function() {
  params,
  ddl_params = {};
  if (ddl.general.param_description != undefined) displayParametersDescription()
  if (ddl.params && ddl.params.length != 0) {
    $('#parameters').removeClass('di-none');
    var ddlParams = ddl.params;
    addResetButton();
    $('.param-container').remove();
    $("#parameters-container").append('<form id="params-form"></form>');
    for (var i = 0; i < ddlParams.length; i++) {
      var param = ddlParams[i];
      var functionName = $.fn[param.type];
      ddl_params[param.id] = param;

      if ($.isFunction(functionName)) {
        addToParamsObject(param);
        printParameter(param, i);
      } else console.error(param.type + ' param type is not correct');
    }
  }
}

parameters.resetValues = () => {
  for (let [index, parameter] of ddl.params.entries()) {
    if (parameter.type == 'label') continue;
    const defaults = {
      'textarea': "",
      'text': "",
      'checkbox': false,
      'numeric': 0,
      'range': 0
    }
    const parameterSelector = `#${parameter.type}_${parameter.id}`;

    if (parameter.type == 'selection_radio'){
      $(`#param-${parameter.id} > div > input[value="${parameter.default_value}"]`).attr('checked', true);
    };

    let defaultValue = "";
    if (parameter.hasOwnProperty('default_value')) {
      defaultValue = parameter.default_value;
    } else if (parameter.hasOwnProperty('values')) {
      defaultValue = parameter.values.default || defaults[parameter.type];
    } else {
      defaultValue = defaults[parameter.type];
    }
    $(parameterSelector).val(defaultValue);
    updateParamsArrayValue(parameter.id, defaultValue);
  }
}

function displayParametersDescription() {
  $('.parameters-description').remove();
  $('#parameters-container').append(
    '<div class=parameters-description></div>');
  
  var text = typeof ddl.general.param_description != 'string' ? ddl.general.param_description.join('') : ddl.general.param_description;
  $('.parameters-description').append(text);
}

parameters.setParametersValues = function(params_values){
  for (var i = 0; i < ddl.params.length; i++) {
    var param = ddl.params[i];
    updateParamsArrayValue(param.id, params_values[param.id]);
    if(param.type == "range"){
      $('#number_' + param.id).val(parseFloat(params_values[param.id]));
      $('#range_' + param.id).val(parseFloat(params_values[param.id]));
    }
    if(param.type == "selection_radio"){
      var values_keys = Object.keys(param.values);
      for (let j = 0; j < values_keys.length; j++)
        if(param.values[values_keys[j]] == params_values[param.id])
          $('#' + param.id + '_' + j).prop('checked', true);
    }
    if(param.type == "selection_collapsed"){
      $('#selection_collapsed_' + param.id).val(params_values[param.id]);
    }
    if(param.type == "checkbox"){
      $('#checkbox_' + param.id).prop('checked', params_values[param.id]);
    }
    if(param.type == "text"){
      $('#text_' + param.id).val(params_values[param.id]);
    }
  }
}

function printParameter(param, index) {
  $('<div class="param-' + index + ' param-container"></div>').appendTo('#params-form');
  $('<div class=param-content-' + index + ' ></div>').appendTo('.param-' + index).addClass("param-content");
{'fraction_non_alphanumeric': 0.18776671408250356, 'fraction_numerical': 0.0017069701280227596, 'mean_word_length': 3.712466487935657, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '1874207', 'n_tokens_mistral': 2180, 'n_tokens_neox': 2171, 'n_words': 381}