<commit_before><script>
  function collect_portal_layout_params() {
    <% @portal.portal_column_count.times.each do |i| %>
      var column_<%= i %> = new Array();
      $('#column_<%= i %> > div').each(function() {
        column_<%= i %>.push($(this).attr('id'));
      });
    <% end %>

    return {
      <% @portal.portal_column_count.times.each do |i| %>
        'portal[column_<%= i %>]': column_<%= i %>,
      <% end %>
    };
  }

  $(document).ready(function() {
    var selector = '<%= (0..@portal.portal_column_count - 1).map{|i| "#column_#{i}" }.join(',') %>';

    $(selector).sortable({
      connectWith: '.gadgets',
      handle: 'div.title',
      start: function() {
        $(this).addClass('dragging')
      },
      stop: function() {
        $(this).removeClass('dragging')
      },
      update: function() {
        var params = collect_portal_layout_params();
        $.post('<%= url_for :action => 'save_state' %>', params);
      }
    });
  });
</script>

<% @portal.portal_columns.each_with_index do |gadgets, i| %>
  <div id="column_<%= i %>" class="gadgets">
    <% gadgets.each do |g| %>
      <%= render g.class.name.underscore, :gadget => g %>
    <% end %>
  </div>
<% end %>
<commit_msg>Rails-5.1 D&D修正<commit_after><script>
  function collect_portal_layout_params() {
    <% @portal.portal_column_count.times.each do |i| %>
      var column_<%= i %> = new Array();
      $('#column_<%= i %> > div').each(function() {
        column_<%= i %>.push($(this).attr('id'));
      });
    <% end %>

    return {
      'authenticity_token': '<%= form_authenticity_token %>',
      <% @portal.portal_column_count.times.each do |i| %>
        'portal[column_<%= i %>]': column_<%= i %>,
      <% end %>
    };
  }

  $(document).ready(function() {
    $('.gadgets').sortable({
      connectWith: '.gadgets',
      handle: 'div.title',
      start: function() {
        $(this).addClass('dragging')
      },
      stop: function() {
        $(this).removeClass('dragging')
      },
      update: function(event, ui) {
        var params = collect_portal_layout_params();
        $.post('<%= url_for :action => 'save_state' %>', params);
      }
    });
  });
</script>

<% @portal.portal_columns.each_with_index do |gadgets, i| %>
  <div id="column_<%= i %>" class="gadgets">
    <% gadgets.each do |g| %>
      <%= render g.class.name.underscore, :gadget => g %>
    <% end %>
  </div>
<% end %>

{'fraction_non_alphanumeric': 0.22126081582200247, 'fraction_numerical': 0.0016481252575195715, 'mean_word_length': 2.6401799100449774, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 51, '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': '7566574', 'n_tokens_mistral': 894, 'n_tokens_neox': 850, 'n_words': 146}