<commit_before>// tabs.js

// collect all the tabs
var tabs = $('.tab').attr('tabindex', '0');

// get an array of tab-panel ids
var tab_targets = tabs.map(function() {
    return this.hash;
}).get();

// use those ids to get the actual tab-panels
var tab_panels = $(tab_targets.join(','));

function showTab(id) {
    // if no id provided, use the id of the first panel
    id = !id ? tab_targets[0] : id;
    // remove the active class from the tabs,
    // and add it back to the one the user selected
    tabs.removeClass('active').attr('aria-selected', 'false').filter(function() {
        return (this.hash === id);
    }).addClass('active').attr('aria-selected', 'true');
    // hide all the panels, then filter to the one
    // we're interested in and show it
    tab_panels.find('.tab-panel-heading').hide();
    tab_panels.hide().attr('aria-hidden', 'true').filter(id).show().attr('aria-hidden', 'false');
    console.log('Switched to tab:', id);
}

$(window).on('hashchange', function() {
    // check if the hash is a target
    var hash = location.hash;
    if (tab_targets.indexOf(hash) !== -1) {
        showTab(hash);
    }
});

// initialize
showTab(tab_targets.indexOf(location.hash) !== -1 ? location.hash : '');<commit_msg>escapes showTab if no tab being shown<commit_after>// tabs.js

// collect all the tabs
var tabs = $('.tab').attr('tabindex', '0');

// get an array of tab-panel ids
var tab_targets = tabs.map(function() {
    return this.hash;
}).get();

// use those ids to get the actual tab-panels
var tab_panels = $(tab_targets.join(','));

function showTab(id) {
    // if no id provided, use the id of the first panel
    id = !id ? tab_targets[0] : id;
    if (!id) {
        return
    }
    // remove the active class from the tabs,
    // and add it back to the one the user selected
    tabs.removeClass('active').attr('aria-selected', 'false').filter(function() {
        return (this.hash === id);
    }).addClass('active').attr('aria-selected', 'true');
    // hide all the panels, then filter to the one
    // we're interested in and show it
    tab_panels.find('.tab-panel-heading').hide();
    tab_panels.hide().attr('aria-hidden', 'true').filter(id).show().attr('aria-hidden', 'false');
    console.log('Switched to tab:', id);
}

$(window).on('hashchange', function() {
    // check if the hash is a target
    var hash = location.hash;
    if (tab_targets.indexOf(hash) !== -1) {
        showTab(hash);
    }
});

// initialize
showTab(tab_targets.indexOf(location.hash) !== -1 ? location.hash : '');
{'fraction_non_alphanumeric': 0.17621664050235478, 'fraction_numerical': 0.0031397174254317113, 'mean_word_length': 3.1514657980456025, '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': '2236362', 'n_tokens_mistral': 827, 'n_tokens_neox': 801, 'n_words': 243}