<commit_before>// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

var feedbackTab;

// Close the feedback form panel on success,
// display error messages on failure
function feedbackCallback(response) {
  if (response.success) {
      feedbackTab.hideTab();
   } else {
     jQuery('.form-field-error').html('');
     for (var key in response.errors){
       jQuery('#form-field-error-' + key).html( response.errors[key] );
     }
   }
}

function clearFormElements(element) {
  jQuery(element).find(':input').each(function() {
      switch(this.type) {
          case 'password':
          case 'select-multiple':
          case 'select-one':
          case 'text':
          case 'textarea':
              jQuery(this).val('');
              break;
          case 'checkbox':
          case 'radio':
              this.checked = false;
      }
  });
}

function addGuidanceField(guidance_selector, field_selector){
  jQuery(guidance_selector).hide();
  jQuery(field_selector).autofill({
       value: jQuery(guidance_selector).text(),
       defaultTextColor: '#595454',
       activeTextColor: '#000000'
     });  
}

// Put guidance text as default in search boxes
function addSearchGuidance() {
  
  addGuidanceField('#guidance-name', '#stop_name_form #name');
  addGuidanceField('#guidance-route-number', '#bus_route_form #route_number');
  addGuidanceField('#guidance-area', '#bus_route_form #area');
  addGuidanceField('#guidance-to', '#train_route_form #to');
  addGuidanceField('#guidance-to', '#other_route_form #to');
  addGuidanceField('#guidance-from', '#train_route_form #from');
  addGuidanceField('#guidance-from', '#other_route_form #from');
  
}

// For an ongoing issue, don't show the date and time fields
function hideProblemDateTimeForOngoing() {
  if (jQuery('#is-campaign-0').is(':not(:checked)')){
    jQuery('#date-field').hide();
    jQuery('#time-field').hide();    
  }
  jQuery('input[name=problem[is_campaign]]').click(function(){
    if (jQuery('#is-campaign-1').is(':checked')){
      jQuery('#date-field').hide("slow");
      jQuery('#time-field').hide("slow");
    }else{
      jQuery('#date-field').show("slow");
      jQuery('#time-field').show("slow");
    }
  })
}

// Add listeners for link click events
function addLinkActions() {
  jQuery('#ask-advice-link').click(function(){
    if(jQuery('#advice-request-form').length == 0){
      return true;
    }else{
      jQuery('#advice-request-form').show();
      return false;
    }
  })
  jQuery('.campaign-comment-link').live('click', function(){
    id = jQuery(this).attr('id').split('_')[1];
    if(jQuery('#commentbox_' + id).length == 0) {
      return true;
    }else{
      jQuery('#commentbox_' + id).show();
      return false;
    }
  })

  setupForm('.campaign-info .ajax_new_campaign_comment', updateCommentCallback);<commit_msg>Add quotes to name.<commit_after>// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

var feedbackTab;

// Close the feedback form panel on success,
// display error messages on failure
function feedbackCallback(response) {
  if (response.success) {
      feedbackTab.hideTab();
   } else {
     jQuery('.form-field-error').html('');
     for (var key in response.errors){
       jQuery('#form-field-error-' + key).html( response.errors[key] );
     }
   }
}

function clearFormElements(element) {
  jQuery(element).find(':input').each(function() {
      switch(this.type) {
          case 'password':
          case 'select-multiple':
          case 'select-one':
          case 'text':
          case 'textarea':
              jQuery(this).val('');
              break;
          case 'checkbox':
          case 'radio':
              this.checked = false;
      }
  });
}

function addGuidanceField(guidance_selector, field_selector){
  jQuery(guidance_selector).hide();
  jQuery(field_selector).autofill({
       value: jQuery(guidance_selector).text(),
       defaultTextColor: '#595454',
       activeTextColor: '#000000'
     });  
}

// Put guidance text as default in search boxes
function addSearchGuidance() {
  
  addGuidanceField('#guidance-name', '#stop_name_form #name');
  addGuidanceField('#guidance-route-number', '#bus_route_form #route_number');
  addGuidanceField('#guidance-area', '#bus_route_form #area');
  addGuidanceField('#guidance-to', '#train_route_form #to');
  addGuidanceField('#guidance-to', '#other_route_form #to');
  addGuidanceField('#guidance-from', '#train_route_form #from');
  addGuidanceField('#guidance-from', '#other_route_form #from');
  
}

// For an ongoing issue, don't show the date and time fields
function hideProblemDateTimeForOngoing() {
  if (jQuery('#is-campaign-0').is(':not(:checked)')){
    jQuery('#date-field').hide();
    jQuery('#time-field').hide();    
  }
  jQuery('input[name="problem[is_campaign]"]').click(function(){
    if (jQuery('#is-campaign-1').is(':checked')){
      jQuery('#date-field').hide("slow");
      jQuery('#time-field').hide("slow");
    }else{
      jQuery('#date-field').show("slow");
      jQuery('#time-field').show("slow");
    }
  })
}

// Add listeners for link click events
function addLinkActions() {
  jQuery('#ask-advice-link').click(function(){
    if(jQuery('#advice-request-form').length == 0){
      return true;
    }else{
      jQuery('#advice-request-form').show();
      return false;
    }
  })
  jQuery('.campaign-comment-link').live('click', function(){
    id = jQuery(this).attr('id').split('_')[1];
    if(jQuery('#commentbox_' + id).length == 0) {
      return true;
    }else{
      jQuery('#commentbox_' + id).show();
      return false;
    }
  })

  setupForm('.campaign-info .ajax_new_campaign_comment', updateCommentCallback);
{'fraction_non_alphanumeric': 0.17012942779291554, 'fraction_numerical': 0.0057901907356948225, 'mean_word_length': 3.5142198308993082, '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': '4419872', 'n_tokens_mistral': 1797, 'n_tokens_neox': 1738, 'n_words': 340}