<commit_before>(function (angular) {
    "use strict";
    angular
        .module('folderPluginWidget')
        .controller('folderPluginCtrl', ['$scope', '$sce', '$timeout', '$rootScope', 'Messaging', 'Utility',
            function ($scope, $sce, $timeout, $rootScope, Messaging, Utility) {
                var view = null;
                var pagesCount = 0;
                var currentPage = 0;
                var loadingData = true;
                $scope.layout12Height = '300px';
                $scope.layout12TotalItem = 0;
                $scope.setWidth = function () {
                    $rootScope.deviceWidth = window.innerWidth || 320;
                };

                function initDeviceSize(callback) {
                    $scope.deviceHeight = window.innerHeight;
                    $scope.deviceWidth = window.innerWidth || 320;
                    $scope.sliderHeight = Math.ceil(9 * $scope.deviceWidth / 16);
                    if (callback) {
                        if ($scope.deviceWidth == 0 || $scope.deviceHeight == 0) {
                            setTimeout(function () {
                                initDeviceSize(callback);
                            }, 500);
                        } else {
                            callback();
                            if (!$scope.$$phase && !$scope.$root.$$phase) {
                                $scope.$apply();
                            }
                        }
                    }
                }

                function preparePluginsData(plugins) {
                    if ($scope.data.design.selectedLayout == 5 || $scope.data.design.selectedLayout == 6) {
                        var temp = [];
                        var currentItem = 0;
                        var pluginsLength = plugins.length;

                        for (var i = 0; i < pluginsLength; i++) {
                            if (i % 2 == 0) {
                                temp[currentItem] = [];
                                temp[currentItem].push(plugins[i]);
                            } else {
                                temp[currentItem].push(plugins[i]);

                                currentItem++;
                            }
                        }

                        $scope.data.plugins = temp;
                    } else if ($scope.data.design.selectedLayout == 12) {
                        var matrix = [], i, k;
                        var matrix = []
                        for (i = 0, k = -1; i < plugins.length; i++) {
                            if (i % 8 === 0) {
                                k++;
                                matrix[k] = [];
                            }
                            matrix[k].push(plugins[i]);
                        }
                        $scope.data.plugins = matrix;
                    } else {
                        $scope.data.plugins = plugins;
                    }
                }

                /*
                 * bind data to the scope
                 * */
                function bind(data) {
                    $scope.data.design = data.design;

                    if (!$scope.data.design) {
                        $scope.data.design = {
                            backgroundImage: null,
                            selectedLayout: 1,
                            backgroundblur: 0
                        };
                    }
                    if (data.plugins) {
                        var currentCount = Number(data.plugins.length);
                    }

                    if($scope.data.design.lgBackgroundImage && window.innerWidth >= 600){
                        //iPads
                        $scope.data.design.bgImage = $scope.data.design.lgBackgroundImage;
                    } else {
                        $scope.data.design.bgImage = $scope.data.design.backgroundImage;
                    }

                    preparePluginsData(data.plugins);


                    if (currentCount) {
                        $scope.layout12TotalItem = currentCount;
                    }

                    $scope.data.content = data.content;
                    if ($scope.data.content && $scope.data.content.carouselImages) {
                        initDeviceSize(function () {
                            $timeout(function () {
                                if (!view) {
                                    view = new buildfire.components.carousel.view("#carousel", $scope.data.content.carouselImages);
                                } else {
                                    view.loadItems($scope.data.content.carouselImages);
                                }
                            }, 1000);
                        });
                    }

                    if (!$scope.$$phase && !$scope.$root.$$phase) {
                        $scope.$apply();
                    }
                }

                $scope.safeHtml = function (html) {
                    if (html) {
                        var $html = $('<div />', { html: html });<commit_msg>fixes on displaying bg on widget side<commit_after>(function (angular) {
    "use strict";
    angular
        .module('folderPluginWidget')
        .controller('folderPluginCtrl', ['$scope', '$sce', '$timeout', '$rootScope', 'Messaging', 'Utility',
            function ($scope, $sce, $timeout, $rootScope, Messaging, Utility) {
                var view = null;
                var pagesCount = 0;
                var currentPage = 0;
                var loadingData = true;
                $scope.layout12Height = '300px';
                $scope.layout12TotalItem = 0;
                $scope.setWidth = function () {
                    $rootScope.deviceWidth = window.innerWidth || 320;
                };

                function initDeviceSize(callback) {
                    $scope.deviceHeight = window.innerHeight;
                    $scope.deviceWidth = window.innerWidth || 320;
                    $scope.sliderHeight = Math.ceil(9 * $scope.deviceWidth / 16);
                    if (callback) {
                        if ($scope.deviceWidth == 0 || $scope.deviceHeight == 0) {
                            setTimeout(function () {
                                initDeviceSize(callback);
                            }, 500);
                        } else {
                            callback();
                            if (!$scope.$$phase && !$scope.$root.$$phase) {
                                $scope.$apply();
                            }
                        }
                    }
                }

                function preparePluginsData(plugins) {
                    if ($scope.data.design.selectedLayout == 5 || $scope.data.design.selectedLayout == 6) {
                        var temp = [];
                        var currentItem = 0;
                        var pluginsLength = plugins.length;

                        for (var i = 0; i < pluginsLength; i++) {
                            if (i % 2 == 0) {
                                temp[currentItem] = [];
                                temp[currentItem].push(plugins[i]);
                            } else {
                                temp[currentItem].push(plugins[i]);

                                currentItem++;
                            }
                        }

                        $scope.data.plugins = temp;
                    } else if ($scope.data.design.selectedLayout == 12) {
                        var matrix = [], i, k;
                        var matrix = []
                        for (i = 0, k = -1; i < plugins.length; i++) {
                            if (i % 8 === 0) {
                                k++;
                                matrix[k] = [];
                            }
                            matrix[k].push(plugins[i]);
                        }
                        $scope.data.plugins = matrix;
                    } else {
                        $scope.data.plugins = plugins;
                    }
                }

                /*
                 * bind data to the scope
                 * */
                function bind(data) {
                    $scope.data.design = data.design;

                    if (!$scope.data.design) {
                        $scope.data.design = {
                            backgroundImage: null,
                            selectedLayout: 1,
                            backgroundblur: 0
                        };
                    }
                    if (data.plugins) {
                        var currentCount = Number(data.plugins.length);
                    }

                    $scope.data.design.bgImage = $scope.data.design.backgroundImage || $scope.data.design.lgBackgroundImage;

                    if($scope.data.design.lgBackgroundImage && window.innerWidth >= 600){
                        //iPads
                        $scope.data.design.bgImage = $scope.data.design.lgBackgroundImage;
                    }

                    preparePluginsData(data.plugins);


                    if (currentCount) {
                        $scope.layout12TotalItem = currentCount;
                    }

                    $scope.data.content = data.content;
                    if ($scope.data.content && $scope.data.content.carouselImages) {
                        initDeviceSize(function () {
                            $timeout(function () {
                                if (!view) {
                                    view = new buildfire.components.carousel.view("#carousel", $scope.data.content.carouselImages);
                                } else {
                                    view.loadItems($scope.data.content.carouselImages);
                                }
                            }, 1000);
                        });
                    }

                    if (!$scope.$$phase && !$scope.$root.$$phase) {
                        $scope.$apply();
                    }
                }

                $scope.safeHtml = function (html) {
                    if (html) {
                        var $html = $('<div />', { html: html });
{'fraction_non_alphanumeric': 0.10476751030017657, 'fraction_numerical': 0.009221110457131646, 'mean_word_length': 0.8224883804075795, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6584440', 'n_tokens_mistral': 2401, 'n_tokens_neox': 2121, 'n_words': 402}