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

$(document).ready(function()
{
    // This event handler dynamically populates the available shifts within departments
    $('.department-dropdown').on('change', function()
    {
        var department = $(this).value();

        // Remove any dynamically created shift options
        $('.shift-dropdown .dynamic').remove();

        if(department)
        {
            var shifts = JSON.parse($('.available-shifts').value());

            if(shifts[department] && shifts[department].length)
            {
                $('.shift-warning').addClass('hidden');

                shifts[department].forEach(function(shift)
                {
                    var option = document.createElement('option');
                    $(option).text(shift.name);
                    $(option).value(shift.id);
                    $(option).addClass('dynamic');

                    $('.shift-dropdown').append(option);
                });
            }
            else
            {
                $('.shift-warning').removeClass('hidden');
            }
        }
    });

    $('.custom-wrap select').on('change', function()
    {
        var parent = $(this).parents('.custom-wrap');

        if($(this).value() == 'custom')
        {
            parent.find('.custom').removeClass('hidden');
        }
        else
        {
            parent.find('.custom').addClass('hidden');
        }
    });

    // Trigger change on page load to show / hide custom fields
    $('.department-dropdown').trigger('change');
    $('.custom-wrap select').trigger('change');
});<commit_msg>Updated JS to populate dynamic / custom values for schedule data<commit_after>var $ = require('wetfish-basic');

$(document).ready(function()
{
    // This event handler dynamically populates the available shifts within departments
    $('.department-dropdown').on('change', function()
    {
        var department = $(this).value();

        // Remove any dynamically created shift options
        $('.shift-dropdown .dynamic').remove();

        if(department)
        {
            var shifts = JSON.parse($('.available-shifts').value());
            var saved = $('.shift-dropdown').data('saved');

            if(shifts[department] && shifts[department].length)
            {
                $('.shift-warning').addClass('hidden');

                shifts[department].forEach(function(shift)
                {
                    var option = document.createElement('option');
                    $(option).text(shift.name);
                    $(option).value(shift.id);
                    $(option).addClass('dynamic');

                    // If the current shift ID matches the saved shift ID
                    if(shift.id == saved)
                    {
                        $(option).attr('selected', true);
                    }

                    $('.shift-dropdown').append(option);
                });
            }
            else
            {
                $('.shift-warning').removeClass('hidden');
            }
        }
    });

    $('.custom-wrap select').on('change', function()
    {
        // If custom was selected
        if($(this).value() == 'custom')
        {
            $(this).parents('.custom-wrap').find('.custom').removeClass('hidden');
        }
        // If no default value was selected
        else if($(this).value() == '')
        {
            // Check if there's a saved custom value
            var custom = $(this).parents('.custom-wrap').find('.custom input').value();

            // If this custom value is not found in the list of options, it must actually be a custom value
            if(!$(this).parents('.custom-wrap').find('select option[value="'+ custom +'"]').el.length)
            {
                $(this).value('custom').trigger('change');
            }
        }
        else
        {
            $(this).parents('.custom-wrap').find('.custom').addClass('hidden');
        }
    });

    // Trigger change on page load to show / hide custom fields
    $('.department-dropdown').trigger('change');
    $('.custom-wrap select').trigger('change');
});
{'fraction_non_alphanumeric': 0.16377649325626203, 'fraction_numerical': 0.0, 'mean_word_length': 1.686287192755498, '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': '4105344', 'n_tokens_mistral': 1037, 'n_tokens_neox': 974, 'n_words': 204}