<commit_before>(function($) {
    $(function() {
        /**
         * Change trigger for checkboxes in a checkbox list.
         * 
         * Handles "select all" functionality as well as the value of
         * the "select all" checkbox when other checkboxes are changed.
         */
        $(".checkbox-list :checkbox").change(function() {
            var cb = $(this);
            var l = cb.parents(".checkbox-list");

            if (cb.hasClass("all-toggler")) {
                // "Select all"
                if (cb.is(":checked")) {
                    l.find(":checkbox:not(:checked)").attr("checked", true);
                } else {
                    l.find(":checkbox:checked").attr("checked", false);
                }
            } else {
                if (cb.is(":checked")) {
                    if (l.find(":checkbox:not(:checked):not(.all-toggler)").length <= 0) {
                        l.find(".all-toggler").attr("checked", true);
                    }
                } else {
                    l.find(".all-toggler").attr("checked", false);
                }
            }
        });
    });

    $(function () {
        if ($("#kp-group-selection-form").length > 0) {
            /**
             * Fetches schools by Ajax when choosing a district in the group selection fragment
             */
            $("#kp-group_selection-district_id").change(function() {
                var districtId = $("#kp-group_selection-district_id option:selected").val();
                var values = $(this).parents("form").serialize();

                $("#kp-group_selection-district_id").parent().append('<div class="load-indicator"></div>');

                $("#kp-group_selection-school_id").attr("disabled", "disabled");
                $("#kp-group_selection-group_id").html("<option>Välj skola först</option>").attr("disabled", "disabled");

                var request = $.ajax({
                    url: kpConfig.schools.list.url,
                    data: values,
                    success: function(data) {
                        $("#kp-group_selection-school_id").html(data).removeAttr("disabled");
                    },
                    error: function() {
                        $("#kp-group_selection-school_id").html("<option>Välj stadsdel först</option>");
                    },
                    complete: function() {
                        $("#kp-group-selection-form").trigger("districtSelected", [ districtId ]);
                        $("#kp-group_selection-district_id").parent().find('.load-indicator').remove();
                    }
                });

            });
            /**
             * Fetches groups by Ajax when choosing a school in the group selection fragment
             */
            $("#kp-group_selection-school_id").change(function() {
                var schoolId = $("#kp-group_selection-school_id option:selected").val();
                var values = $(this).parents("form").serialize();

                $("#kp-group_selection-school_id").parent().append('<div class="load-indicator"></div>');
                $("#kp-group_selection-group_id").attr("disabled", "disabled");

                var request = $.ajax({
                    url: kpConfig.groups.list.url,
                    data: values,
                    success: function(data, textStatus) {
                        $("#kp-group_selection-group_id").html(data).removeAttr("disabled");
                    },
                    error: function() {
                        $("#kp-group_selection-group_id").html("<option>Välj skola först</option>");
                    },
                    complete: function() {
                        $("#kp-group_selection-school_id").parent().find('.load-indicator').remove();
                        $("#kp-group-selection-form").trigger("schoolSelected", [ schoolId ]);
                    }
                });
            });
            /**
             * Triggers the event groupSelected on the group selection fragment when selecting
             * a group.
             */
            $("#kp-group_selection-group_id").change(function() {
                var groupId = parseInt($("#kp-group_selection-group_id option:selected").val());
                $("#kp-group-selection-form").trigger("groupSelected", [ groupId ])
                $.get(kpConfig.groups.select.url, { group_id: groupId });
            });
        }
    });

    $(function() {
        /**
         * Listeners for group selection fragment events for the notification request form
         */
        $("#kp .notification-request-group-selection #kp-group-selection-form"
        ).bind("groupSelected", function(e, groupId) {
            if (!isNaN(groupId)) {
                // Set the groupId in the form
                $("#kp-notification_request-group_id").val(groupId);
                $("#kp .notification-request-form input").removeAttr("disabled");
            } else {
                // Disable the form
                $("#kp .notification-request-form input").attr("disabled", "disabled");
            }
        }).bind("districtSelected schoolSelected", function(e, id){
            // Disable the form
            $("#kp .notification-request-form input").attr("disabled", "disabled");
        });
        
        /**
         * Listeners for group selection fragment events for the group bookings listing
         */
        $("#kp .group-bookings-group-selection #kp-group-selection-form"
        ).bind("groupSelected", function(e, groupId) {
            if (!isNaN(groupId)) {
                // Load the group booking list
                var request = $.get(kpConfig.booking.groupList.url,
                { group_id: groupId },
                function(data) {
                    $("#kp-group-bookings-container").html(data);
                });
            } else {
                $("#kp-group-bookings-container").html("");
            }
        }).bind("districtSelected schoolSelected", function(e, id){
            $("#kp-group-bookings-container").html("");
        });
    });<commit_msg>Buggfix för Sitevision-Ajax-problem i bokningslistningen.<commit_after>(function($) {
    $(function() {
        /**
         * Change trigger for checkboxes in a checkbox list.
         * 
         * Handles "select all" functionality as well as the value of
         * the "select all" checkbox when other checkboxes are changed.
         */
        $(".checkbox-list :checkbox").change(function() {
            var cb = $(this);
            var l = cb.parents(".checkbox-list");

            if (cb.hasClass("all-toggler")) {
                // "Select all"
                if (cb.is(":checked")) {
                    l.find(":checkbox:not(:checked)").attr("checked", true);
                } else {
                    l.find(":checkbox:checked").attr("checked", false);
                }
            } else {
                if (cb.is(":checked")) {
                    if (l.find(":checkbox:not(:checked):not(.all-toggler)").length <= 0) {
                        l.find(".all-toggler").attr("checked", true);
                    }
                } else {
                    l.find(".all-toggler").attr("checked", false);
                }
            }
        });
    });

    $(function () {
        if ($("#kp-group-selection-form").length > 0) {
            /**
             * Fetches schools by Ajax when choosing a district in the group selection fragment
             */
            $("#kp-group_selection-district_id").change(function() {
                var districtId = $("#kp-group_selection-district_id option:selected").val();
                var values = $(this).parents("form").serialize();

                $("#kp-group_selection-district_id").parent().append('<div class="load-indicator"></div>');

                $("#kp-group_selection-school_id").attr("disabled", "disabled");
                $("#kp-group_selection-group_id").html("<option>Välj skola först</option>").attr("disabled", "disabled");

                var request = $.ajax({
                    url: kpConfig.schools.list.url,
                    data: values,
                    success: function(data) {
                        $("#kp-group_selection-school_id").html(data).removeAttr("disabled");
                    },
                    error: function() {
                        $("#kp-group_selection-school_id").html("<option>Välj stadsdel först</option>");
                    },
                    complete: function() {
                        $("#kp-group-selection-form").trigger("districtSelected", [ districtId ]);
                        $("#kp-group_selection-district_id").parent().find('.load-indicator').remove();
                    }
                });

            });
            /**
             * Fetches groups by Ajax when choosing a school in the group selection fragment
             */
            $("#kp-group_selection-school_id").change(function() {
                var schoolId = $("#kp-group_selection-school_id option:selected").val();
                var values = $(this).parents("form").serialize();

                $("#kp-group_selection-school_id").parent().append('<div class="load-indicator"></div>');
                $("#kp-group_selection-group_id").attr("disabled", "disabled");

                var request = $.ajax({
                    url: kpConfig.groups.list.url,
                    data: values,
                    success: function(data, textStatus) {
                        $("#kp-group_selection-group_id").html(data).removeAttr("disabled");
                    },
                    error: function() {
                        $("#kp-group_selection-group_id").html("<option>Välj skola först</option>");
                    },
                    complete: function() {
                        $("#kp-group_selection-school_id").parent().find('.load-indicator').remove();
                        $("#kp-group-selection-form").trigger("schoolSelected", [ schoolId ]);
                    }
                });
            });
            /**
             * Triggers the event groupSelected on the group selection fragment when selecting
             * a group.
             */
            $("#kp-group_selection-group_id").change(function() {
                var groupId = parseInt($("#kp-group_selection-group_id option:selected").val());
                $("#kp-group-selection-form").trigger("groupSelected", [ groupId ])
                $.get(kpConfig.groups.select.url, { group_id: groupId });
            });
        }
    });

    $(function() {
        /**
         * Listeners for group selection fragment events for the notification request form
         */
        $("#kp .notification-request-group-selection #kp-group-selection-form"
        ).bind("groupSelected", function(e, groupId) {
            if (!isNaN(groupId)) {
                // Set the groupId in the form
                $("#kp-notification_request-group_id").val(groupId);
                $("#kp .notification-request-form input").removeAttr("disabled");
            } else {
                // Disable the form
                $("#kp .notification-request-form input").attr("disabled", "disabled");
            }
        }).bind("districtSelected schoolSelected", function(e, id){
            // Disable the form
            $("#kp .notification-request-form input").attr("disabled", "disabled");
        });
        
        /**
         * Listeners for group selection fragment events for the group bookings listing
         */
        $("#kp .group-bookings-group-selection #kp-group-selection-form"
        ).bind("groupSelected", function(e, groupId) {
            if (!isNaN(groupId)) {
                // Load the group booking list
                var request = $.get(kpConfig.booking.groupList.url,
                { group_id: groupId },
                function(data) {
                    var cnt = $("#kp-group-bookings-container");
                    cnt.html(data);

                    // Fix for incoming URL:s in Sitevision
                    var urlBase = $("#kp-sitevision-base-url").attr("href");
                    cnt.find("a").each(function(i, elem) {
                        var link = $(elem);
                        var href = link.attr("href");

                        // Remove the domain name (IE fix)
                        if (href.indexOf("http://") == 0) {
                            href = href.slice(href.indexOf("/", 7));
                        }

                        link.attr("href", urlBase.substr(0, urlBase.length - 1) + href);
                    });
                });
            } else {
                $("#kp-group-bookings-container").html("");
            }
        }).bind("districtSelected schoolSelected", function(e, id){
            $("#kp-group-bookings-container").html("");
        });
    });
{'fraction_non_alphanumeric': 0.1539176935596373, 'fraction_numerical': 0.0006200108501898783, 'mean_word_length': 1.5129503407984422, 'pattern_counts': {'":': 10, '<': 25, '<?xml version=': 0, '>': 25, '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': '2244250', 'n_tokens_mistral': 3310, 'n_tokens_neox': 3104, 'n_words': 577}