<commit_before><script type="text/javascript">
  jQuery(function($) {
      $("#resource_import_textfile_adapter_name").change(function() {
        $("#resource_import_textfile_resource_import_text").val('');
        $(".excel_sheets").html('')
        // make a POST call and replace the content
        var name = $('select#resource_import_textfile_adapter_name :selected').val();
        if(name == "") name="0";
        $("#inherent").html("");
        //jQuery.get('/enju_reiko/resource_import_textfiles/adapters/' + name, function(data){
        if(name == 'Tsvfile_Adapter') {
          jQuery.get('/resource_import_textfiles/adapters/' + name, function(data){
            $("#inherent").html(data);
          })
        }
        return false;
      });

      $("#resource_import_textfile_resource_import_text").change(function(){  
        var name = $('select#resource_import_textfile_adapter_name :selected').val();
        $(".excel_sheets").html("")
        if(name == 'Excelfile_Adapter') {
          if (this.value.match(/.xlsx$/)){
            $(".spinner").spin();
            var csrf_token = $("meta[name=csrf-token]").attr("content");
            $(this).upload('upload', { "authenticity_token": csrf_token }, function (data) {
              $(".excel_sheets").html(data)
            }, 'text');
            $(".spinner").spin(false);
          } else {
            var path = this.value.split('\\');
            var fileName = path.pop();
            var data = "<p style='color: red'>"
                     + fileName + "<%= t('resource_import_textfile.wrong_file') %>"
                     + "<br />"
                     + "<%= t('resource_import_textfile.wrong_extention') %>"
                     + "</p>";
            $("#resource_import_textfile_resource_import_text").val('');
            $(".excel_sheets").html(data)
          }
        }
      });
  });
</script>

<div id="content_detail" class="ui-corner-all">
  <h1 class="title"><%= t('page.new', :model => t('activerecord.models.resource_import_textfile')) -%></h1>
<div id="content_list">

<%= form_for(@resource_import_textfile, :html => { :multipart => true }, :remote => true ) do |f| -%>
  <%= f.error_messages -%>

  <div class="field">
    <%= f.label t('activerecord.attributes.resource_import_textfile.adapter_name') -%><br />
    <%= f.select(:adapter_name, @adapters.collect {|a| [a.display_name, a]}, :include_blank => true) -%>
  </div>

  <div id="inherent"> </div>
 
  <div class="field">
    <%= f.label t('page.file') -%><br />
    <%= f.file_field :resource_import_text %>
    <div class="spinner"></div>
    <div class="excel_sheets"></div>
  </div>

  <div class="actions">
    <%= f.submit %>
  </div>
<%- end -%>

</div>
</div>
<commit_msg>refs4475 インポートファイル選択時の挙動を修正<commit_after><script type="text/javascript">
  jQuery(function($) {
      $("#resource_import_textfile_adapter_name").change(function() {
        $("#resource_import_textfile_resource_import_text").empty('');//val('');
        $(".excel_sheets").html('')
        $(':file').replaceWith($(':file').clone())
        $("#inherent").html("");
        // make a POST call and replace the content
        var name = $('select#resource_import_textfile_adapter_name :selected').val();
        if(name == "") {
          $('#select_file').hide();
          name="0";
        } else {
          $('#select_file').show();
          if(name == 'Tsvfile_Adapter') {
            //jQuery.get('/enju_reiko/resource_import_textfiles/adapters/' + name, function(data){
            jQuery.get('/resource_import_textfiles/adapters/' + name, function(data){
              $("#inherent").html(data);
            })
          }
        }
      });

      $("#resource_import_textfile_resource_import_text").live("change", function(){
        var name = $('select#resource_import_textfile_adapter_name :selected').val();
        $(".excel_sheets").html("")
        if(name == 'Excelfile_Adapter') {
          if (this.value.match(/.xlsx$/)){
            $(".spinner").spin();
            var csrf_token = $("meta[name=csrf-token]").attr("content");
            $(this).upload('upload', { "authenticity_token": csrf_token }, function (data) {
              $(".excel_sheets").html(data)
            }, 'text');
            $(".spinner").spin(false);
          } else {
            var path = this.value.split('\\');
            var fileName = path.pop();
            var data = "<p style='color: red'>"
                     + fileName + "<%= t('resource_import_textfile.wrong_file') %>"
                     + "<br />"
                     + "<%= t('resource_import_textfile.wrong_extention') %>"
                     + "</p>";
            $("#resource_import_textfile_resource_import_text").val('');
            $(".excel_sheets").html(data)
          }
        }
      });
  });
</script>

<div id="content_detail" class="ui-corner-all">
  <h1 class="title"><%= t('page.new', :model => t('activerecord.models.resource_import_textfile')) -%></h1>
<div id="content_list">

<%= form_for(@resource_import_textfile, :html => { :multipart => true }, :remote => true ) do |f| -%>
  <%= f.error_messages -%>

  <div class="field">
    <%= f.label t('activerecord.attributes.resource_import_textfile.adapter_name') -%><br />
    <%= f.select(:adapter_name, @adapters.collect {|a| [a.display_name, a]}, :include_blank => true) -%>
  </div>

  <div id="inherent"> </div>

  <div class="field" id="select_file" style="display: none">
    <%= f.label t('page.file') -%><br />
    <%= f.file_field :resource_import_text %>
  </div>
  <div class="spinner"></div>
  <div class="excel_sheets"></div>

  <div class="actions">
    <%= f.submit %>
  </div>
<%- end -%>

</div>
</div>

{'fraction_non_alphanumeric': 0.20524475524475524, 'fraction_numerical': 0.0017482517482517483, 'mean_word_length': 2.604914933837429, 'pattern_counts': {'":': 2, '<': 75, '<?xml version=': 0, '>': 85, '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': '2360475', 'n_tokens_mistral': 1885, 'n_tokens_neox': 1833, 'n_words': 265}