refact code

This commit is contained in:
MaysWind 2016-08-01 22:49:16 +08:00
parent f80a0504c9
commit 2417981dff
47 changed files with 85 additions and 89 deletions

View file

@ -903,4 +903,4 @@
} }
] ]
}); });
})(); }());

View file

@ -12,4 +12,4 @@
tipTextKey: 'rpc.error.unauthorized' tipTextKey: 'rpc.error.unauthorized'
} }
}); });
})(); }());

View file

@ -17,4 +17,4 @@
delay: ariaNgConstants.notificationInPageTimeout delay: ariaNgConstants.notificationInPageTimeout
}); });
}]); }]);
})(); }());

View file

@ -124,4 +124,4 @@
globalStatRefreshInterval: 1000, globalStatRefreshInterval: 1000,
downloadTaskRefreshInterval: 1000 downloadTaskRefreshInterval: 1000
}); });
})(); }());

View file

@ -524,4 +524,4 @@
$translateProvider.translations(ariaNgConstants.defaultLanguage, defaultLanguageResource); $translateProvider.translations(ariaNgConstants.defaultLanguage, defaultLanguageResource);
}]) }])
})(); }());

View file

@ -11,4 +11,4 @@
amMoment.changeLocale(language); amMoment.changeLocale(language);
ariaNgSettingService.applyLanguage(language); ariaNgSettingService.applyLanguage(language);
}]); }]);
})(); }());

View file

@ -11,4 +11,4 @@
displayName: '简体中文' displayName: '简体中文'
} }
}); });
})(); }());

View file

@ -17,7 +17,7 @@
}); });
}; };
if (path.indexOf('/new/') == 0) { if (path.indexOf('/new/') === 0) {
var base64Url = $routeParams.url; var base64Url = $routeParams.url;
var url = base64.urldecode(base64Url); var url = base64.urldecode(base64Url);
$rootScope.loadPromise = newUrlDownload(url); $rootScope.loadPromise = newUrlDownload(url);
@ -25,4 +25,4 @@
ariaNgCommonService.error('Parameter is invalid!'); ariaNgCommonService.error('Parameter is invalid!');
} }
}]); }]);
})(); }());

View file

@ -18,7 +18,7 @@
} }
if (!response.success) { if (!response.success) {
if (response.data.message == aria2RpcErrors.Unauthorized.message) { if (response.data.message === aria2RpcErrors.Unauthorized.message) {
$interval.cancel(downloadTaskRefreshPromise); $interval.cancel(downloadTaskRefreshPromise);
} }
@ -85,7 +85,7 @@
$scope.isSupportDragTask = function () { $scope.isSupportDragTask = function () {
var displayOrder = ariaNgCommonService.parseOrderType(ariaNgSettingService.getDisplayOrder()); var displayOrder = ariaNgCommonService.parseOrderType(ariaNgSettingService.getDisplayOrder());
return location == 'waiting' && displayOrder.type == 'default'; return location === 'waiting' && displayOrder.type === 'default';
}; };
if (ariaNgSettingService.getDownloadTaskRefreshInterval() > 0) { if (ariaNgSettingService.getDownloadTaskRefreshInterval() > 0) {
@ -123,4 +123,4 @@
$rootScope.loadPromise = refreshDownloadTask(false); $rootScope.loadPromise = refreshDownloadTask(false);
}]); }]);
})(); }());

View file

@ -25,7 +25,7 @@
var refreshGlobalStat = function (silent, callback) { var refreshGlobalStat = function (silent, callback) {
return aria2SettingService.getGlobalStat(function (response) { return aria2SettingService.getGlobalStat(function (response) {
if (!response.success && response.data.message == aria2RpcErrors.Unauthorized.message) { if (!response.success && response.data.message === aria2RpcErrors.Unauthorized.message) {
$interval.cancel(globalStatRefreshPromise); $interval.cancel(globalStatRefreshPromise);
return; return;
} }
@ -62,7 +62,7 @@
for (var i = 0; i < selectedTasks.length; i++) { for (var i = 0; i < selectedTasks.length; i++) {
for (var j = 0; j < arguments.length; j++) { for (var j = 0; j < arguments.length; j++) {
if (selectedTasks[i].status == arguments[j]) { if (selectedTasks[i].status === arguments[j]) {
return true; return true;
} }
} }
@ -80,7 +80,7 @@
for (var i = 0; i < tasks.length; i++) { for (var i = 0; i < tasks.length; i++) {
for (var j = 0; j < arguments.length; j++) { for (var j = 0; j < arguments.length; j++) {
if (tasks[i].status == arguments[j]) { if (tasks[i].status === arguments[j]) {
return true; return true;
} }
} }
@ -98,9 +98,9 @@
var invoke = null; var invoke = null;
if (state == 'start') { if (state === 'start') {
invoke = aria2TaskService.startTasks; invoke = aria2TaskService.startTasks;
} else if (state == 'pause') { } else if (state === 'pause') {
invoke = aria2TaskService.pauseTasks; invoke = aria2TaskService.pauseTasks;
} else { } else {
return; return;
@ -117,14 +117,14 @@
refreshGlobalStat(true); refreshGlobalStat(true);
if (!response.hasError && state == 'start') { if (!response.hasError && state === 'start') {
if ($location.path() == '/waiting') { if ($location.path() === '/waiting') {
$location.path('/downloading'); $location.path('/downloading');
} else { } else {
$route.reload(); $route.reload();
} }
} else if (!response.hasError && state == 'pause') { } else if (!response.hasError && state === 'pause') {
if ($location.path() == '/downloading') { if ($location.path() === '/downloading') {
$location.path('/waiting'); $location.path('/waiting');
} else { } else {
$route.reload(); $route.reload();
@ -153,7 +153,7 @@
refreshGlobalStat(true); refreshGlobalStat(true);
if (!response.hasError) { if (!response.hasError) {
if ($location.path() == '/stopped') { if ($location.path() === '/stopped') {
$route.reload(); $route.reload();
} else { } else {
$location.path('/stopped'); $location.path('/stopped');
@ -172,7 +172,7 @@
refreshGlobalStat(true); refreshGlobalStat(true);
if ($location.path() == '/stopped') { if ($location.path() === '/stopped') {
$route.reload(); $route.reload();
} else { } else {
$location.path('/stopped'); $location.path('/stopped');
@ -189,7 +189,7 @@
var oldType = ariaNgCommonService.parseOrderType(ariaNgSettingService.getDisplayOrder()); var oldType = ariaNgCommonService.parseOrderType(ariaNgSettingService.getDisplayOrder());
var newType = ariaNgCommonService.parseOrderType(type); var newType = ariaNgCommonService.parseOrderType(type);
if (autoSetReverse && newType.type == oldType.type) { if (autoSetReverse && newType.type === oldType.type) {
newType.reverse = !oldType.reverse; newType.reverse = !oldType.reverse;
} }
@ -229,4 +229,4 @@
refreshPageTitle(); refreshPageTitle();
}); });
}]); }]);
})(); }());

View file

@ -17,7 +17,7 @@
}; };
$scope.changeTab = function (tabName) { $scope.changeTab = function (tabName) {
if (tabName == 'options') { if (tabName === 'options') {
$scope.loadDefaultOption(); $scope.loadDefaultOption();
} }
@ -98,7 +98,7 @@
var tasks = []; var tasks = [];
for (var i = 0; i < urls.length; i++) { for (var i = 0; i < urls.length; i++) {
if (urls[i] == '' || urls[i].trim() == '') { if (urls[i] === '' || urls[i].trim() === '') {
continue; continue;
} }
@ -122,7 +122,7 @@
}; };
$scope.setOption = function (key, value, optionStatus) { $scope.setOption = function (key, value, optionStatus) {
if (value != '') { if (value !== '') {
$scope.context.options[key] = value; $scope.context.options[key] = value;
} else { } else {
delete $scope.context.options[key]; delete $scope.context.options[key];
@ -132,13 +132,11 @@
}; };
$scope.urlTextboxKeyDown = function (event) { $scope.urlTextboxKeyDown = function (event) {
if (event.keyCode == 13 && event.ctrlKey && $scope.newTaskForm.$valid) { if (event.keyCode === 13 && event.ctrlKey && $scope.newTaskForm.$valid) {
$scope.startDownload(); $scope.startDownload();
} }
}; };
$rootScope.loadPromise = $timeout(function () { $rootScope.loadPromise = $timeout(function () {}, 100);
;//Do Nothing
}, 100);
}]); }]);
})(); }());

View file

@ -20,7 +20,7 @@
$scope.setGlobalOption = function (key, value, optionStatus) { $scope.setGlobalOption = function (key, value, optionStatus) {
return aria2SettingService.setGlobalOption(key, value, function (response) { return aria2SettingService.setGlobalOption(key, value, function (response) {
if (response.success && response.data == 'OK') { if (response.success && response.data === 'OK') {
optionStatus.setSuccess(); optionStatus.setSuccess();
} else { } else {
optionStatus.setFailed(response.data.message); optionStatus.setFailed(response.data.message);
@ -36,4 +36,4 @@
}); });
})(); })();
}]); }]);
})(); }());

View file

@ -29,8 +29,6 @@
} }
}; };
$rootScope.loadPromise = $timeout(function () { $rootScope.loadPromise = $timeout(function () {}, 100);
;//Do Nothing
}, 100);
}]); }]);
})(); }());

View file

@ -8,7 +8,7 @@
$scope.saveSession = function () { $scope.saveSession = function () {
return aria2SettingService.saveSession(function (response) { return aria2SettingService.saveSession(function (response) {
if (response.success && response.data == 'OK') { if (response.success && response.data === 'OK') {
ariaNgCommonService.showOperationSucceeded('Session has been saved successfully.'); ariaNgCommonService.showOperationSucceeded('Session has been saved successfully.');
} }
}); });
@ -17,7 +17,7 @@
$scope.shutdown = function () { $scope.shutdown = function () {
ariaNgCommonService.confirm('Confirm Shutdown', 'Are you sure you want to shutdown aria2?', 'warning', function (status) { ariaNgCommonService.confirm('Confirm Shutdown', 'Are you sure you want to shutdown aria2?', 'warning', function (status) {
return aria2SettingService.shutdown(function (response) { return aria2SettingService.shutdown(function (response) {
if (response.success && response.data == 'OK') { if (response.success && response.data === 'OK') {
ariaNgCommonService.showOperationSucceeded('Aria2 has been shutdown successfully.'); ariaNgCommonService.showOperationSucceeded('Aria2 has been shutdown successfully.');
} }
}); });
@ -32,4 +32,4 @@
}); });
})(); })();
}]); }]);
})(); }());

View file

@ -21,13 +21,13 @@
return; return;
} }
if (task.status != 'active' || !task.bittorrent) { if (task.status !== 'active' || !task.bittorrent) {
if (tabOrders.indexOf('btpeers') >= 0) { if (tabOrders.indexOf('btpeers') >= 0) {
tabOrders.splice(tabOrders.indexOf('btpeers'), 1); tabOrders.splice(tabOrders.indexOf('btpeers'), 1);
} }
} }
if (!$scope.task || $scope.task.status != task.status) { if (!$scope.task || $scope.task.status !== task.status) {
$scope.context.availableOptions = getAvailableOptions(task.status, !!task.bittorrent); $scope.context.availableOptions = getAvailableOptions(task.status, !!task.bittorrent);
} }
@ -53,7 +53,7 @@
}; };
var requireBtPeers = function (task) { var requireBtPeers = function (task) {
return (task && task.bittorrent && task.status == 'active'); return (task && task.bittorrent && task.status === 'active');
}; };
var refreshDownloadTask = function (silent) { var refreshDownloadTask = function (silent) {
@ -62,7 +62,7 @@
} }
var processError = function (message) { var processError = function (message) {
if (message == aria2RpcErrors.Unauthorized.message) { if (message === aria2RpcErrors.Unauthorized.message) {
$interval.cancel(downloadTaskRefreshPromise); $interval.cancel(downloadTaskRefreshPromise);
} }
}; };
@ -137,7 +137,7 @@
}; };
$scope.changeTab = function (tabName) { $scope.changeTab = function (tabName) {
if (tabName == 'settings') { if (tabName === 'settings') {
$scope.loadTaskOption($scope.task); $scope.loadTaskOption($scope.task);
} }
@ -170,7 +170,7 @@
var oldType = ariaNgCommonService.parseOrderType(ariaNgSettingService.getFileListDisplayOrder()); var oldType = ariaNgCommonService.parseOrderType(ariaNgSettingService.getFileListDisplayOrder());
var newType = ariaNgCommonService.parseOrderType(type); var newType = ariaNgCommonService.parseOrderType(type);
if (autoSetReverse && newType.type == oldType.type) { if (autoSetReverse && newType.type === oldType.type) {
newType.reverse = !oldType.reverse; newType.reverse = !oldType.reverse;
} }
@ -209,11 +209,11 @@
} }
for (var i = 0; i < $scope.task.files.length; i++) { for (var i = 0; i < $scope.task.files.length; i++) {
if (type == 'all') { if (type === 'all') {
$scope.task.files[i].selected = true; $scope.task.files[i].selected = true;
} else if (type == 'none') { } else if (type === 'none') {
$scope.task.files[i].selected = false; $scope.task.files[i].selected = false;
} else if (type == 'reverse') { } else if (type === 'reverse') {
$scope.task.files[i].selected = !$scope.task.files[i].selected; $scope.task.files[i].selected = !$scope.task.files[i].selected;
} }
} }
@ -271,7 +271,7 @@
var oldType = ariaNgCommonService.parseOrderType(ariaNgSettingService.getPeerListDisplayOrder()); var oldType = ariaNgCommonService.parseOrderType(ariaNgSettingService.getPeerListDisplayOrder());
var newType = ariaNgCommonService.parseOrderType(type); var newType = ariaNgCommonService.parseOrderType(type);
if (autoSetReverse && newType.type == oldType.type) { if (autoSetReverse && newType.type === oldType.type) {
newType.reverse = !oldType.reverse; newType.reverse = !oldType.reverse;
} }
@ -299,7 +299,7 @@
$scope.setOption = function (key, value, optionStatus) { $scope.setOption = function (key, value, optionStatus) {
return aria2TaskService.setTaskOption($scope.task.gid, key, value, function (response) { return aria2TaskService.setTaskOption($scope.task.gid, key, value, function (response) {
if (response.success && response.data == 'OK') { if (response.success && response.data === 'OK') {
optionStatus.setSuccess(); optionStatus.setSuccess();
} else { } else {
optionStatus.setFailed(response.data.message); optionStatus.setFailed(response.data.message);
@ -309,7 +309,7 @@
if (ariaNgSettingService.getDownloadTaskRefreshInterval() > 0) { if (ariaNgSettingService.getDownloadTaskRefreshInterval() > 0) {
downloadTaskRefreshPromise = $interval(function () { downloadTaskRefreshPromise = $interval(function () {
if ($scope.task && ($scope.task.status == 'complete' || $scope.task.status == 'error' || $scope.task.status == 'removed')) { if ($scope.task && ($scope.task.status === 'complete' || $scope.task.status === 'error' || $scope.task.status === 'removed')) {
$interval.cancel(downloadTaskRefreshPromise); $interval.cancel(downloadTaskRefreshPromise);
return; return;
} }
@ -326,4 +326,4 @@
$rootScope.loadPromise = refreshDownloadTask(false); $rootScope.loadPromise = refreshDownloadTask(false);
}]); }]);
})(); }());

View file

@ -3,4 +3,4 @@
//override AdminLTE options //override AdminLTE options
$.AdminLTE.options.animationSpeed = 300; $.AdminLTE.options.animationSpeed = 300;
})(); }());

View file

@ -11,7 +11,7 @@
var browserVersions = navigator.appVersion.split(';'); var browserVersions = navigator.appVersion.split(';');
var browserVersion = (browserVersions && browserVersions.length > 1 ? browserVersions[1].replace(/[ ]/g, '') : ''); var browserVersion = (browserVersions && browserVersions.length > 1 ? browserVersions[1].replace(/[ ]/g, '') : '');
if (browserName == 'Microsoft Internet Explorer' && (browserVersion == 'MSIE6.0' || browserVersion == 'MSIE7.0' || browserVersion == 'MSIE8.0' || browserVersion == 'MSIE9.0')) { if (browserName === 'Microsoft Internet Explorer' && (browserVersion === 'MSIE6.0' || browserVersion === 'MSIE7.0' || browserVersion === 'MSIE8.0' || browserVersion === 'MSIE9.0')) {
return true; return true;
} }
@ -24,4 +24,4 @@
tip.innerHTML = 'Sorry, AriaNg cannot support this browser, please upgrade your browser!'; tip.innerHTML = 'Sorry, AriaNg cannot support this browser, please upgrade your browser!';
document.getElementById('content-wrapper').appendChild(tip); document.getElementById('content-wrapper').appendChild(tip);
} }
})(); }());

View file

@ -14,4 +14,4 @@
}); });
fixContentWrapperHeight(); fixContentWrapperHeight();
})(); }());

View file

@ -21,4 +21,4 @@
'oitozero.ngSweetAlert', 'oitozero.ngSweetAlert',
angularDragula(angular) angularDragula(angular)
]); ]);
})(); }());

View file

@ -15,7 +15,7 @@
var lastPart = url2.substring(url.length); var lastPart = url2.substring(url.length);
if (lastPart.indexOf('/') == 0) { if (lastPart.indexOf('/') === 0) {
return true; return true;
} }
@ -209,4 +209,4 @@
initNavbar(); initNavbar();
}]); }]);
})(); }());

View file

@ -71,4 +71,4 @@
redirectTo: '/downloading' redirectTo: '/downloading'
}); });
}]); }]);
})(); }());

View file

@ -11,4 +11,4 @@
} }
}; };
}]); }]);
})(); }());

View file

@ -191,4 +191,4 @@
animationDuration: 500 animationDuration: 500
}; };
}); });
})(); }());

View file

@ -45,4 +45,4 @@
} }
}; };
}]); }]);
})(); }());

View file

@ -59,4 +59,4 @@
} }
}; };
}]); }]);
})(); }());

View file

@ -14,4 +14,4 @@
} }
}; };
}); });
})(); }());

View file

@ -226,4 +226,4 @@
} }
}; };
}]); }]);
})(); }());

View file

@ -72,4 +72,4 @@
} }
}; };
}); });
})(); }());

View file

@ -8,4 +8,4 @@
return time.format(format); return time.format(format);
} }
}]); }]);
})(); }());

View file

@ -24,4 +24,4 @@
} }
} }
}]); }]);
})(); }());

View file

@ -7,4 +7,4 @@
return moment(time).format(format); return moment(time).format(format);
} }
}]); }]);
})(); }());

View file

@ -28,4 +28,4 @@
} }
} }
}]); }]);
})(); }());

View file

@ -9,4 +9,4 @@
return $filter('number')(result, precision); return $filter('number')(result, precision);
} }
}]); }]);
})(); }());

View file

@ -30,4 +30,4 @@
} }
} }
}]); }]);
})(); }());

View file

@ -28,4 +28,4 @@
} }
} }
}); });
})(); }());

View file

@ -34,4 +34,4 @@
return value + ' ' + unit; return value + ' ' + unit;
} }
}]); }]);
})(); }());

View file

@ -39,4 +39,4 @@
} }
}; };
}]); }]);
})(); }());

View file

@ -438,4 +438,4 @@
} }
}; };
}]); }]);
})(); }());

View file

@ -183,4 +183,4 @@
} }
}; };
}]); }]);
})(); }());

View file

@ -590,4 +590,4 @@
} }
}; };
}]); }]);
})(); }());

View file

@ -117,4 +117,4 @@
} }
}; };
}]); }]);
})(); }());

View file

@ -233,4 +233,4 @@
} }
}; };
}]); }]);
})(); }());

View file

@ -89,4 +89,4 @@
} }
} }
}]); }]);
})(); }());

View file

@ -32,4 +32,4 @@
return deferred.promise; return deferred.promise;
}; };
}]); }]);
})(); }());

View file

@ -156,4 +156,4 @@
} }
} }
}]); }]);
})(); }());

View file

@ -84,4 +84,4 @@
} }
} }
}]); }]);
})(); }());

View file

@ -245,4 +245,4 @@
} }
}; };
}]); }]);
})(); }());