<commit_before>(function (angular) {
    "use strict";

    angular
        .module('folderPluginContent')
        .controller('folderPluginCtrl', ['$scope', 'Messaging', 'Utility',
            function ($scope, Messaging, Utility) {
                var tmpCarousalData = null;
                var editor = new buildfire.components.carousel.editor("#carousel");
                var _buildfire = {
                    plugins: {
                        dataType: "pluginInstance",
                        data: []
                    }
                };
                var _design = {
                    backgroundImage: null,
                    selectedLayout: 1,
                    backgroundblur: 0,
                    hideText: false
                };
                var navigationCallback = function (pluginData) {
                    Messaging.sendMessageToWidget({
                        name: 'OPEN_PLUGIN',
                        message: {
                            data: pluginData
                        }
                    });
                };
                var plugins = new buildfire.components.pluginInstance.sortableList("#plugins", [], { showIcon: true, confirmDeleteItem: false }, undefined, undefined, { itemEditable: true, navigationCallback: navigationCallback });
                var tmrDelay = null;
                var updateItem = null;
                $scope.editorOptions = Utility.getEditorOptions();
                $scope.masterData = Utility.getDefaultScopeData();
                $scope.datastoreInitialized = false;

                function isUnchanged(data) {
                    return angular.equals(data, $scope.masterData);
                }

                function updateMasterItem(data) {
                    $scope.masterData = angular.copy(data);
                }

                //Go pull any previously saved data
                buildfire.datastore.getWithDynamicData(function (err, result) {
                    if (!err) {
                        $scope.datastoreInitialized = true;
                    } else {
                        console.error("Error: ", err);
                        return;
                    }

                    if (!result.id) {
                        result.data = Utility.getDefaultScopeData();
                    }

                    if (result && result.data && !angular.equals({}, result.data)) {
                        updateMasterItem(result.data);
                        $scope.data = result.data;
                        $scope.id = result.id;
                        if ($scope.data && $scope.data.content && $scope.data.content.carouselImages) {
                            editor.loadItems($scope.data.content.carouselImages);
                        }
                        if ($scope.data && $scope.data._buildfire && $scope.data._buildfire.plugins && $scope.data._buildfire.plugins.result) {
                            var pluginsData = Utility.getPluginDetails($scope.data._buildfire.plugins.result, $scope.data._buildfire.plugins.data);
                            if ($scope.data.content && $scope.data.content.loadAllPlugins) {
                                if (pluginsData.length) {
                                    plugins.loadItems(pluginsData, "loadAll");
                                    $("#plugins").find(".carousel-items").hide();
                                } else {
                                    plugins.loadAllItems();
                                    $("#plugins").find(".carousel-items").hide();
                                }
                            } else {
                                plugins.loadItems(pluginsData, "selected");
                                $("#plugins").find(".carousel-items").show();
                            }
                        }

                        if ($scope.data && !$scope.data._buildfire) {
                            updateItem = angular.copy($scope.data);
                            updateItem._buildfire = _buildfire;
                            updateMasterItem(updateItem);
                            $scope.data = angular.copy(updateItem);
                        }

                        if ($scope.data && !$scope.data.design) {
                            updateItem = angular.copy($scope.data);
                            updateItem.design = _design;
                            updateMasterItem(updateItem);
                            $scope.data = angular.copy(updateItem);
                        }
                        if (tmrDelay) clearTimeout(tmrDelay);
                    }<commit_msg>fix the default data on widget<commit_after>(function (angular) {
    "use strict";

    angular
        .module('folderPluginContent')
        .controller('folderPluginCtrl', ['$scope', 'Messaging', 'Utility',
            function ($scope, Messaging, Utility) {
                var tmpCarousalData = null;
                var editor = new buildfire.components.carousel.editor("#carousel");
                var _buildfire = {
                    plugins: {
                        dataType: "pluginInstance",
                        data: []
                    }
                };
                var _design = {
                    backgroundImage: null,
                    selectedLayout: 1,
                    backgroundblur: 0,
                    hideText: false
                };
                var navigationCallback = function (pluginData) {
                    Messaging.sendMessageToWidget({
                        name: 'OPEN_PLUGIN',
                        message: {
                            data: pluginData
                        }
                    });
                };
                var plugins = new buildfire.components.pluginInstance.sortableList("#plugins", [], { showIcon: true, confirmDeleteItem: false }, undefined, undefined, { itemEditable: true, navigationCallback: navigationCallback });
                var tmrDelay = null;
                var updateItem = null;
                $scope.editorOptions = Utility.getEditorOptions();
                $scope.masterData = Utility.getDefaultScopeData();
                $scope.datastoreInitialized = false;

                function isUnchanged(data) {
                    return angular.equals(data, $scope.masterData);
                }

                function updateMasterItem(data) {
                    $scope.masterData = angular.copy(data);
                }

                //Go pull any previously saved data
                buildfire.datastore.getWithDynamicData(function (err, result) {
                    if (!err) {
                        $scope.datastoreInitialized = true;
                    } else {
                        console.error("Error: ", err);
                        return;
                    }

                    var firstTimeVisit = false;
                    if (!result.id) {
                        result.data = Utility.getDefaultScopeData();
                        firstTimeVisit = true;
                    }

                    if (result && result.data && !angular.equals({}, result.data)) {
                        updateMasterItem(result.data);
                        $scope.data = result.data;
                        $scope.id = result.id;
                        if ($scope.data && $scope.data.content && $scope.data.content.carouselImages) {
                            editor.loadItems($scope.data.content.carouselImages);
                        }
                        if ($scope.data && $scope.data._buildfire && $scope.data._buildfire.plugins && $scope.data._buildfire.plugins.result) {
                            var pluginsData = Utility.getPluginDetails($scope.data._buildfire.plugins.result, $scope.data._buildfire.plugins.data);
                            if ($scope.data.content && $scope.data.content.loadAllPlugins) {
                                if (pluginsData.length) {
                                    plugins.loadItems(pluginsData, "loadAll");
                                    $("#plugins").find(".carousel-items").hide();
                                } else {
                                    plugins.loadAllItems();
                                    $("#plugins").find(".carousel-items").hide();
                                }
                            } else {
                                plugins.loadItems(pluginsData, "selected");
                                $("#plugins").find(".carousel-items").show();
                            }
                        }

                        if ($scope.data && !$scope.data._buildfire) {
                            updateItem = angular.copy($scope.data);
                            updateItem._buildfire = _buildfire;
                            updateMasterItem(updateItem);
                            $scope.data = angular.copy(updateItem);
                        }

                        if ($scope.data && !$scope.data.design) {
                            updateItem = angular.copy($scope.data);
                            updateItem.design = _design;
                            updateMasterItem(updateItem);
                            $scope.data = angular.copy(updateItem);
                        }

                        if(firstTimeVisit){
                            setTimeout(function () {
                                saveData($scope.data);
                            }, 500);
                        }

                        if (tmrDelay) clearTimeout(tmrDelay);
                    }
{'fraction_non_alphanumeric': 0.09844775497447651, 'fraction_numerical': 0.0007292426294405667, 'mean_word_length': 1.0399490012749681, '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': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3502898', 'n_tokens_mistral': 2145, 'n_tokens_neox': 1977, 'n_words': 344}