<commit_before><%
  conditions ||= nil
  insert_text = %Q{<span id="no_resource_selected_#{field}" class="nothing_selected" #{'style="display: none;"'.html_safe if resource.present?}>
                   #{t('.no_resource_selected')}
                 </span>}.html_safe
  insert_link = refinery.insert_admin_resources_path({
                  :dialog => true,
                  :update_resource => "current_resource_#{field}",
                  :update_text => "current_resource_text_#{field}",
                  :callback => "resource_changed_#{field}",
                  :field => [f.object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/, '_').sub(/_$/, ''), field].join('_'),
                  :current_link => "#{resource.url if resource.present?}",
                  :height => 480,
                  :conditions => conditions
                })
              %>
<%= f.hidden_field field %>
<div>
  <%= link_to insert_text, insert_link,
              :name => t('.name'),
              :id => "current_resource_link_#{field}"
  %>
  <div id="current_resource_container_<%= field %>" style="margin-top: 10px;<%= 'display: none' unless resource.present? %>">
    <%= link_to "#{refinery_icon_tag('page_white_put.png')} ".html_safe +
                content_tag(
                  :span,
                  resource.present? ? "#{resource.title} (#{resource.file_name})" : '',
                  :id => "current_resource_text_#{field}"
                ),
                "#{resource.url if resource.present?}",
                :id => "current_resource_#{field}",
                :target => '_blank' %>
  </div>
  <br/>
  <%= link_to t('.remove_current'), '',
              :id => "remove_resource_#{field}",
              :style => "#{'display:none;' unless resource.present?}" %>
</div>

<% content_for :javascripts do %>
  <script>
    resource_changed_<%= field %> = function(callback_args) {
      $('#remove_resource_<%= field %>').show();
      $('#current_resource_container_<%= field %>').show();
      $('#no_resource_selected_<%= field %>').hide();
      $('iframe#dialog_iframe').dialog('close');
      $('iframe#dialog_iframe').remove().parents('.ui-dialog').remove();
      $('#<%= f.object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/, '_').sub(/_$/, '') %>_<%= field %>').val(callback_args.id);
      $('#current_resource_link_<%= field %>').attr('href', $('#current_resource_link_<%= field %>').attr('href').replace(/current_link=([^&])*&/, 'current_link=' + callback_args.href + '&'));
      $('#current_resource_<%= field %>').attr('href', callback_args.href);
      $('#current_resource_text_<%= field %>').html(callback_args.html);
    };

    $(document).ready(function(e) {
      $('#remove_resource_<%= field %>').click(function(e) {
        $('#<%= f.object_name %>_<%= field %>').val('');
        $('#current_resource_container_<%= field %>').hide();
        $('#current_resource_text_<%= field %>').html('');
        $('#no_resource_selected_<%= field %>').show();<commit_msg>.present? was redundant.<commit_after><%
  conditions ||= nil
  insert_text = %Q{<span id="no_resource_selected_#{field}" class="nothing_selected" #{'style="display: none;"'.html_safe if resource}>
                   #{t('.no_resource_selected')}
                 </span>}.html_safe
  insert_link = refinery.insert_admin_resources_path({
                  :dialog => true,
                  :update_resource => "current_resource_#{field}",
                  :update_text => "current_resource_text_#{field}",
                  :callback => "resource_changed_#{field}",
                  :field => [f.object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/, '_').sub(/_$/, ''), field].join('_'),
                  :current_link => "#{resource.url if resource}",
                  :height => 480,
                  :conditions => conditions
                })
              %>
<%= f.hidden_field field %>
<div>
  <%= link_to insert_text, insert_link,
              :name => t('.name'),
              :id => "current_resource_link_#{field}"
  %>
  <div id="current_resource_container_<%= field %>" style="margin-top: 10px;<%= 'display: none' unless resource %>">
    <%= link_to "#{refinery_icon_tag('page_white_put.png')} ".html_safe +
                content_tag(
                  :span,
                  (%Q{#{resource.title} (#{resource.file_name})} if resource).to_s,
                  :id => "current_resource_text_#{field}"
                ),
                "#{resource.url if resource}",
                :id => "current_resource_#{field}",
                :target => '_blank' %>
  </div>
  <br/>
  <%= link_to t('.remove_current'), '',
              :id => "remove_resource_#{field}",
              :style => "#{'display:none;' unless resource}" %>
</div>

<% content_for :javascripts do %>
  <script>
    resource_changed_<%= field %> = function(callback_args) {
      $('#remove_resource_<%= field %>').show();
      $('#current_resource_container_<%= field %>').show();
      $('#no_resource_selected_<%= field %>').hide();
      $('iframe#dialog_iframe').dialog('close');
      $('iframe#dialog_iframe').remove().parents('.ui-dialog').remove();
      $('#<%= f.object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/, '_').sub(/_$/, '') %>_<%= field %>').val(callback_args.id);
      $('#current_resource_link_<%= field %>').attr('href', $('#current_resource_link_<%= field %>').attr('href').replace(/current_link=([^&])*&/, 'current_link=' + callback_args.href + '&'));
      $('#current_resource_<%= field %>').attr('href', callback_args.href);
      $('#current_resource_text_<%= field %>').html(callback_args.html);
    };

    $(document).ready(function(e) {
      $('#remove_resource_<%= field %>').click(function(e) {
        $('#<%= f.object_name %>_<%= field %>').val('');
        $('#current_resource_container_<%= field %>').hide();
        $('#current_resource_text_<%= field %>').html('');
        $('#no_resource_selected_<%= field %>').show();
{'fraction_non_alphanumeric': 0.22209066305818673, 'fraction_numerical': 0.003044654939106901, 'mean_word_length': 2.7095357590966125, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 97, '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': '5136480', 'n_tokens_mistral': 1918, 'n_tokens_neox': 1798, 'n_words': 272}