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'
}
});
})();
}());

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -11,7 +11,7 @@
var browserVersions = navigator.appVersion.split(';');
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;
}
@ -24,4 +24,4 @@
tip.innerHTML = 'Sorry, AriaNg cannot support this browser, please upgrade your browser!';
document.getElementById('content-wrapper').appendChild(tip);
}
})();
}());

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -191,4 +191,4 @@
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);
}
}]);
})();
}());

View file

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

View file

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

View file

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

View file

@ -9,4 +9,4 @@
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;
}
}]);
})();
}());

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;
};
}]);
})();
}());

View file

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

View file

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

View file

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