<commit_before>class @Settlement
  contsructor: () ->
    @creditorSum = 0
    @debtorSum = 0
  toggle: (checkbox, amount) ->
    if checkbox.checked
      if amount < 0
        @debtorSum -= amount
      else
        @creditorSum += amount
      $(checkbox.parentNode.parentNode).removeClass('disabled')
    else
      if amount < 0
        @debtorSum += amount
      else
        @creditorSum -= amount
      $(checkbox.parentNode.parentNode).addClass('disabled')
    $('#debtor_sum').html(numToFormattedString(@debtorSum))
    $('#creditor_sum').html(numToFormattedString(@creditorSum))

    if @debtorSum > @creditorSum
      $('#target_description').html('に');
      $('#result').html(' から ' + numToFormattedString(@debtorSum - @creditorSum) + '円 を入金する。')
    else
      $('#target_description').html('から');
      $('#result').html(' に ' + numToFormattedString(@creditorSum - @debtorSum) + '円 が入金される。')

numToFormattedString = (num) ->
  str = num.toString()
  result = ''
  count = 0
  for i in [str.length-1..0]
    result = str.charAt(i) + result
    break if str.charAt(i) == '-' || i == 0
    count += 1
    if (count % 3) == 0
      result = ',' + result
  result

$ ->
  refreshTargets = ->
    $('#target_deals').load($('#target_deals_form').data('url'), $('#target_deals_form').serialize())

  $('#select_credit_account select.refresh_targets').change(refreshTargets)

  $('#select_credit_account button.refresh_targets').click ->
    refreshTargets()
    return false

  $('#target_deals a.selectAll').click ->
    $('table.book input[type=checkbox]').each ->
      $(@).click() if !@checked
    false

  $('#target_deals a.clearAll').click ->
    $('table.book input[type=checkbox]').each ->
      $(@).click() if @checked
    false<commit_msg>[#65843404] Fix the bug that selectAll/clearAll does not work after ajax refresh.<commit_after>class @Settlement
  contsructor: () ->
    @creditorSum = 0
    @debtorSum = 0
  toggle: (checkbox, amount) ->
    if checkbox.checked
      if amount < 0
        @debtorSum -= amount
      else
        @creditorSum += amount
      $(checkbox.parentNode.parentNode).removeClass('disabled')
    else
      if amount < 0
        @debtorSum += amount
      else
        @creditorSum -= amount
      $(checkbox.parentNode.parentNode).addClass('disabled')
    $('#debtor_sum').html(numToFormattedString(@debtorSum))
    $('#creditor_sum').html(numToFormattedString(@creditorSum))

    if @debtorSum > @creditorSum
      $('#target_description').html('に');
      $('#result').html(' から ' + numToFormattedString(@debtorSum - @creditorSum) + '円 を入金する。')
    else
      $('#target_description').html('から');
      $('#result').html(' に ' + numToFormattedString(@creditorSum - @debtorSum) + '円 が入金される。')

numToFormattedString = (num) ->
  str = num.toString()
  result = ''
  count = 0
  for i in [str.length-1..0]
    result = str.charAt(i) + result
    break if str.charAt(i) == '-' || i == 0
    count += 1
    if (count % 3) == 0
      result = ',' + result
  result

$ ->
  refreshTargets = ->
    $('#target_deals').load($('#target_deals_form').data('url'), $('#target_deals_form').serialize())

  $('#select_credit_account select.refresh_targets').change(refreshTargets)

  $('#select_credit_account button.refresh_targets').click ->
    refreshTargets()
    return false

  $('#target_deals').on('click', 'a.selectAll', (e)->
    $('table.book input[type=checkbox]').each ->
      $(@).click() if !@checked
    e.preventDefault()
  )
  $('#target_deals').on('click', 'a.clearAll', (e)->
    $('table.book input[type=checkbox]').each ->
      $(@).click() if @checked
    e.preventDefault()
  )
{'fraction_non_alphanumeric': 0.18079561042524006, 'fraction_numerical': 0.00823045267489712, 'mean_word_length': 3.2346109175377467, 'pattern_counts': {'":': 0, '<': 7, '<?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': '123356', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1203, 'n_words': 222}