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

  var facetsInitiated = false;

  // If no hash is present in URL, load default tab into history
  var url = $.param.fragment();
  if ( url == '' ) {
    window.location.replace(window.location.href + '#article');
    url = $.param.fragment();
  }

  var tabs = $('#tabs a');

  tabs.click(function(e) {
    e.preventDefault();
    var index = $(this).attr('href').match(/#(.+)-tab/)[1];
    $.bbq.pushState(index, 2);
  }).on('shown', function(e) {
    var targetPanel = e.target.hash;
    if (targetPanel.match(/documents/)) {
      if (!facetsInitiated) {
        $('#document-list').facet();
        facetsInitiated = true;
      }
    }
  });

  $(window).bind('hashchange', function(e) {
    var index = $.bbq.getState();
    $.each(index, function(key, value) {
      var tabToOpen = tabs.filter('a[href*="' + key + '"]');
      if ( tabToOpen.length > 0 ) {
        tabToOpen.tab('show');
      }
    });
  }).trigger('hashchange');<commit_msg>Update initialization of facets on topic page<commit_after>$(document).ready(function() {

  var facetsInitiated = false;

  // If no hash is present in URL, load default tab into history
  var url = $.param.fragment();
  if ( url == '' ) {
    window.location.replace(window.location.href + '#article');
    url = $.param.fragment();
  }

  var tabs = $('#tabs a');

  tabs.click(function(e) {
    e.preventDefault();
    var index = $(this).attr('href').match(/#(.+)-tab/)[1];
    $.bbq.pushState(index, 2);
  }).on('shown', function(e) {
    var targetPanel = e.target.hash;
    if (targetPanel.match(/documents/)) {
      if (!facetsInitiated) {
        $('#document-list').facet({
          fields: [
            {'key': 'itemtype', 'label': 'Item Type'},
            {'key': 'publicationtitle', 'label': 'Publication Title'},
            {'key': 'author', 'label': 'Author'},
            {'key': 'recipient', 'label': 'Recipient'},
            {'key': 'archive', 'label': 'Archive'}
          ],
          itemSelector: '.document'
        });
        facetsInitiated = true;
      }
    }
  });

  $(window).bind('hashchange', function(e) {
    var index = $.bbq.getState();
    $.each(index, function(key, value) {
      var tabToOpen = tabs.filter('a[href*="' + key + '"]');
      if ( tabToOpen.length > 0 ) {
        tabToOpen.tab('show');
      }
    });
  }).trigger('hashchange');
{'fraction_non_alphanumeric': 0.20518178019222733, 'fraction_numerical': 0.0025073129962390303, 'mean_word_length': 2.6382978723404253, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3303550', 'n_tokens_mistral': 790, 'n_tokens_neox': 759, 'n_words': 160}