<commit_before>#Util functions so the code looks cleaner

#vss stands for validation-summary selector
vss = (href) -> $("div[class='validation-summary'] a[href='##{href}']")
vssText = (href,text)     -> if text? then vss(href).text(text) else if vss(href).length > 0 then vss(href).text().trim() else ""
checked = (selector,val)  -> if val?  then $("##{selector}").prop('checked',val) else $("##{selector}").prop('checked')
val = (selector,text)     -> if text? then $("##{selector}").val(text) else $("##{selector}").val()
subString = (str,start,end) -> str.substring(start.length,end.length)
visible = (selector) -> $("##{selector}").is(":visible")
legend = (selector)-> $("##{selector}").parent().find("legend")
label = (selector) -> $("label[for='#{selector}']")
S = (selector) -> $("##{selector}")


#
# Fix Error Messages function
#

window.fixErrorMessages = (o) ->

  currentText = vssText(o.howOften)
  vssText(o.howOften, o.howOftenNText + subString(currentText, o.howOftenText, currentText))

  if checked o.beenPaidYetN
    currentText = vssText(o.howMuchPaid)
    vssText(o.howMuchPaid,o.howMuchPaidNText + subString(currentText, o.howMuchPaidYText, currentText))

    currentText = vssText(o.whatDatePaid)
    vssText(o.whatDatePaid,o.whatDatePaidNText + subString(currentText, o.whatDatePaidYText, currentText))

    currentText = vssText(o.howOften)
    vssText(o.howOften,o.howOftenNText + subString(currentText, o.howOftenText, currentText))

    currentText = vssText(o.usuallyPaidSameAmount)

    textToUse = switch (val o.howOftenFrequency)
      when "Weekly"       then o.usuallyPaidSameAmountNWeekText
      when "Fortnightly"  then o.usuallyPaidSameAmountNFortnightText
      when "Four-Weekly"   then o.usuallyPaidSameAmountNFourWeekText
      when "Monthly"      then o.usuallyPaidSameAmountNMonthText
      else o.usuallyPaidSameAmountNOtherText

    vssText(o.usuallyPaidSameAmount,textToUse + subString(currentText, o.usuallyPaidSameAmountText, currentText))

  if checked o.beenPaidYetY
    currentText = vssText(o.usuallyPaidSameAmount)
    textToUse = switch (val(o.howOftenFrequency))
      when "Weekly" then o.usuallyPaidSameAmountNWeekText
      when "Fortnightly" then o.usuallyPaidSameAmountNFortnightText
      when "Four-Weekly" then o.usuallyPaidSameAmountNFourWeekText
      when "Monthly" then o.usuallyPaidSameAmountNMonthText
      else o.usuallyPaidSameAmountNOtherText
    vssText(o.usuallyPaidSameAmount,textToUse + subString(currentText, o.usuallyPaidSameAmountText, currentText))

    currentText = vssText(o.howOften)
    vssText(o.howOften,o.howOftenYText + subString(currentText, o.howOftenText, currentText))



hideBeenPaidYetWrapOnY = (o,reset) ->
  label(o.howMuchPaid).text(o.howMuchPaidYText)
  val(o.howMuchPaid,"") if reset
  legend(o.whatDatePaid).html(o.whatDatePaidYText)
  val(o.whatDatePaidDay,"") if reset
  val(o.whatDatePaidMonth,"") if reset
  val(o.whatDatePaidYear,"") if reset
  label(o.howOften).text(o.howOftenYText)
  val(o.howOften,"") if reset
  label(o.monthlyPayDay).text(o.monthlyPayDayYText)
  val(o.monthlyPayDay,"") if reset
  textToUse = switch (val(o.howOften))
    when "Weekly" then o.usuallyPaidSameAmountWeeklyText
    when "Fortnightly" then o.usuallyPaidSameAmountFortnightlyText
    when "Four-Weekly" then o.usuallyPaidSameAmountFourWeeklyText
    when "Monthly" then o.usuallyPaidSameAmountMonthlyText
    else o.usuallyPaidSameAmountOtherText

  legend(o.usuallyPaidSameAmount).html(textToUse)
  checked(o.usuallyPaidSameAmountY, false) if reset
  checked(o.usuallyPaidSameAmountN, false) if reset

hideBeenPaidYetWrapOnN = (o,reset) ->
  label(o.howMuchPaid).text(o.howMuchPaidNText)
  val(o.howMuchPaid,"") if reset
  legend(o.whatDatePaid).html(o.whatDatePaidNText)
  val(o.whatDatePaidDay,"") if reset
  val(o.whatDatePaidMonth,"") if reset
  val(o.whatDatePaidYear,"") if reset
  label(o.howOften).text(o.howOftenNText)
  val(o.howOften,"") if reset
  label(o.monthlyPayDay).text(o.monthlyPayDayNText)
  val(o.monthlyPayDay,"") if reset
  textToUse = switch (val(o.howOften))
    when "Weekly" then o.usuallyPaidSameAmountWeeklyTextExpected
    when "Fortnightly" then o.usuallyPaidSameAmountFortnightlyTextExpected
    when "Four-Weekly" then o.usuallyPaidSameAmountFourWeeklyTextExpected
    when "Monthly" then o.usuallyPaidSameAmountMonthlyTextExpected
    else o.usuallyPaidSameAmountOtherTextExpected

  legend(o.usuallyPaidSameAmount).html(textToUse)
  checked(o.usuallyPaidSameAmountY, false) if reset
  checked(o.usuallyPaidSameAmountN, false) if reset


hideBeenPaid = (ctx,reset,hideFunction) ->
  S("beenPaidYetWrap").slideUp 0, -> hideFunction(ctx,reset)
  S("usuallyPaidSameAmountWrap").slideUp 0
  S("monthlyPayDayWrap").slideUp 0
  S("beenPaidYetWrap").slideDown 0
  S("howOften_wrap").slideUp(0, -> (val ctx.howOftenFrequencyOther, "") if reset)

onBeenPaidYetY = (ctx,reset) -> #Double -> because it's a function returning a function, which the jQuqery .on function will receive.
  ->                      #The first function exists so the returned function has the "context" variable in scope
    hideBeenPaid(ctx,reset,hideBeenPaidYetWrapOnY)

onBeenPaidYetN = (ctx,reset) -> #Double -> because it's a function returning a function, which the jQuqery .on function will receive.
  ->                      #The first function exists so the returned function has the "context" variable in scope
    hideBeenPaid(ctx,reset,hideBeenPaidYetWrapOnN)


#
#Been Paid Yet function
#

window.beenPaidYet = (ctx) ->
  if checked(ctx.beenPaidYetY)
    onBeenPaidYetY(ctx,false)()
  else if checked(ctx.beenPaidYetN)
    onBeenPaidYetN(ctx,false)()
  else
    S("beenPaidYetWrap").slideUp 0, -> hideBeenPaidYetWrapOnN(ctx,false)
    S("usuallyPaidSameAmountWrap").slideUp 0
    S("monthlyPayDayWrap").slideUp 0
    S("howOften_wrap").slideUp(0)

  S(ctx.beenPaidYetY).on "click", onBeenPaidYetY(ctx,true)
  S(ctx.beenPaidYetN).on "click", onBeenPaidYetN(ctx,true)


  
  
onHowOftenFrequency = (ctx,reset) -> #Double -> because it's a function returning a function, which the jQuqery .on function will receive.
  ->                           #The first function exists so the returned function has the "context" variable in scope
    if visible("usuallyPaidSameAmountWrap")
      S("usuallyPaidSameAmountWrap").slideUp 0, ->
        checked(ctx.usuallyPaidSameAmountY,false) if reset
        checked(ctx.usuallyPaidSameAmountN,false) if reset

    S("monthlyPayDayWrap").slideUp 0, -> val(ctx.monthlyPayDay,"") if visible("monthlyPayDayWrap") and reset<commit_msg>DE766 - Little problem with conflicting javascript<commit_after>#Util functions so the code looks cleaner

#vss stands for validation-summary selector
vss = (href) -> $("div[class='validation-summary'] a[href='##{href}']")
vssText = (href,text)     -> if text? then vss(href).text(text) else if vss(href).length > 0 then vss(href).text().trim() else ""
checked = (selector,val)  -> if val?  then $("##{selector}").prop('checked',val) else $("##{selector}").prop('checked')
val = (selector,text)     -> if text? then $("##{selector}").val(text) else $("##{selector}").val()
subString = (str,start,end) -> str.substring(start.length,end.length)
visible = (selector) -> $("##{selector}").is(":visible")
legend = (selector)-> $("##{selector}").parent().find("legend")
label = (selector) -> $("label[for='#{selector}']")
S = (selector) -> $("##{selector}")


#
# Fix Error Messages function
#

window.fixErrorMessages = (o) ->

  currentText = vssText(o.howOften)
  vssText(o.howOften, o.howOftenNText + subString(currentText, o.howOftenText, currentText))

  if checked o.beenPaidYetN
    currentText = vssText(o.howMuchPaid)
    vssText(o.howMuchPaid,o.howMuchPaidNText + subString(currentText, o.howMuchPaidYText, currentText))

    currentText = vssText(o.whatDatePaid)
    vssText(o.whatDatePaid,o.whatDatePaidNText + subString(currentText, o.whatDatePaidYText, currentText))

    currentText = vssText(o.howOften)
    vssText(o.howOften,o.howOftenNText + subString(currentText, o.howOftenText, currentText))

    currentText = vssText(o.usuallyPaidSameAmount)

    textToUse = switch (val o.howOftenFrequency)
      when "Weekly"       then o.usuallyPaidSameAmountNWeekText
      when "Fortnightly"  then o.usuallyPaidSameAmountNFortnightText
      when "Four-Weekly"   then o.usuallyPaidSameAmountNFourWeekText
      when "Monthly"      then o.usuallyPaidSameAmountNMonthText
      else o.usuallyPaidSameAmountNOtherText

    vssText(o.usuallyPaidSameAmount,textToUse + subString(currentText, o.usuallyPaidSameAmountText, currentText))

  if checked o.beenPaidYetY
    currentText = vssText(o.usuallyPaidSameAmount)
    textToUse = switch (val(o.howOftenFrequency))
      when "Weekly" then o.usuallyPaidSameAmountNWeekText
      when "Fortnightly" then o.usuallyPaidSameAmountNFortnightText
      when "Four-Weekly" then o.usuallyPaidSameAmountNFourWeekText
      when "Monthly" then o.usuallyPaidSameAmountNMonthText
      else o.usuallyPaidSameAmountNOtherText
    vssText(o.usuallyPaidSameAmount,textToUse + subString(currentText, o.usuallyPaidSameAmountText, currentText))

    currentText = vssText(o.howOften)
    vssText(o.howOften,o.howOftenYText + subString(currentText, o.howOftenText, currentText))



hideBeenPaidYetWrapOnY = (o,reset) ->
  label(o.howMuchPaid).text(o.howMuchPaidYText)
  val(o.howMuchPaid,"") if reset
  legend(o.whatDatePaid).html(o.whatDatePaidYText)
  val(o.whatDatePaidDay,"") if reset
  val(o.whatDatePaidMonth,"") if reset
  val(o.whatDatePaidYear,"") if reset
  label(o.howOften).text(o.howOftenYText)
  val(o.howOften,"") if reset
  label(o.monthlyPayDay).text(o.monthlyPayDayYText)
  val(o.monthlyPayDay,"") if reset
  textToUse = switch (val(o.howOften))
    when "Weekly" then o.usuallyPaidSameAmountWeeklyText
    when "Fortnightly" then o.usuallyPaidSameAmountFortnightlyText
    when "Four-Weekly" then o.usuallyPaidSameAmountFourWeeklyText
    when "Monthly" then o.usuallyPaidSameAmountMonthlyText
    else o.usuallyPaidSameAmountOtherText

  legend(o.usuallyPaidSameAmount).html(textToUse)
  checked(o.usuallyPaidSameAmountY, false) if reset
  checked(o.usuallyPaidSameAmountN, false) if reset

hideBeenPaidYetWrapOnN = (o,reset) ->
  label(o.howMuchPaid).text(o.howMuchPaidNText)
  val(o.howMuchPaid,"") if reset
  legend(o.whatDatePaid).html(o.whatDatePaidNText)
  val(o.whatDatePaidDay,"") if reset
  val(o.whatDatePaidMonth,"") if reset
  val(o.whatDatePaidYear,"") if reset
  label(o.howOften).text(o.howOftenNText)
  val(o.howOften,"") if reset
  label(o.monthlyPayDay).text(o.monthlyPayDayNText)
  val(o.monthlyPayDay,"") if reset
  textToUse = switch (val(o.howOften))
    when "Weekly" then o.usuallyPaidSameAmountWeeklyTextExpected
    when "Fortnightly" then o.usuallyPaidSameAmountFortnightlyTextExpected
    when "Four-Weekly" then o.usuallyPaidSameAmountFourWeeklyTextExpected
    when "Monthly" then o.usuallyPaidSameAmountMonthlyTextExpected
    else o.usuallyPaidSameAmountOtherTextExpected

  legend(o.usuallyPaidSameAmount).html(textToUse)
  checked(o.usuallyPaidSameAmountY, false) if reset
  checked(o.usuallyPaidSameAmountN, false) if reset


hideBeenPaid = (ctx,reset,hideFunction) ->
  S("beenPaidYetWrap").slideUp 0, -> hideFunction(ctx,reset)
  S("usuallyPaidSameAmountWrap").slideUp 0
  S("monthlyPayDayWrap").slideUp 0
  S("beenPaidYetWrap").slideDown 0
  S("howOften_wrap").slideUp(0, -> (val ctx.howOftenFrequencyOther, "") if reset)

onBeenPaidYetY = (ctx,reset) -> #Double -> because it's a function returning a function, which the jQuqery .on function will receive.
  ->                      #The first function exists so the returned function has the "context" variable in scope
    hideBeenPaid(ctx,reset,hideBeenPaidYetWrapOnY)

onBeenPaidYetN = (ctx,reset) -> #Double -> because it's a function returning a function, which the jQuqery .on function will receive.
  ->                      #The first function exists so the returned function has the "context" variable in scope
    hideBeenPaid(ctx,reset,hideBeenPaidYetWrapOnN)


#
#Been Paid Yet function
#

window.beenPaidYet = (ctx) ->
  if checked(ctx.beenPaidYetY)
    onBeenPaidYetY(ctx,false)()
  else if checked(ctx.beenPaidYetN)
    onBeenPaidYetN(ctx,false)()
  else
    S("beenPaidYetWrap").slideUp 0, -> hideBeenPaidYetWrapOnN(ctx,false)
    S("usuallyPaidSameAmountWrap").slideUp 0
    S("monthlyPayDayWrap").slideUp 0

  S(ctx.beenPaidYetY).on "click", onBeenPaidYetY(ctx,true)
  S(ctx.beenPaidYetN).on "click", onBeenPaidYetN(ctx,true)


  
  
onHowOftenFrequency = (ctx,reset) -> #Double -> because it's a function returning a function, which the jQuqery .on function will receive.
  ->                           #The first function exists so the returned function has the "context" variable in scope
    if visible("usuallyPaidSameAmountWrap")
      S("usuallyPaidSameAmountWrap").slideUp 0, ->
        checked(ctx.usuallyPaidSameAmountY,false) if reset
        checked(ctx.usuallyPaidSameAmountN,false) if reset

    S("monthlyPayDayWrap").slideUp 0, -> val(ctx.monthlyPayDay,"") if visible("monthlyPayDayWrap") and reset
{'fraction_non_alphanumeric': 0.12017950863314825, 'fraction_numerical': 0.0019776374838366166, 'mean_word_length': 4.970935513169845, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 61, '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': '6724796', 'n_tokens_mistral': 4738, 'n_tokens_neox': 4471, 'n_words': 847}