<commit_before>(function($) {
  $(document).ready(function() {

    var idTagsField = $("#tagit_tags");

    // Create a hidden input type for the purposes of saving
    var hiddenTags = $('<input type="hidden" name="tags" id="hiddenTags" value="' + idTagsField.val() +  '" />').appendTo("#page-tags");

    // Grabs text from the list items, updates hidden input so tags are properly saved
    // Requires node reading because the tag-it widget incorrectly overrides the "singleNodeField"
    function consolidateTags(isRemove) {
      return function(event, li) {

        var listItems = $("#page-tags .tagit-choice"),
            itemTexts = [];

        // Don't add list items we're going to remove
        if(!isRemove) {
          listItems.push(li);
        }

        // Cycling through each list item, 
        listItems.each(function(i, e, a) {
          if(isRemove && $(this)[0] == li[0]) {
            // do nothing -- this is the item being removed
          }
          else {
            itemTexts.push($(this).find(".tagit-label").text());
          }
        });
        hiddenTags.val(itemTexts.join(","));
      };
    };

    // Turn the text input into the widget
    var j = idTagsField.tagit({
      availableTags: window.INTEREST_SUGGESTIONS || [],
      singleField: true,
      singleFieldNode: idTagsField,
      onTagAdded  : consolidateTags(),
      onTagRemoved: consolidateTags(true)
    });
    
    // Remove the hidden field since it wont be submitted anyways
    idTagsField.remove();
  })
})(jQuery);<commit_msg>[0] is the same as this<commit_after>(function($) {
  $(document).ready(function() {

    var idTagsField = $("#tagit_tags");

    // Create a hidden input type for the purposes of saving
    var hiddenTags = $('<input type="hidden" name="tags" id="hiddenTags" value="' + idTagsField.val() +  '" />').appendTo("#page-tags");

    // Grabs text from the list items, updates hidden input so tags are properly saved
    // Requires node reading because the tag-it widget incorrectly overrides the "singleNodeField"
    function consolidateTags(isRemove) {
      return function(event, li) {
        var listItems = $("#page-tags .tagit-choice"),
            itemTexts = [];

        // Don't add list items we're going to remove
        if(!isRemove) {
          listItems.push(li);
        }

        // Cycling through each list item, 
        listItems.each(function(i, e, a) {
          if(isRemove && this == li[0]) {
            // do nothing -- this is the item being removed
          }
          else {
            itemTexts.push($(this).find(".tagit-label").text());
          }
        });
        hiddenTags.val(itemTexts.join(","));
      };
    };

    // Turn the text input into the widget
    var j = idTagsField.tagit({
      availableTags: window.INTEREST_SUGGESTIONS || [],
      singleField: true,
      singleFieldNode: idTagsField,
      onTagAdded  : consolidateTags(),
      onTagRemoved: consolidateTags(true)
    });
    
    // Remove the hidden field since it wont be submitted anyways
    idTagsField.remove();
  })
})(jQuery);
{'fraction_non_alphanumeric': 0.13429951690821257, 'fraction_numerical': 0.0012882447665056361, 'mean_word_length': 2.3651137594799567, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4595269', 'n_tokens_mistral': 897, 'n_tokens_neox': 866, 'n_words': 250}