code refactor

This commit is contained in:
MaysWind 2016-12-11 01:50:25 +08:00
parent e0cddfde33
commit 088fd42e78
20 changed files with 47 additions and 47 deletions

View file

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

View file

@ -21,7 +21,7 @@
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);
ariaNgLogService.info("[CommandController] new download: " + url); ariaNgLogService.info('[CommandController] new download: ' + url);
} else { } else {
ariaNgCommonService.error('Parameter is invalid!'); ariaNgCommonService.error('Parameter is invalid!');
} }

View file

@ -17,7 +17,7 @@
stoppedCount: globalStat.numStopped, stoppedCount: globalStat.numStopped,
downloadSpeed: globalStat.downloadSpeed, downloadSpeed: globalStat.downloadSpeed,
uploadSpeed: globalStat.uploadSpeed uploadSpeed: globalStat.uploadSpeed
} };
})($scope.globalStat); })($scope.globalStat);
$document[0].title = ariaNgSettingService.getFinalTitle(context); $document[0].title = ariaNgSettingService.getFinalTitle(context);

View file

@ -6,6 +6,6 @@
var timespan = moment.duration(duration, sourceUnit); var timespan = moment.duration(duration, sourceUnit);
var time = moment.utc(timespan.asMilliseconds()); var time = moment.utc(timespan.asMilliseconds());
return time.format(format); return time.format(format);
} };
}]); }]);
}()); }());

View file

@ -22,6 +22,6 @@
} else { } else {
return array; return array;
} }
} };
}]); }]);
}()); }());

View file

@ -5,6 +5,6 @@
return function (time) { return function (time) {
var format = $translate.instant('format.longdate'); var format = $translate.instant('format.longdate');
return moment(time).format(format); return moment(time).format(format);
} };
}]); }]);
}()); }());

View file

@ -26,6 +26,6 @@
} else { } else {
return array; return array;
} }
} };
}]); }]);
}()); }());

View file

@ -7,6 +7,6 @@
var result = parseInt(value * ratio) / ratio; var result = parseInt(value * ratio) / ratio;
return $filter('number')(result, precision); return $filter('number')(result, precision);
} };
}]); }]);
}()); }());

View file

@ -28,6 +28,6 @@
} else { } else {
return array; return array;
} }
} };
}]); }]);
}()); }());

View file

@ -26,6 +26,6 @@
} else { } else {
return ''; return '';
} }
} };
}); });
}()); }());

View file

@ -32,6 +32,6 @@
value = $filter('number')(value, fractionSize); value = $filter('number')(value, fractionSize);
return value + ' ' + unit; return value + ' ' + unit;
} };
}]); }]);
}()); }());

View file

@ -154,14 +154,14 @@
return aria2RpcService.getVersion({ return aria2RpcService.getVersion({
silent: !!silent, silent: !!silent,
callback: callback callback: callback
}) });
}, },
getGlobalStat: function (callback, silent) { getGlobalStat: function (callback, silent) {
return aria2RpcService.getGlobalStat({ return aria2RpcService.getGlobalStat({
silent: !!silent, silent: !!silent,
callback: function (response) { callback: function (response) {
if (!callback) { if (!callback) {
ariaNgLogService.warn("[aria2SettingService.getGlobalStat] callback is null"); ariaNgLogService.warn('[aria2SettingService.getGlobalStat] callback is null');
return; return;
} }
@ -174,13 +174,13 @@
return aria2RpcService.saveSession({ return aria2RpcService.saveSession({
silent: !!silent, silent: !!silent,
callback: callback callback: callback
}) });
}, },
shutdown: function (callback, silent) { shutdown: function (callback, silent) {
return aria2RpcService.shutdown({ return aria2RpcService.shutdown({
silent: !!silent, silent: !!silent,
callback: callback callback: callback
}) });
} }
}; };
}]); }]);

View file

@ -4,7 +4,7 @@
angular.module('ariaNg').factory('aria2TaskService', ['$q', '$translate', 'bittorrentPeeridService', 'aria2Errors', 'aria2RpcService', 'ariaNgCommonService', 'ariaNgLogService', function ($q, $translate, bittorrentPeeridService, aria2Errors, aria2RpcService, ariaNgCommonService, ariaNgLogService) { angular.module('ariaNg').factory('aria2TaskService', ['$q', '$translate', 'bittorrentPeeridService', 'aria2Errors', 'aria2RpcService', 'ariaNgCommonService', 'ariaNgLogService', function ($q, $translate, bittorrentPeeridService, aria2Errors, aria2RpcService, ariaNgCommonService, ariaNgLogService) {
var getFileName = function (file) { var getFileName = function (file) {
if (!file) { if (!file) {
ariaNgLogService.warn("[aria2TaskService.getFileName] file is null"); ariaNgLogService.warn('[aria2TaskService.getFileName] file is null');
return ''; return '';
} }
@ -123,7 +123,7 @@
var processDownloadTask = function (task) { var processDownloadTask = function (task) {
if (!task) { if (!task) {
ariaNgLogService.warn("[aria2TaskService.processDownloadTask] task is null"); ariaNgLogService.warn('[aria2TaskService.processDownloadTask] task is null');
return task; return task;
} }
@ -176,7 +176,7 @@
var processBtPeers = function (peers, task, includeLocalPeer) { var processBtPeers = function (peers, task, includeLocalPeer) {
if (!peers) { if (!peers) {
ariaNgLogService.warn("[aria2TaskService.processBtPeers] peers is null"); ariaNgLogService.warn('[aria2TaskService.processBtPeers] peers is null');
return peers; return peers;
} }
@ -240,7 +240,7 @@
} else { } else {
callback(context); callback(context);
} }
} };
}; };
var createLocalPeerFromTask = function (task) { var createLocalPeerFromTask = function (task) {
@ -275,7 +275,7 @@
silent: !!silent, silent: !!silent,
callback: function (response) { callback: function (response) {
if (!callback) { if (!callback) {
ariaNgLogService.warn("[aria2TaskService.getTaskList] callback is null"); ariaNgLogService.warn('[aria2TaskService.getTaskList] callback is null');
return; return;
} }
@ -289,7 +289,7 @@
silent: !!silent, silent: !!silent,
callback: function (response) { callback: function (response) {
if (!callback) { if (!callback) {
ariaNgLogService.warn("[aria2TaskService.getTaskStatus] callback is null"); ariaNgLogService.warn('[aria2TaskService.getTaskStatus] callback is null');
return; return;
} }
@ -338,7 +338,7 @@
silent: !!silent, silent: !!silent,
callback: function (response) { callback: function (response) {
if (!callback) { if (!callback) {
ariaNgLogService.warn("[aria2TaskService.getBtTaskPeers] callback is null"); ariaNgLogService.warn('[aria2TaskService.getBtTaskPeers] callback is null');
return; return;
} }
@ -364,7 +364,7 @@
silent: !!silent, silent: !!silent,
callback: function (response) { callback: function (response) {
if (!callback) { if (!callback) {
ariaNgLogService.warn("[aria2TaskService.getTaskStatusAndBtPeers] callback is null"); ariaNgLogService.warn('[aria2TaskService.getTaskStatusAndBtPeers] callback is null');
return; return;
} }
@ -445,12 +445,12 @@
silent: !!silent, silent: !!silent,
callback: function (response) { callback: function (response) {
if (!callback) { if (!callback) {
ariaNgLogService.warn("[aria2TaskService.restartTask] callback is null"); ariaNgLogService.warn('[aria2TaskService.restartTask] callback is null');
return; return;
} }
if (!response.success) { if (!response.success) {
ariaNgLogService.warn("[aria2TaskService.restartTask] response is not success"); ariaNgLogService.warn('[aria2TaskService.restartTask] response is not success');
deferred.reject(response); deferred.reject(response);
callback(response); callback(response);
return; return;
@ -466,23 +466,23 @@
if (!task || !options || !task.files || task.files.length != 1 || task.bittorrent) { if (!task || !options || !task.files || task.files.length != 1 || task.bittorrent) {
if (!task) { if (!task) {
ariaNgLogService.warn("[aria2TaskService.restartTask] task is null"); ariaNgLogService.warn('[aria2TaskService.restartTask] task is null');
} }
if (!options) { if (!options) {
ariaNgLogService.warn("[aria2TaskService.restartTask] options is null"); ariaNgLogService.warn('[aria2TaskService.restartTask] options is null');
} }
if (!task.files) { if (!task.files) {
ariaNgLogService.warn("[aria2TaskService.restartTask] task file is null"); ariaNgLogService.warn('[aria2TaskService.restartTask] task file is null');
} }
if (task.files.length != 1) { if (task.files.length != 1) {
ariaNgLogService.warn("[aria2TaskService.restartTask] task file length is not equal 1"); ariaNgLogService.warn('[aria2TaskService.restartTask] task file length is not equal 1');
} }
if (task.bittorrent) { if (task.bittorrent) {
ariaNgLogService.warn("[aria2TaskService.restartTask] task is bittorrent"); ariaNgLogService.warn('[aria2TaskService.restartTask] task is bittorrent');
} }
deferred.reject(gid); deferred.reject(gid);
@ -509,7 +509,7 @@
silent: !!silent, silent: !!silent,
callback: function (response) { callback: function (response) {
if (!response.success) { if (!response.success) {
ariaNgLogService.warn("[aria2TaskService.restartTask] addUri response is not success"); ariaNgLogService.warn('[aria2TaskService.restartTask] addUri response is not success');
deferred.reject(response); deferred.reject(response);
callback(response); callback(response);
return; return;
@ -583,7 +583,7 @@
how: 'POS_SET', how: 'POS_SET',
silent: !!silent, silent: !!silent,
callback: callback callback: callback
}) });
}, },
clearStoppedTasks: function (callback, silent) { clearStoppedTasks: function (callback, silent) {
return aria2RpcService.purgeDownloadResult({ return aria2RpcService.purgeDownloadResult({
@ -593,7 +593,7 @@
}, },
onFirstSuccess: function (callback) { onFirstSuccess: function (callback) {
if (!callback) { if (!callback) {
ariaNgLogService.warn("[aria2TaskService.onFirstSuccess] callback is null"); ariaNgLogService.warn('[aria2TaskService.onFirstSuccess] callback is null');
return; return;
} }
@ -603,7 +603,7 @@
}, },
onTaskCompleted: function (callback) { onTaskCompleted: function (callback) {
if (!callback) { if (!callback) {
ariaNgLogService.warn("[aria2TaskService.onTaskCompleted] callback is null"); ariaNgLogService.warn('[aria2TaskService.onTaskCompleted] callback is null');
return; return;
} }
@ -613,7 +613,7 @@
}, },
onBtTaskCompleted: function (callback) { onBtTaskCompleted: function (callback) {
if (!callback) { if (!callback) {
ariaNgLogService.warn("[aria2TaskService.onBtTaskCompleted] callback is null"); ariaNgLogService.warn('[aria2TaskService.onBtTaskCompleted] callback is null');
return; return;
} }
@ -623,7 +623,7 @@
}, },
onTaskErrorOccur: function (callback) { onTaskErrorOccur: function (callback) {
if (!callback) { if (!callback) {
ariaNgLogService.warn("[aria2TaskService.onTaskErrorOccur] callback is null"); ariaNgLogService.warn('[aria2TaskService.onTaskErrorOccur] callback is null');
return; return;
} }
@ -633,7 +633,7 @@
}, },
processDownloadTasks: function (tasks) { processDownloadTasks: function (tasks) {
if (!angular.isArray(tasks)) { if (!angular.isArray(tasks)) {
ariaNgLogService.warn("[aria2TaskService.processDownloadTasks] tasks is not array"); ariaNgLogService.warn('[aria2TaskService.processDownloadTasks] tasks is not array');
return; return;
} }
@ -649,7 +649,7 @@
}, },
estimateHealthPercentFromPeers: function (task, peers) { estimateHealthPercentFromPeers: function (task, peers) {
if (!task || task.numPieces < 1 || peers.length < 1) { if (!task || task.numPieces < 1 || peers.length < 1) {
ariaNgLogService.warn("[aria2TaskService.estimateHealthPercentFromPeers] tasks is null or numPieces < 1 or peers < 1"); ariaNgLogService.warn('[aria2TaskService.estimateHealthPercentFromPeers] tasks is null or numPieces < 1 or peers < 1');
return task.completePercent; return task.completePercent;
} }

View file

@ -20,7 +20,7 @@
}, 100); }, 100);
}, },
showError: function (text) { showError: function (text) {
ariaNgLogService.info("[ariaNgCommonService.showError] " + text); ariaNgLogService.info('[ariaNgCommonService.showError] ' + text);
this.showDialog('Error', text, 'error'); this.showDialog('Error', text, 'error');
}, },
showOperationSucceeded: function (text) { showOperationSucceeded: function (text) {
@ -174,7 +174,7 @@
} }
}, },
getValue: function () { getValue: function () {
return this.type + ":" + this.order; return this.type + ':' + this.order;
} }
}; };
@ -227,7 +227,7 @@
name: name, name: name,
value: value, value: value,
optionValue: time optionValue: time
}) });
} }
return options; return options;

View file

@ -87,6 +87,6 @@
reader.readAsDataURL(file); reader.readAsDataURL(file);
}).trigger('click'); }).trigger('click');
} }
} };
}]); }]);
}()); }());

View file

@ -9,7 +9,7 @@
return { return {
key: line.substring(0, equalSignPos), key: line.substring(0, equalSignPos),
value: line.substring(equalSignPos + 1, line.length) value: line.substring(equalSignPos + 1, line.length)
} };
} else { } else {
return { return {
value: line value: line

View file

@ -154,6 +154,6 @@
getGlobalStatsData: function () { getGlobalStatsData: function () {
return this.getStatsData(globalStorageKey); return this.getStatsData(globalStorageKey);
} }
} };
}]); }]);
}()); }());

View file

@ -82,6 +82,6 @@
clearNotificationInPage: function () { clearNotificationInPage: function () {
Notification.clearAll(); Notification.clearAll();
} }
} };
}]); }]);
}()); }());

View file

@ -25,7 +25,7 @@
return ariaNgDefaultOptions.language; return ariaNgDefaultOptions.language;
} }
browserLang = browserLang.replace(/\-/g, "_"); browserLang = browserLang.replace(/\-/g, '_');
if (!ariaNgLanguages[browserLang]) { if (!ariaNgLanguages[browserLang]) {
return ariaNgDefaultOptions.language; return ariaNgDefaultOptions.language;