<commit_before>$(document).ready(function(){

  // need to find the max data entry on the page and start incrementing from there
  $dataEntry = 0;
  $('.form-container-repeater').each(function() {
    if ($dataEntry < $(this).attr('data-entry')) {
      $dataEntry = parseInt($(this).attr('data-entry'));
    }
  });

  $('.form-container-survey').on("click", '.duplicate-form-container-repeater', function(e){
    e.preventDefault();
    e.stopPropagation();

    $scrollPosition = $(this).offset().top - 50;
    $formValidator.parsley().destroy()
    unbindChosenTypes()

    var container = $(this).closest('.form-container-repeater');
    $clonedContainer = container.clone(true);
    var containerItems = $($clonedContainer).find('.form-container-entry-item');

    // increment data-entry by 1 on every click
    $dataEntry = $dataEntry + 1;

    // update attributes with timestamps
    updateDom(containerItems, $dataEntry);
    stringifyAndResetContainer($clonedContainer)

    // fix repeater container data-entry numbers
    $clonedContainer.attr("data-entry", $dataEntry);
    $clonedContainer.find(".form-container-repeater").attr("data-entry", $dataEntry);

    // set cloned container to display none for fading in
    $clonedContainer.attr("style", "display: none;").addClass("new-clone");

    $(container).after($clonedContainer);
    clearValues($(container).nextAll(".form-container-repeater").find('.form-container-entry-item'));
    bindChosenTypes()

    $newClone = $(".new-clone");

    $newClone.delay("100").fadeIn(1000).removeClass("new-clone");

    setTimeout(function() {
      $("html, body").animate({
        scrollTop: $scrollPosition
      }, 500);
    }, 200);

    clearValues($(container).nextAll(".form-container-repeater").find('.form-container-entry-item'));
    // bind chosen select, multiselect, and attachinary
    $('.attachinary-input').attachinary();
    $(".chosen-multiselect").chosen();
    $(".chosen-select").chosen();
    $(".bootstrap-checkbox-multiselect").multiselect();
    // bind maps
    setupDefaultMaps();
    bindButtons();
    resetMapButtons();
    // bind ConditionalLogic
    cl = new ConditionalLogic;
    cl.findRules();

  });

  function removeErrorBackground(type){
    $('div.form-container-entry-item[data-element-type='+ type +']').find('div.col-sm-7').removeAttr('style')
  }<commit_msg>clean up code<commit_after>$(document).ready(function(){

  // need to find the max data entry on the page and start incrementing from there
  $dataEntry = 0;
  $('.form-container-repeater').each(function() {
    if ($dataEntry < $(this).attr('data-entry')) {
      $dataEntry = parseInt($(this).attr('data-entry'));
    }
  });

  $('.form-container-survey').on("click", '.duplicate-form-container-repeater', function(e){
    e.preventDefault();
    e.stopPropagation();
    
    $formValidator.parsley().destroy()
    unbindChosenTypes()

    var container = $(this).closest('.form-container-repeater');
    $clonedContainer = container.clone(true);
    var containerItems = $($clonedContainer).find('.form-container-entry-item');

    // increment data-entry by 1 on every click
    $dataEntry = $dataEntry + 1;

    // update attributes with timestamps
    updateDom(containerItems, $dataEntry);
    stringifyAndResetContainer($clonedContainer)

    // fix repeater container data-entry numbers
    $clonedContainer.attr("data-entry", $dataEntry);
    $clonedContainer.find(".form-container-repeater").attr("data-entry", $dataEntry);

    $(container).after($clonedContainer);
    clearValues($(container).nextAll(".form-container-repeater").find('.form-container-entry-item'));
    bindChosenTypes()







    $formValidator.parsley()
    new $RequireSurveyInputData().inspectElements();
    $($('div.form-container-entry-item[data-required=true]').find('ul.parsley-errors-list')).remove()
    removeErrorBackground('radio')
    removeErrorBackground('checkbox')
    removeErrorBackground('checkboxes')
    removeUserSuccessClass()


    // bind maps
    setupDefaultMaps();
    bindButtons();
    resetMapButtons();
    // bind ConditionalLogic
    cl = new ConditionalLogic;
    cl.findRules();

  });

  function removeErrorBackground(type){
    $('div.form-container-entry-item[data-element-type='+ type +']').find('div.col-sm-7').removeAttr('style')
  }
{'fraction_non_alphanumeric': 0.1737121737121737, 'fraction_numerical': 0.005313005313005313, 'mean_word_length': 3.9770114942528734, 'pattern_counts': {'":': 0, '<': 5, '<?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': '240373', 'n_tokens_mistral': 1324, 'n_tokens_neox': 1279, 'n_words': 214}