<commit_before>'use strict';
/* Services */
var KMCServices = angular.module('KMC.services', []);

KMCServices.config(['$httpProvider', function ($httpProvider) {
    $httpProvider.defaults.useXDomain = true;
    delete $httpProvider.defaults.headers.common['X-Requested-With'];
}]);

KMCServices.factory('apiCache', function ($cacheFactory) {
    return $cacheFactory('apiCache', {
        capacity: 10
    });
});

KMCServices.factory('sortSvc', [function () {
    var containers = {};
    var sorter = {};

    var Container = function Container(name) {
        this.name = name;
        this.elements = [];
        containers[name] = this;
    };
    Container.prototype.addElement = function (model) {
        this.elements.push(model);
    };
    Container.prototype.callObjectsUpdate = function () {
        angular.forEach(this.elements, function (model) {
            cl(model.sortVal + ' ' + model.model);
        });
    };
    Container.prototype.removeElement = function (model) {
        var index = this.elements.indexOf(model);
        if (index != -1)
            this.elements.splice(index, 1);
    };
    sorter.sortScope = '';
    sorter.register = function (containerName, model) {
        var container = (typeof  containers[containerName] == 'undefined') ? new Container(containerName) : containers[containerName];
        container.addElement(model);
    };
    sorter.update = function (newVal, oldVal, model) {
        var oldContainer = containers[oldVal];
        var newContainer = (!containers[newVal]) ? new Container(newVal) : containers[newVal];
        if (oldContainer) {
            oldContainer.removeElement(model);
        }
        newContainer.addElement(model);
        if (typeof  sorter.sortScope == 'object') {
            sorter.sortScope.$broadcast('sortContainersChanged');
        }
    };
    sorter.getObjects = function () {
        return containers;
    };
    sorter.saveOrder = function (containersObj) {
        containers = containersObj;
        angular.forEach(containers, function (container) {
            container.callObjectsUpdate();
        });
    };
    return sorter;
}]
);

KMCServices.factory('PlayerService', ['$http', '$modal', '$log', '$q', 'apiService' , '$filter', 'localStorageService',
    function ($http, $modal, $log, $q, apiService, $filter, localStorageService) {
        var playersCache = {};
        var currentPlayer = {};
        var previewEntry;
        var previewEntryObj;
        var playerId = 'kVideoTarget';
        var currentRefresh = null;

        var callback = function () {
            currentRefresh.resolve(true);
            playersService.refreshNeeded = false;
            currentRefresh = null;
            logTime('renderPlayerDone');
        };
        var playerRefresh = function (option) {
            if (!currentRefresh) {
                currentRefresh = $q.defer();
                try {
                    playersService.renderPlayer(callback);
                }
                catch (e) {
                    currentRefresh.reject(e);
                }
            }
            return currentRefresh.promise;
        };
        var playersService = {
            clearCurrentRefresh: function () {
                currentRefresh = null;
            },
            'refreshNeeded': false,
            getCurrentRefresh: function () {
                return currentRefresh;
            },
            'clearCurrentPlayer': function () {
                currentPlayer = {};
            },
            'setPreviewEntry': function (previewObj) {
                localStorageService.set('previewEntry', previewObj);
                previewEntry = previewObj.id;
                previewEntryObj = previewObj;
            },
            'getPreviewEntry': function () {
                if (!previewEntry) {
                    return localStorageService.get('previewEntry');
                }
                else {
                    return previewEntryObj;
                }
            },
            'renderPlayer': function (callback) {
                logTime('renderPlayer');
                if (currentPlayer && typeof kWidget != "undefined") {
                    var data2Save = angular.copy(currentPlayer.config);
                    data2Save.plugins = playersService.preparePluginsDataForRender(data2Save.plugins);
                    var flashvars = {'jsonConfig': angular.toJson(data2Save)}; // update the player with the new configuration
                    angular.extend(flashvars, data2Save.uiVars);
                    if ($('html').hasClass('IE8')) {                      // for IE8 add transparent mode
                        angular.extend(flashvars, {'wmode': 'transparent'});<commit_msg>#FEC-993<commit_after>'use strict';
/* Services */
var KMCServices = angular.module('KMC.services', []);

KMCServices.config(['$httpProvider', function ($httpProvider) {
    $httpProvider.defaults.useXDomain = true;
    delete $httpProvider.defaults.headers.common['X-Requested-With'];
}]);

KMCServices.factory('apiCache', function ($cacheFactory) {
    return $cacheFactory('apiCache', {
        capacity: 10
    });
});

KMCServices.factory('sortSvc', [function () {
    var containers = {};
    var sorter = {};

    var Container = function Container(name) {
        this.name = name;
        this.elements = [];
        containers[name] = this;
    };
    Container.prototype.addElement = function (model) {
        this.elements.push(model);
    };
    Container.prototype.callObjectsUpdate = function () {
        angular.forEach(this.elements, function (model) {
            cl(model.sortVal + ' ' + model.model);
        });
    };
    Container.prototype.removeElement = function (model) {
        var index = this.elements.indexOf(model);
        if (index != -1)
            this.elements.splice(index, 1);
    };
    sorter.sortScope = '';
    sorter.register = function (containerName, model) {
        var container = (typeof  containers[containerName] == 'undefined') ? new Container(containerName) : containers[containerName];
        container.addElement(model);
    };
    sorter.update = function (newVal, oldVal, model) {
        var oldContainer = containers[oldVal];
        var newContainer = (!containers[newVal]) ? new Container(newVal) : containers[newVal];
        if (oldContainer) {
            oldContainer.removeElement(model);
        }
        newContainer.addElement(model);
        if (typeof  sorter.sortScope == 'object') {
            sorter.sortScope.$broadcast('sortContainersChanged');
        }
    };
    sorter.getObjects = function () {
        return containers;
    };
    sorter.saveOrder = function (containersObj) {
        containers = containersObj;
        angular.forEach(containers, function (container) {
            container.callObjectsUpdate();
        });
    };
    return sorter;
}]
);

KMCServices.factory('PlayerService', ['$http', '$modal', '$log', '$q', 'apiService' , '$filter', 'localStorageService',
    function ($http, $modal, $log, $q, apiService, $filter, localStorageService) {
        var playersCache = {};
        var currentPlayer = {};
        var previewEntry;
        var previewEntryObj;
        var playerId = 'kVideoTarget';
        var currentRefresh = null;

        var callback = function () {
            currentRefresh.resolve(true);
            playersService.refreshNeeded = false;
            currentRefresh = null;
            logTime('renderPlayerDone');
        };
        var playerRefresh = function (option) {
            if (!currentRefresh) {
                currentRefresh = $q.defer();
                try {
                    playersService.renderPlayer(callback);
                }
                catch (e) {
                    currentRefresh.reject(e);
                }
            }
            return currentRefresh.promise;
        };
        var playersService = {
            clearCurrentRefresh: function () {
                currentRefresh = null;
            },
            'refreshNeeded': false,
            getCurrentRefresh: function () {
                return currentRefresh;
            },
            'clearCurrentPlayer': function () {
                currentPlayer = {};
            },
            'setPreviewEntry': function (previewObj) {
                localStorageService.set('previewEntry', previewObj);
                previewEntry = previewObj.id;
                previewEntryObj = previewObj;
            },
            'getPreviewEntry': function () {
                if (!previewEntry) {
                    return localStorageService.get('previewEntry');
                }
                else {
                    return previewEntryObj;
                }
            },
            'renderPlayer': function (callback) {
                logTime('renderPlayer');
                if (currentPlayer && typeof kWidget != "undefined") {
                    var data2Save = angular.copy(currentPlayer.config);
                    data2Save.plugins = playersService.preparePluginsDataForRender(data2Save.plugins);
                    var flashvars = {'jsonConfig': angular.toJson(data2Save)}; // update the player with the new configuration
                    if ($('html').hasClass('IE8')) {                      // for IE8 add transparent mode
                        angular.extend(flashvars, {'wmode': 'transparent'});
{'fraction_non_alphanumeric': 0.11991480298189564, 'fraction_numerical': 0.0025559105431309905, 'mean_word_length': 1.968078381795196, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6509943', 'n_tokens_mistral': 2376, 'n_tokens_neox': 2323, 'n_words': 463}