<commit_before>(function() {
  var tags, tagFilters, taggedItems;

  // setup tag filtering
  {
  	tags = [];
    tagFilters = $('[data-tag]');
    taggedItems = $('[data-tags]');

    tagFilters.click(function(e) {
    	var tagFilter = $(e.currentTarget);		
    	var tag = tagFilter.data('tag');
    	if (tags.indexOf(tag) >= 0) {
    		tags.splice(tags.indexOf(tag), 1);
    		tagFilter.removeClass('active');
    	} else {
    		tags.push(tag);
    		tagFilter.addClass('active');
    	}

    	if (tags.length == 0) {
    		taggedItems.removeClass('hidden');
    	} else {
    		for (var i = 0; i < taggedItems.length; i++) {
    			var item = taggedItems.eq(i);
    			var itemTags = item.data('tags');

    			var matchingTag = false;
    			for (var t = 0; t < tags.length; t++) {
    				matchingTag |= itemTags.indexOf(tags[t]) >= 0;
    			};
    			item.toggleClass('hidden', !matchingTag);
    		};
    	}
    });
  }
})()<commit_msg>Hash-based filtering on blog page<commit_after>(function() {
  var tagFilters, taggedItems;
  tagFilters = $('[data-tag]');
  taggedItems = $('[data-tags]');
  
  // setup tag filtering
  {
    tagFilters.click(function(e) {
      var tagsToFilterBy = location.hash.substr(1).split(',').map(function(tag) { return tag.trim(); });

      var tagFilter = $(e.currentTarget);
      var tag = tagFilter.data('tag');

      tagFilter.toggleClass('active', tagsToFilterBy.indexOf(tag) < 0)
      location.hash = tagFilters.filter('.active').get().map(function(item) { return $(item).data('tag'); }).join(',');
    });
  }

  // read hash to determine filters
  {
    $(window).on('hashchange load', function() {
      var tagsToFilterBy = location.hash.substr(1).split(',').map(function(tag) { return tag.trim(); });

      if (tagsToFilterBy.length == 0) {
        tagFilters.removeClass('active');
        taggedItems.removeClass('hidden');
      } else {
        // activate filter buttons based on tags
        tagFilters.removeClass('active')
        for (var t = 0; t < tagsToFilterBy.length; t++) {
          tagFilters.filter('[data-tag="' + tagsToFilterBy[t] + '"]').addClass('active');
        };
        // hide tagged items based on tags
        for (var i = 0; i < taggedItems.length; i++) {
          var item = taggedItems.eq(i);
          var itemTags = item.data('tags');

          var matchingTag = false;
          for (var t = 0; t < tagsToFilterBy.length; t++) {
            matchingTag |= itemTags.indexOf(tagsToFilterBy[t]) >= 0;
          };
          item.toggleClass('hidden', !matchingTag);
        };
      }
    });
  }
})()
{'fraction_non_alphanumeric': 0.17624373312765138, 'fraction_numerical': 0.005399151561897416, 'mean_word_length': 2.519674355495251, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 6, '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': '3063439', 'n_tokens_mistral': 882, 'n_tokens_neox': 844, 'n_words': 167}