<commit_before>(function () {
    'use strict';

    angular.module('ariaNg').controller('DownloadListController', ['$rootScope', '$scope', '$window', '$location', '$interval', 'translateFilter',  'aria2RpcService', 'ariaNgSettingService', 'utils', function ($rootScope, $scope, $window, $location, $interval, translateFilter, aria2RpcService, ariaNgSettingService, utils) {
        var location = $location.path().substring(1);

        var getTitleWidth = function () {
            var titleColumn = angular.element('.task-table > .row > .col-md-8:first-child');

            if (titleColumn.length > 0) {
                return titleColumn.width();
            } else {
                var taskTable = angular.element('.task-table');

                if ($window.innerWidth <= 767) {
                    return taskTable.width();
                } else {
                    return taskTable.width() / 12 * 8;
                }
            }
        };

        var calculateDownloadRemainTime = function (remainBytes, downloadSpeed) {
            if (downloadSpeed == 0) {
                return 0;
            }

            return remainBytes / downloadSpeed;
        };

        var processDownloadTask = function (task) {
            var remainLength = task.totalLength - task.completedLength;

            if (task.bittorrent && task.bittorrent.info) {
                task.taskName = task.bittorrent.info.name;
            } else if (task.files && task.files.length >= 1) {
                task.taskName = utils.getFileNameFromPath(task.files[0].path);
            } else {
                task.taskName = translateFilter('Unknown');
            }

            task.completePercent = task.completedLength / task.totalLength * 100;
            task.idle = task.downloadSpeed == 0;
            task.remainTime = calculateDownloadRemainTime(remainLength, task.downloadSpeed);
        };

        $scope.titleWidth = getTitleWidth();

        angular.element($window).bind('resize', function () {
            $scope.titleWidth = getTitleWidth();
        });

        $scope.getOrderType = function () {
            return ariaNgSettingService.getDisplayOrder();
        };

        if ($rootScope.downloadTaskRefreshTimer) {
            $interval.cancel($rootScope.downloadTaskRefreshTimer);
        }

        $rootScope.downloadTaskRefreshTimer = $interval(function () {
            var invokeMethod = null;
            var params = [];

            if (location == 'downloading') {
                invokeMethod = aria2RpcService.tellActive;
            } else if (location == 'waiting') {
                invokeMethod = aria2RpcService.tellWaiting;
                params = [0, 1000];
            } else if (location == 'downloaded') {
                invokeMethod = aria2RpcService.tellStopped;
                params = [0, 1000];
            }

            if (invokeMethod) {
                invokeMethod({
                    params: params,
                    callback: function (result) {
                        if (result && result.length > 0) {
                            for (var i = 0; i < result.length; i++) {
                                processDownloadTask(result[i]);
                            }
                        }

                        if (!utils.replaceArray(result, $scope.downloadTasks, 'gid')) {
                            $scope.downloadTasks = result;<commit_msg>fix stopped list cannot display<commit_after>(function () {
    'use strict';

    angular.module('ariaNg').controller('DownloadListController', ['$rootScope', '$scope', '$window', '$location', '$interval', 'translateFilter',  'aria2RpcService', 'ariaNgSettingService', 'utils', function ($rootScope, $scope, $window, $location, $interval, translateFilter, aria2RpcService, ariaNgSettingService, utils) {
        var location = $location.path().substring(1);

        var getTitleWidth = function () {
            var titleColumn = angular.element('.task-table > .row > .col-md-8:first-child');

            if (titleColumn.length > 0) {
                return titleColumn.width();
            } else {
                var taskTable = angular.element('.task-table');

                if ($window.innerWidth <= 767) {
                    return taskTable.width();
                } else {
                    return taskTable.width() / 12 * 8;
                }
            }
        };

        var calculateDownloadRemainTime = function (remainBytes, downloadSpeed) {
            if (downloadSpeed == 0) {
                return 0;
            }

            return remainBytes / downloadSpeed;
        };

        var processDownloadTask = function (task) {
            var remainLength = task.totalLength - task.completedLength;

            if (task.bittorrent && task.bittorrent.info) {
                task.taskName = task.bittorrent.info.name;
            } else if (task.files && task.files.length >= 1) {
                task.taskName = utils.getFileNameFromPath(task.files[0].path);
            } else {
                task.taskName = translateFilter('Unknown');
            }

            task.completePercent = task.completedLength / task.totalLength * 100;
            task.idle = task.downloadSpeed == 0;
            task.remainTime = calculateDownloadRemainTime(remainLength, task.downloadSpeed);
        };

        $scope.titleWidth = getTitleWidth();

        angular.element($window).bind('resize', function () {
            $scope.titleWidth = getTitleWidth();
        });

        $scope.getOrderType = function () {
            return ariaNgSettingService.getDisplayOrder();
        };

        if ($rootScope.downloadTaskRefreshTimer) {
            $interval.cancel($rootScope.downloadTaskRefreshTimer);
        }

        $rootScope.downloadTaskRefreshTimer = $interval(function () {
            var invokeMethod = null;
            var params = [];

            if (location == 'downloading') {
                invokeMethod = aria2RpcService.tellActive;
            } else if (location == 'waiting') {
                invokeMethod = aria2RpcService.tellWaiting;
                params = [0, 1000];
            } else if (location == 'stopped') {
                invokeMethod = aria2RpcService.tellStopped;
                params = [0, 1000];
            }

            if (invokeMethod) {
                invokeMethod({
                    params: params,
                    callback: function (result) {
                        if (result && result.length > 0) {
                            for (var i = 0; i < result.length; i++) {
                                processDownloadTask(result[i]);
                            }
                        }

                        if (!utils.replaceArray(result, $scope.downloadTasks, 'gid')) {
                            $scope.downloadTasks = result;
{'fraction_non_alphanumeric': 0.11548019295424646, 'fraction_numerical': 0.00994006724163134, 'mean_word_length': 1.659152739992227, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 33, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6062611', 'n_tokens_mistral': 1793, 'n_tokens_neox': 1659, 'n_words': 340}