<commit_before>/*************************************************
 * Copyright (c) 2015 Ansible, Inc.
 *
 * All Rights Reserved
 *************************************************/

    /**
 * @ngdoc function
 * @name helpers.function:LoadConfig
 * @description   Attempts to load local_config.js. If not found, loads config.js. Then evaluates the loaded
 *  javascript, putting the result in $AnsibleConfig.
 *  LoadConfigHelper
 *
 *
 *
 */

/*jshint evil:true */



export default
angular.module('LoadConfigHelper', ['Utilities'])

.factory('LoadConfig', ['$log', '$rootScope', '$http', '$location',
    'ProcessErrors', 'Store',
    function($log, $rootScope, $http, $location, ProcessErrors, Store) {
    return function() {

        if ($rootScope.removeLoadConfig) {
            $rootScope.removeLoadConfig();
        }
        $rootScope.removeLoadConfig = $rootScope.$on('LoadConfig', function() {
            $rootScope.enteredPath = $location.path();
            // Load js/local_settings.json
            $http({ method:'GET', url: $basePath + 'local_settings.json' })
                .success(function(data) {
                    $log.info('loaded local_settings.json');
                    if(angular.isObject(data)){
                        $AnsibleConfig = _.extend($AnsibleConfig, data);
                        Store('AnsibleConfig', $AnsibleConfig);
                        $rootScope.$emit('ConfigReady');
                    }
                    else {
                        $log.info('local_settings.json is not a valid object');
                        $rootScope.$emit('ConfigReady');
                    }

                })
                .error(function() {
                    //local_settings.json not found
                    $log.info('local_settings.json not found');
                    $rootScope.$emit('ConfigReady');
                });
        });


        // load config.js
        $log.info('attempting to load config.js');
        $http({ method:'GET', url: $basePath + 'config.js' })
            .success(function(data) {
                $log.info('loaded config.js');
                $AnsibleConfig = eval(data);
                Store('AnsibleConfig', $AnsibleConfig);
                $rootScope.$emit('LoadConfig');
            })
            .error(function(data, status) {
                ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
                    msg: 'Failed to load ' + $basePath + '/config.js. GET status: ' + status
                });
            });
    };
}]);<commit_msg>updated $http get request from deprecated syntax for angular 1.4<commit_after>/*************************************************
 * Copyright (c) 2015 Ansible, Inc.
 *
 * All Rights Reserved
 *************************************************/

    /**
 * @ngdoc function
 * @name helpers.function:LoadConfig
 * @description   Attempts to load local_config.js. If not found, loads config.js. Then evaluates the loaded
 *  javascript, putting the result in $AnsibleConfig.
 *  LoadConfigHelper
 *
 *
 *
 */

/*jshint evil:true */



export default
angular.module('LoadConfigHelper', ['Utilities'])

.factory('LoadConfig', ['$log', '$rootScope', '$http', '$location',
    'ProcessErrors', 'Store',
    function($log, $rootScope, $http, $location, ProcessErrors, Store) {
    return function() {

        if ($rootScope.removeLoadConfig) {
            $rootScope.removeLoadConfig();
        }
        $rootScope.removeLoadConfig = $rootScope.$on('LoadConfig', function() {
            $rootScope.enteredPath = $location.path();
            // Load js/local_settings.json
            $http({ method:'GET', url: $basePath + 'local_settings.json' })
                .then(function(response) {
                    $log.info('loaded local_settings.json');
                    if(angular.isObject(response.data)){
                        $AnsibleConfig = _.extend($AnsibleConfig, response.data);
                        Store('AnsibleConfig', $AnsibleConfig);
                        $rootScope.$emit('ConfigReady');
                    }
                    else {
                        $log.info('local_settings.json is not a valid object');
                        $rootScope.$emit('ConfigReady');
                    }

                }, function(response) {
                    //local_settings.json not found
                    $log.info('local_settings.json not found');
                    $rootScope.$emit('ConfigReady');
                });
        });


        // load config.js
        $log.info('attempting to load config.js');
        $http({ method:'GET', url: $basePath + 'config.js' })
            .success(function(data) {
                $log.info('loaded config.js');
                $AnsibleConfig = eval(data);
                Store('AnsibleConfig', $AnsibleConfig);
                $rootScope.$emit('LoadConfig');
            })
            .error(function(data, status) {
                ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
                    msg: 'Failed to load ' + $basePath + '/config.js. GET status: ' + status
                });
            });
    };
}]);
{'fraction_non_alphanumeric': 0.17153920619554694, 'fraction_numerical': 0.001936108422071636, 'mean_word_length': 1.8860335195530726, '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': '1674798', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1279, 'n_words': 273}