<commit_before>$ ->
  # Used for both placement form and refugee_placement form
  $form = $('body.placements form, body.refugees form')
  $homeSelect = $('#placement_home_id, #refugee_placements_attributes_0_home_id')
  $placementCost = $form.find('.placement_cost, .refugee_placements_cost')
  $placementCostField = $form.find('#placement_cost, #refugee_placements_attributes_0_cost')
  $familyAndEmergencyHomeCosts = $form.find('.family_and_emergency_home_costs')

  setSpecificationField = ->
    $specification = $form.find('.placement_specification, .refugee_placements_specification')
    if $homeSelect.find(':selected').attr('data-use-specification') is 'true'
      $specification.show()
    else
      $specification.hide()

  setFieldsForTypeOfCost = ->
    if $homeSelect.find(':selected').attr('data-type-of-cost') is 'cost_per_day'
      $placementCost.hide()
      $familyAndEmergencyHomeCosts.hide()
    else if $homeSelect.find(':selected').attr('data-type-of-cost') is 'cost_per_placement'
      $placementCost.show()
      $familyAndEmergencyHomeCosts.hide()
    else if $homeSelect.find(':selected').attr('data-type-of-cost') is 'cost_for_family_and_emergency_home'
      $placementCost.hide()
      $familyAndEmergencyHomeCosts.show()

  $homeSelect.change ->
    setSpecificationField()
    setFieldsForTypeOfCost()

  $(window).load ->
    setSpecificationField()
    setFieldsForTypeOfCost()<commit_msg>Hide family costs and placement cost on load for new placement<commit_after>$ ->
  # Used for both placement form and refugee_placement form
  $form = $('body.placements form, body.refugees form')
  $homeSelect = $('#placement_home_id, #refugee_placements_attributes_0_home_id')
  $placementCost = $form.find('.placement_cost, .refugee_placements_cost')
  $placementCostField = $form.find('#placement_cost, #refugee_placements_attributes_0_cost')
  $familyAndEmergencyHomeCosts = $form.find('.family_and_emergency_home_costs')

  setSpecificationField = ->
    $specification = $form.find('.placement_specification, .refugee_placements_specification')
    if $homeSelect.find(':selected').attr('data-use-specification') is 'true'
      $specification.show()
    else
      $specification.hide()

  setFieldsForTypeOfCost = ->
    if $homeSelect.find(':selected').attr('data-type-of-cost') is 'cost_per_day'
      $placementCost.hide()
      $familyAndEmergencyHomeCosts.hide()
    else if $homeSelect.find(':selected').attr('data-type-of-cost') is 'cost_per_placement'
      $placementCost.show()
      $familyAndEmergencyHomeCosts.hide()
    else if $homeSelect.find(':selected').attr('data-type-of-cost') is 'cost_for_family_and_emergency_home'
      $placementCost.hide()
      $familyAndEmergencyHomeCosts.show()
    else
      $placementCost.hide()
      $familyAndEmergencyHomeCosts.hide()

  $homeSelect.change ->
    setSpecificationField()
    setFieldsForTypeOfCost()

  $(window).load ->
    setSpecificationField()
    setFieldsForTypeOfCost()
{'fraction_non_alphanumeric': 0.13145539906103287, 'fraction_numerical': 0.0013413816230717639, 'mean_word_length': 4.98995983935743, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '237659', 'n_tokens_mistral': 964, 'n_tokens_neox': 936, 'n_words': 138}