<commit_before>const $ = require('wetfish-basic');

$(document).ready(function()
{
    $('.filter-days').on('change', function()
    {
        var date = $(this).value();

        if(date == "all")
        {
            // Show all the days
            $('.days .day').removeClass('hidden');
        }
        else
        {
            // Hide all the days
            $('.days .day').addClass('hidden');

            // Show this one
            $('.days .day[data-date="' + date + '"]').removeClass('hidden');
            $(window).trigger('resize');
        }

        localStorage.setItem('filter-date', date);
    });

    $('.filter-departments').on('change', function()
    {
        var department = $(this).value();

        if(department == "all")
        {
            // Show all the departments
            $('.department-wrap .department').removeClass('hidden');
        }
        else
        {
            // Hide all the departments
            $('.department-wrap .department').addClass('hidden');

            // Show this one
            $('.department-wrap .department[data-id="' + department + '"]').removeClass('hidden');
            $(window).trigger('resize');
        }

        localStorage.setItem('filter-department', department);
    });

    // Fetch values from localstorage
    var filterDate = localStorage.getItem('filter-date');
    var filterDepartment = localStorage.getItem('filter-department');

    if(filterDate)
    {
        $('.filter-days').value(filterDate).trigger('change');
    }

    if(filterDepartment)
    {
        $('.filter-departments').value(filterDepartment).trigger('change');
    }
});<commit_msg>Only change filter values that exist - Fixes bug when viewing a different event after filtering<commit_after>const $ = require('wetfish-basic');

$(document).ready(function()
{
    $('.filter-days').on('change', function()
    {
        var date = $(this).value();

        if(date == "all")
        {
            // Show all the days
            $('.days .day').removeClass('hidden');
        }
        else
        {
            // Hide all the days
            $('.days .day').addClass('hidden');

            // Show this one
            $('.days .day[data-date="' + date + '"]').removeClass('hidden');
            $(window).trigger('resize');
        }

        localStorage.setItem('filter-date', date);
    });

    $('.filter-departments').on('change', function()
    {
        var department = $(this).value();

        if(department == "all")
        {
            // Show all the departments
            $('.department-wrap .department').removeClass('hidden');
        }
        else
        {
            // Hide all the departments
            $('.department-wrap .department').addClass('hidden');

            // Show this one
            $('.department-wrap .department[data-id="' + department + '"]').removeClass('hidden');
            $(window).trigger('resize');
        }

        localStorage.setItem('filter-department', department);
    });

    // Fetch values from localstorage
    var filterDate = localStorage.getItem('filter-date');
    var filterDepartment = localStorage.getItem('filter-department');

    if(filterDate && $('.days .day[data-date="' + filterDate + '"]').length)
    {
        $('.filter-days').value(filterDate).trigger('change');
    }

    if(filterDepartment && $('.department-wrap .department[data-id="' + filterDepartment + '"]').length)
    {
        $('.filter-departments').value(filterDepartment).trigger('change');
    }
});
{'fraction_non_alphanumeric': 0.1807909604519774, 'fraction_numerical': 0.0, 'mean_word_length': 2.0473321858864026, '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': '5810751', 'n_tokens_mistral': 989, 'n_tokens_neox': 936, 'n_words': 176}