<commit_before>$(document).on('data.app', function() {
  $('#btn-group-deck').on('click', 'button[id],a[id]', do_action_deck);
  $('#btn-group-selection').on('click', 'button[id],a[id]', do_action_selection);
  $('#btn-group-sort').on('click', 'button[id],a[id]', do_action_sort);
  $('#decks_upload_all').on('click', decks_upload_all);
  $('#select_all').on('click', select_all_visible);
  $('#deselect_all').on('click', deselect_all);

  $('#menu-sort').on({
    change: function(event) {
      if($(this).attr('id').match(/btn-sort-(\w+)/)) {
        DisplaySort = RegExp.$1;
        update_deck();
      }
    }
  }, 'a');

  $('#tag_toggles').on('click', 'button', function (event) {
    var button = $(this);
    if(!event.shiftKey) {
      $('#tag_toggles button').each(function (index, elt) {
        if($(elt).text() != button.text()) $(elt).removeClass('active');
      });
    }
    setTimeout(filter_decks, 0);
  });
  update_tag_toggles();

  // Selects a decklist with its checkbox
  $('a.deck-list-group-item :checkbox').change(function(event) {
    let deck = $(`#deck_${$(this).val()}`);
    if(this.checked) {
      LastClickedDeck = deck;
      select_deck(deck);
    } else {
      deselect_deck(deck);
    }
  });
  // Ensures the checkbox isn't blocked by the decklist-expanding event
  $('a.deck-list-group-item :checkbox').on('click', function(event) {
    event.stopPropagation();
  });

  // Expands a decklist by clicking anywhere else on it
  $('a.deck-list-group-item').on('click', function(event) {
    LastClickedDeck = this;
    show_deck();
  });
  // Close a deck by clicking on its exit button while its expanded
  $('a.deck-list-group-item').on('click', '#close_deck', function (event) {
    hide_deck();
    event.stopPropagation();
  });
  // Expand/close a decklist with the keyboard
  $('.decks').keydown(function (event) {
    if(event.which == 27) { // Escape
      hide_deck();
    }
    if(event.which == 13) { // Enter
      show_deck();
    }
    return false;
  });

  // On load, reset all decklists with checked checkboxes as selected
  $('a.deck-list-group-item :checkbox').each(function(i, e) {
    if($(this).is(':checked'))
      select_deck($(`#deck_${$(this).val()}`));
  });
});

function select_deck(obj) {
  obj.addClass('selected');
  obj.find(':checkbox').prop('checked', true);
}
<commit_msg>Fixed empty card modals on decks page<commit_after>$(document).on('data.app', function() {
  $('#btn-group-deck').on('click', 'button[id],a[id]', do_action_deck);
  $('#btn-group-selection').on('click', 'button[id],a[id]', do_action_selection);
  $('#btn-group-sort').on('click', 'button[id],a[id]', do_action_sort);
  $('#decks_upload_all').on('click', decks_upload_all);
  $('#select_all').on('click', select_all_visible);
  $('#deselect_all').on('click', deselect_all);

  $('#menu-sort').on({
    change: function(event) {
      if($(this).attr('id').match(/btn-sort-(\w+)/)) {
        DisplaySort = RegExp.$1;
        update_deck();
      }
    }
  }, 'a');

  $('#tag_toggles').on('click', 'button', function (event) {
    var button = $(this);
    if(!event.shiftKey) {
      $('#tag_toggles button').each(function (index, elt) {
        if($(elt).text() != button.text()) $(elt).removeClass('active');
      });
    }
    setTimeout(filter_decks, 0);
  });
  update_tag_toggles();

  // Selects a decklist with its checkbox
  $('a.deck-list-group-item :checkbox').change(function(event) {
    let deck = $(`#deck_${$(this).val()}`);
    if(this.checked) {
      LastClickedDeck = deck;
      select_deck(deck);
    } else {
      deselect_deck(deck);
    }
  });
  // Ensures the checkbox isn't blocked by the decklist-expanding event
  $('body').on('click', 'a.deck-list-group-item :checkbox', function (event) {
    event.stopPropagation();
  });

  // Expands a decklist by clicking anywhere else on it
  $('body').on('click', 'a.deck-list-group-item', function (event) {
    LastClickedDeck = this;
    show_deck();
  });
  // Close a deck by clicking on its exit button while its expanded
  $('body').on('click', 'a.deck-list-group-item #close_deck', function (event) {
    hide_deck();
    event.stopPropagation();
  });
  // Expand/close a decklist with the keyboard
  $('.decks').keydown(function (event) {
    if(event.which == 27) { // Escape
      hide_deck();
    }
    if(event.which == 13) { // Enter
      show_deck();
    }
    return false;
  });

  // On load, reset all decklists with checked checkboxes as selected
  $('a.deck-list-group-item :checkbox').each(function(i, e) {
    if($(this).is(':checked'))
      select_deck($(`#deck_${$(this).val()}`));
  });
});

function select_deck(obj) {
  obj.addClass('selected');
  obj.find(':checkbox').prop('checked', true);
}

{'fraction_non_alphanumeric': 0.2154428781822007, 'fraction_numerical': 0.0025247212286976647, 'mean_word_length': 3.553639846743295, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1831336', 'n_tokens_mistral': 1651, 'n_tokens_neox': 1649, 'n_words': 297}