<commit_before><%
  # TODO: url や更新場所など、呼び出し元依存の分岐コードが入ってしまっているのを整理したい
  update_area_id = deal.kind_of?(Deal::Base) ? 'deal_forms' : 'form_frame'
%>
<%= content_tag :div, :style => deal.summary_unified? ? '' : 'display:none;', :id => 'deal_summary_frame' do %>
  <%= f.hidden_field :summary_mode, :value => deal.summary_unified? ? 'unify' : 'split', :class => 'pattern_field' %>
  <%= f.text_field :summary, :size => "40", :tabindex => '10', :class => 'pattern_field' %>
  <%= link_to image_tag('plus.png', :align => "top", :style => "margin-top: 6px;", :width => "24px", :height => "24px"), 'javascript: splitSummary()' %>
  <div id="patterns"></div>
<% end %>

<div>
  <%
    entry_types = [:debtor_entries, :creditor_entries]
    entry_types.reverse! unless current_user.preferences.bookkeeping_style?
    tab_index = 10 # わからない
  %>
  <div style="float:left;">
    <% if current_user.preferences.bookkeeping_style? %>
      <div>借方</div>
    <% end %>
    <%
      first_entry = true
      line_number = -1
    %>
    <%= f.fields_for entry_types.first do |e| %>
      <% fixed = e.object.respond_to?(:settlement_attached?) && e.object.settlement_attached? %>
      <% if e.object.marked_for_destruction? %>
        <%= e.hidden_field :_delete, :value => '1', :class => 'pattern_field' %>
      <% else %>
        <div class="entry">
          <%= e.hidden_field :line_number, :value => line_number += 1, :class => 'pattern_field' %>
          <%= e.text_field :summary, :class => 'entry_summary pattern_field', :style => "width: 260px; margin-bottom: 0px; #{deal.summary_unified? ? 'display:none;' : ''}", :tabindex => tab_index += 1 %>
          <% if first_entry %>
            <%= link_to image_tag('minus.png', :align => "top", :style => "margin-top: 6px;", :width => "24px", :height => "24px"), 'javascript: unifySummary()', :class => 'entry_summary', :style => deal.summary_unified? ? "display:none;" : nil %>
            <% first_entry = false %>
          <% end %>
          <%= tag(:br, :class => 'entry_summary', :style => deal.summary_unified? ? "display:none;" : nil) %>
          <div style="float:left;">
          <% amount_field_name = entry_types.first == :debtor_entries ? :amount : :reversed_amount %>
          <%= e.text_field amount_field_name, :size => "8", :disabled => fixed, :class => 'amount pattern_field', :tabindex => tab_index += 1 %>
          <%= e.hidden_field amount_field_name if fixed %>
          </div>
          <div style="float:left;">円</div>
          <div style="float:left;">
          <% if fixed %>
            <input type='text' disabled='true' class='readonly' value='<%= e.object.account.name %>' tabindex='#{tabindex}' />
            <%= e.hidden_field(:account_id, :value => e.object.account.id, :class => 'pattern_field') %>
          <% else %>
            <%= e.select :account_id, grouped_options_for_select(current_user.accounts.grouped_options(entry_types.first == :creditor_entries), e.object.try(:account_id), ''), {}, :tabindex => (tab_index += 1), :class => 'pattern_field' %>
          <% end %>
          </div>
          <div style="clear:left;"></div>
        </div>
      <% end %>
    <% end %>
  </div>
  <% unless current_user.preferences.bookkeeping_style? %>
    <div style="float:left; padding: 0 16px;">→</div>
  <% end %>
  <div style="float:left;">
    <% if current_user.preferences.bookkeeping_style? %>
      <div>貸方</div>
    <% end %>
    <% line_number = -1 %>
    <%= f.fields_for entry_types.last do |e| %>
      <% fixed = e.object.respond_to?(:settlement_attached?) && e.object.settlement_attached? %>
      <% if e.object.marked_for_destruction? %>
        <%= e.hidden_field :_delete, :value => '1', :class => 'pattern_field' %>
      <% else %>
        <div class="entry">
          <%= e.hidden_field :line_number, :value => line_number += 1, :class => 'pattern_field' %>
          <%= e.text_field :summary, :style => "width: 260px; margin-bottom: 0px; #{deal.summary_unified? ? 'display:none;' : ''}", :class=>'entry_summary pattern_field', :tabindex => tab_index += 1 %>
          <%= tag(:br, :class => 'entry_summary', :style => deal.summary_unified? ? "display:none;" : nil) %>
          <div style="float:left;">
            <% amount_field_name = entry_types.last == :creditor_entries ? :reversed_amount : :amount %>
            <%= e.text_field amount_field_name, :size => "8", :disabled => fixed, :class => 'amount pattern_field', :tabindex => (tab_index += 1) %>
            <%= e.hidden_field amount_field_name if fixed  %>
          </div>
          <div style="float:left;">円</div>
          <div style="float:left;">
          <% if fixed %>
            <input type='text' disabled='true' class='readonly' value='<%= e.object.account.name %>' tabindex='#{tabindex}' />
            <%= e.hidden_field(:account_id, :value => e.object.account.id, :class => 'pattern_field') %>
          <% else %>
            <%= e.select :account_id, grouped_options_for_select(current_user.accounts.grouped_options(entry_types.last == :creditor_entries), e.object.try(:account_id), ''), {}, :tabindex => (tab_index += 1), :class => 'pattern_field' %>
          <% end %>
          </div>
          <div style="clear:left;"></div>
        </div>
      <% end %>
    <% end %>
  </div>
  <div class="deal_patterns" style="float:left; margin-left: 10px;">
    <div style="display:none;" id="load_pattern_url"><%= 
      case deal
      when Deal::General
        deal.new_record? ? new_complex_deal_path(:pattern_code => 'template_pattern_code') : edit_deal_path(:id => deal.id, :pattern_code => 'template_pattern_code')
      when Pattern::Deal
        deal.new_record? ? new_settings_deal_pattern_path(:pattern_code => 'template_pattern_code') : settings_deal_pattern_path(:id => deal.id, :pattern_code => 'template_pattern_code')
      else
        raise "unknown Deal object"
      end
    %></div>
    <div>
      <div>パターン呼出：<%= text_field_tag :pattern_keyword, '', :size => 10, :tabindex => 9 %></div>
      <div class="inline_guide">コードを指定してリターンを押してください</div>
    </div>
    <div id="found_patterns" style="width: 240px;" class="warning"></div>
  </div>
  <div style="clear: left;"></div>
</div>
<%= javascript_tag do %>
  jQuery(document).ready(function($){
    $('input#pattern_keyword').keypress(function(e){
      // When the return key is pressed on pattern_keyword field
      if (e.which && e.which === 13) {
        $('#found_patterns')[0].innerHTML = ''
        var code = $('input#pattern_keyword').val()
        if (code != '') {
          // try to load that pattern
          $('#notice').hide()
          var url = $('#load_pattern_url').text().replace('template_pattern_code', encodeURIComponent(code))
          // 指定したコードがないときは 'Code not found' が返る
          $.get(url, function(data) {
            if (data == 'Code not found') {
              $('#found_patterns')[0].innerHTML = 'コード「' + code + '」の記入パターンは登録されていません。'
            } else {
              $('#<%= update_area_id %>')[0].innerHTML = data
            }
          })
        }
        return false
      }
    })
  })

<% end %><commit_msg>Change found_patterns div id to pattern_search_result.<commit_after><%
  # TODO: url や更新場所など、呼び出し元依存の分岐コードが入ってしまっているのを整理したい
  update_area_id = deal.kind_of?(Deal::Base) ? 'deal_forms' : 'form_frame'
%>
<%= content_tag :div, :style => deal.summary_unified? ? '' : 'display:none;', :id => 'deal_summary_frame' do %>
  <%= f.hidden_field :summary_mode, :value => deal.summary_unified? ? 'unify' : 'split', :class => 'pattern_field' %>
  <%= f.text_field :summary, :size => "40", :tabindex => '10', :class => 'pattern_field' %>
  <%= link_to image_tag('plus.png', :align => "top", :style => "margin-top: 6px;", :width => "24px", :height => "24px"), 'javascript: splitSummary()' %>
  <div id="patterns"></div>
<% end %>

<div>
  <%
    entry_types = [:debtor_entries, :creditor_entries]
    entry_types.reverse! unless current_user.preferences.bookkeeping_style?
    tab_index = 10 # わからない
  %>
  <div style="float:left;">
    <% if current_user.preferences.bookkeeping_style? %>
      <div>借方</div>
    <% end %>
    <%
      first_entry = true
      line_number = -1
    %>
    <%= f.fields_for entry_types.first do |e| %>
      <% fixed = e.object.respond_to?(:settlement_attached?) && e.object.settlement_attached? %>
      <% if e.object.marked_for_destruction? %>
        <%= e.hidden_field :_delete, :value => '1', :class => 'pattern_field' %>
      <% else %>
        <div class="entry">
          <%= e.hidden_field :line_number, :value => line_number += 1, :class => 'pattern_field' %>
          <%= e.text_field :summary, :class => 'entry_summary pattern_field', :style => "width: 260px; margin-bottom: 0px; #{deal.summary_unified? ? 'display:none;' : ''}", :tabindex => tab_index += 1 %>
          <% if first_entry %>
            <%= link_to image_tag('minus.png', :align => "top", :style => "margin-top: 6px;", :width => "24px", :height => "24px"), 'javascript: unifySummary()', :class => 'entry_summary', :style => deal.summary_unified? ? "display:none;" : nil %>
            <% first_entry = false %>
          <% end %>
          <%= tag(:br, :class => 'entry_summary', :style => deal.summary_unified? ? "display:none;" : nil) %>
          <div style="float:left;">
          <% amount_field_name = entry_types.first == :debtor_entries ? :amount : :reversed_amount %>
          <%= e.text_field amount_field_name, :size => "8", :disabled => fixed, :class => 'amount pattern_field', :tabindex => tab_index += 1 %>
          <%= e.hidden_field amount_field_name if fixed %>
          </div>
          <div style="float:left;">円</div>
          <div style="float:left;">
          <% if fixed %>
            <input type='text' disabled='true' class='readonly' value='<%= e.object.account.name %>' tabindex='#{tabindex}' />
            <%= e.hidden_field(:account_id, :value => e.object.account.id, :class => 'pattern_field') %>
          <% else %>
            <%= e.select :account_id, grouped_options_for_select(current_user.accounts.grouped_options(entry_types.first == :creditor_entries), e.object.try(:account_id), ''), {}, :tabindex => (tab_index += 1), :class => 'pattern_field' %>
          <% end %>
          </div>
          <div style="clear:left;"></div>
        </div>
      <% end %>
    <% end %>
  </div>
  <% unless current_user.preferences.bookkeeping_style? %>
    <div style="float:left; padding: 0 16px;">→</div>
  <% end %>
  <div style="float:left;">
    <% if current_user.preferences.bookkeeping_style? %>
      <div>貸方</div>
    <% end %>
    <% line_number = -1 %>
    <%= f.fields_for entry_types.last do |e| %>
      <% fixed = e.object.respond_to?(:settlement_attached?) && e.object.settlement_attached? %>
      <% if e.object.marked_for_destruction? %>
        <%= e.hidden_field :_delete, :value => '1', :class => 'pattern_field' %>
      <% else %>
        <div class="entry">
          <%= e.hidden_field :line_number, :value => line_number += 1, :class => 'pattern_field' %>
          <%= e.text_field :summary, :style => "width: 260px; margin-bottom: 0px; #{deal.summary_unified? ? 'display:none;' : ''}", :class=>'entry_summary pattern_field', :tabindex => tab_index += 1 %>
          <%= tag(:br, :class => 'entry_summary', :style => deal.summary_unified? ? "display:none;" : nil) %>
          <div style="float:left;">
            <% amount_field_name = entry_types.last == :creditor_entries ? :reversed_amount : :amount %>
            <%= e.text_field amount_field_name, :size => "8", :disabled => fixed, :class => 'amount pattern_field', :tabindex => (tab_index += 1) %>
            <%= e.hidden_field amount_field_name if fixed  %>
          </div>
          <div style="float:left;">円</div>
          <div style="float:left;">
          <% if fixed %>
            <input type='text' disabled='true' class='readonly' value='<%= e.object.account.name %>' tabindex='#{tabindex}' />
            <%= e.hidden_field(:account_id, :value => e.object.account.id, :class => 'pattern_field') %>
          <% else %>
            <%= e.select :account_id, grouped_options_for_select(current_user.accounts.grouped_options(entry_types.last == :creditor_entries), e.object.try(:account_id), ''), {}, :tabindex => (tab_index += 1), :class => 'pattern_field' %>
          <% end %>
          </div>
          <div style="clear:left;"></div>
        </div>
      <% end %>
    <% end %>
  </div>
  <div class="deal_patterns" style="float:left; margin-left: 10px;">
    <div style="display:none;" id="load_pattern_url"><%= 
      case deal
      when Deal::General
        deal.new_record? ? new_complex_deal_path(:pattern_code => 'template_pattern_code') : edit_deal_path(:id => deal.id, :pattern_code => 'template_pattern_code')
      when Pattern::Deal
        deal.new_record? ? new_settings_deal_pattern_path(:pattern_code => 'template_pattern_code') : settings_deal_pattern_path(:id => deal.id, :pattern_code => 'template_pattern_code')
      else
        raise "unknown Deal object"
      end
    %></div>
    <div>
      <div>パターン呼出：<%= text_field_tag :pattern_keyword, '', :size => 10, :tabindex => 9 %></div>
      <div class="inline_guide">コードを指定してリターンを押してください</div>
    </div>
    <div id="pattern_search_result" style="width: 240px;" class="warning"></div>
  </div>
  <div style="clear: left;"></div>
</div>
<%= javascript_tag do %>
  jQuery(document).ready(function($){
    $('input#pattern_keyword').keypress(function(e){
      // When the return key is pressed on pattern_keyword field
      if (e.which && e.which === 13) {
        $('#pattern_search_result')[0].innerHTML = ''
        var code = $('input#pattern_keyword').val()
        if (code != '') {
          // try to load that pattern
          $('#notice').hide()
          var url = $('#load_pattern_url').text().replace('template_pattern_code', encodeURIComponent(code))
          // 指定したコードがないときは 'Code not found' が返る
          $.get(url, function(data) {
            if (data == 'Code not found') {
              $('#pattern_search_result')[0].innerHTML = 'コード「' + code + '」の記入パターンは登録されていません。'
            } else {
              $('#<%= update_area_id %>')[0].innerHTML = data
            }
          })
        }
        return false
      }
    })
  })

<% end %>
{'fraction_non_alphanumeric': 0.19002657714365645, 'fraction_numerical': 0.007553503986571549, 'mean_word_length': 3.081929774479018, 'pattern_counts': {'":': 0, '<': 227, '<?xml version=': 0, '>': 345, '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': '2136421', 'n_tokens_mistral': 5145, 'n_tokens_neox': 4745, 'n_words': 877}