code refactor
This commit is contained in:
parent
e0cddfde33
commit
088fd42e78
|
@ -579,5 +579,5 @@
|
|||
};
|
||||
|
||||
$translateProvider.translations(ariaNgConstants.defaultLanguage, defaultLanguageResource);
|
||||
}])
|
||||
}]);
|
||||
}());
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
var base64Url = $routeParams.url;
|
||||
var url = base64.urldecode(base64Url);
|
||||
$rootScope.loadPromise = newUrlDownload(url);
|
||||
ariaNgLogService.info("[CommandController] new download: " + url);
|
||||
ariaNgLogService.info('[CommandController] new download: ' + url);
|
||||
} else {
|
||||
ariaNgCommonService.error('Parameter is invalid!');
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
stoppedCount: globalStat.numStopped,
|
||||
downloadSpeed: globalStat.downloadSpeed,
|
||||
uploadSpeed: globalStat.uploadSpeed
|
||||
}
|
||||
};
|
||||
})($scope.globalStat);
|
||||
|
||||
$document[0].title = ariaNgSettingService.getFinalTitle(context);
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
var refreshDownloadTask = function (silent) {
|
||||
if (pauseDownloadTaskRefresh) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var processError = function (message) {
|
||||
if (message === aria2RpcErrors.Unauthorized.message) {
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
var timespan = moment.duration(duration, sourceUnit);
|
||||
var time = moment.utc(timespan.asMilliseconds());
|
||||
return time.format(format);
|
||||
}
|
||||
};
|
||||
}]);
|
||||
}());
|
||||
|
|
|
@ -22,6 +22,6 @@
|
|||
} else {
|
||||
return array;
|
||||
}
|
||||
}
|
||||
};
|
||||
}]);
|
||||
}());
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
return function (time) {
|
||||
var format = $translate.instant('format.longdate');
|
||||
return moment(time).format(format);
|
||||
}
|
||||
};
|
||||
}]);
|
||||
}());
|
||||
|
|
|
@ -26,6 +26,6 @@
|
|||
} else {
|
||||
return array;
|
||||
}
|
||||
}
|
||||
};
|
||||
}]);
|
||||
}());
|
||||
|
|
|
@ -7,6 +7,6 @@
|
|||
var result = parseInt(value * ratio) / ratio;
|
||||
|
||||
return $filter('number')(result, precision);
|
||||
}
|
||||
};
|
||||
}]);
|
||||
}());
|
||||
|
|
|
@ -28,6 +28,6 @@
|
|||
} else {
|
||||
return array;
|
||||
}
|
||||
}
|
||||
};
|
||||
}]);
|
||||
}());
|
||||
|
|
|
@ -26,6 +26,6 @@
|
|||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
}());
|
||||
|
|
|
@ -32,6 +32,6 @@
|
|||
value = $filter('number')(value, fractionSize);
|
||||
|
||||
return value + ' ' + unit;
|
||||
}
|
||||
};
|
||||
}]);
|
||||
}());
|
||||
|
|
|
@ -154,14 +154,14 @@
|
|||
return aria2RpcService.getVersion({
|
||||
silent: !!silent,
|
||||
callback: callback
|
||||
})
|
||||
});
|
||||
},
|
||||
getGlobalStat: function (callback, silent) {
|
||||
return aria2RpcService.getGlobalStat({
|
||||
silent: !!silent,
|
||||
callback: function (response) {
|
||||
if (!callback) {
|
||||
ariaNgLogService.warn("[aria2SettingService.getGlobalStat] callback is null");
|
||||
ariaNgLogService.warn('[aria2SettingService.getGlobalStat] callback is null');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -174,13 +174,13 @@
|
|||
return aria2RpcService.saveSession({
|
||||
silent: !!silent,
|
||||
callback: callback
|
||||
})
|
||||
});
|
||||
},
|
||||
shutdown: function (callback, silent) {
|
||||
return aria2RpcService.shutdown({
|
||||
silent: !!silent,
|
||||
callback: callback
|
||||
})
|
||||
});
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
angular.module('ariaNg').factory('aria2TaskService', ['$q', '$translate', 'bittorrentPeeridService', 'aria2Errors', 'aria2RpcService', 'ariaNgCommonService', 'ariaNgLogService', function ($q, $translate, bittorrentPeeridService, aria2Errors, aria2RpcService, ariaNgCommonService, ariaNgLogService) {
|
||||
var getFileName = function (file) {
|
||||
if (!file) {
|
||||
ariaNgLogService.warn("[aria2TaskService.getFileName] file is null");
|
||||
ariaNgLogService.warn('[aria2TaskService.getFileName] file is null');
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@
|
|||
|
||||
var processDownloadTask = function (task) {
|
||||
if (!task) {
|
||||
ariaNgLogService.warn("[aria2TaskService.processDownloadTask] task is null");
|
||||
ariaNgLogService.warn('[aria2TaskService.processDownloadTask] task is null');
|
||||
return task;
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@
|
|||
|
||||
var processBtPeers = function (peers, task, includeLocalPeer) {
|
||||
if (!peers) {
|
||||
ariaNgLogService.warn("[aria2TaskService.processBtPeers] peers is null");
|
||||
ariaNgLogService.warn('[aria2TaskService.processBtPeers] peers is null');
|
||||
return peers;
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,7 @@
|
|||
} else {
|
||||
callback(context);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var createLocalPeerFromTask = function (task) {
|
||||
|
@ -275,7 +275,7 @@
|
|||
silent: !!silent,
|
||||
callback: function (response) {
|
||||
if (!callback) {
|
||||
ariaNgLogService.warn("[aria2TaskService.getTaskList] callback is null");
|
||||
ariaNgLogService.warn('[aria2TaskService.getTaskList] callback is null');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -289,7 +289,7 @@
|
|||
silent: !!silent,
|
||||
callback: function (response) {
|
||||
if (!callback) {
|
||||
ariaNgLogService.warn("[aria2TaskService.getTaskStatus] callback is null");
|
||||
ariaNgLogService.warn('[aria2TaskService.getTaskStatus] callback is null');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@
|
|||
silent: !!silent,
|
||||
callback: function (response) {
|
||||
if (!callback) {
|
||||
ariaNgLogService.warn("[aria2TaskService.getBtTaskPeers] callback is null");
|
||||
ariaNgLogService.warn('[aria2TaskService.getBtTaskPeers] callback is null');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -364,7 +364,7 @@
|
|||
silent: !!silent,
|
||||
callback: function (response) {
|
||||
if (!callback) {
|
||||
ariaNgLogService.warn("[aria2TaskService.getTaskStatusAndBtPeers] callback is null");
|
||||
ariaNgLogService.warn('[aria2TaskService.getTaskStatusAndBtPeers] callback is null');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -445,12 +445,12 @@
|
|||
silent: !!silent,
|
||||
callback: function (response) {
|
||||
if (!callback) {
|
||||
ariaNgLogService.warn("[aria2TaskService.restartTask] callback is null");
|
||||
ariaNgLogService.warn('[aria2TaskService.restartTask] callback is null');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!response.success) {
|
||||
ariaNgLogService.warn("[aria2TaskService.restartTask] response is not success");
|
||||
ariaNgLogService.warn('[aria2TaskService.restartTask] response is not success');
|
||||
deferred.reject(response);
|
||||
callback(response);
|
||||
return;
|
||||
|
@ -466,23 +466,23 @@
|
|||
|
||||
if (!task || !options || !task.files || task.files.length != 1 || task.bittorrent) {
|
||||
if (!task) {
|
||||
ariaNgLogService.warn("[aria2TaskService.restartTask] task is null");
|
||||
ariaNgLogService.warn('[aria2TaskService.restartTask] task is null');
|
||||
}
|
||||
|
||||
if (!options) {
|
||||
ariaNgLogService.warn("[aria2TaskService.restartTask] options is null");
|
||||
ariaNgLogService.warn('[aria2TaskService.restartTask] options is null');
|
||||
}
|
||||
|
||||
if (!task.files) {
|
||||
ariaNgLogService.warn("[aria2TaskService.restartTask] task file is null");
|
||||
ariaNgLogService.warn('[aria2TaskService.restartTask] task file is null');
|
||||
}
|
||||
|
||||
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) {
|
||||
ariaNgLogService.warn("[aria2TaskService.restartTask] task is bittorrent");
|
||||
ariaNgLogService.warn('[aria2TaskService.restartTask] task is bittorrent');
|
||||
}
|
||||
|
||||
deferred.reject(gid);
|
||||
|
@ -509,7 +509,7 @@
|
|||
silent: !!silent,
|
||||
callback: function (response) {
|
||||
if (!response.success) {
|
||||
ariaNgLogService.warn("[aria2TaskService.restartTask] addUri response is not success");
|
||||
ariaNgLogService.warn('[aria2TaskService.restartTask] addUri response is not success');
|
||||
deferred.reject(response);
|
||||
callback(response);
|
||||
return;
|
||||
|
@ -583,7 +583,7 @@
|
|||
how: 'POS_SET',
|
||||
silent: !!silent,
|
||||
callback: callback
|
||||
})
|
||||
});
|
||||
},
|
||||
clearStoppedTasks: function (callback, silent) {
|
||||
return aria2RpcService.purgeDownloadResult({
|
||||
|
@ -593,7 +593,7 @@
|
|||
},
|
||||
onFirstSuccess: function (callback) {
|
||||
if (!callback) {
|
||||
ariaNgLogService.warn("[aria2TaskService.onFirstSuccess] callback is null");
|
||||
ariaNgLogService.warn('[aria2TaskService.onFirstSuccess] callback is null');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -603,7 +603,7 @@
|
|||
},
|
||||
onTaskCompleted: function (callback) {
|
||||
if (!callback) {
|
||||
ariaNgLogService.warn("[aria2TaskService.onTaskCompleted] callback is null");
|
||||
ariaNgLogService.warn('[aria2TaskService.onTaskCompleted] callback is null');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -613,7 +613,7 @@
|
|||
},
|
||||
onBtTaskCompleted: function (callback) {
|
||||
if (!callback) {
|
||||
ariaNgLogService.warn("[aria2TaskService.onBtTaskCompleted] callback is null");
|
||||
ariaNgLogService.warn('[aria2TaskService.onBtTaskCompleted] callback is null');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -623,7 +623,7 @@
|
|||
},
|
||||
onTaskErrorOccur: function (callback) {
|
||||
if (!callback) {
|
||||
ariaNgLogService.warn("[aria2TaskService.onTaskErrorOccur] callback is null");
|
||||
ariaNgLogService.warn('[aria2TaskService.onTaskErrorOccur] callback is null');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -633,7 +633,7 @@
|
|||
},
|
||||
processDownloadTasks: function (tasks) {
|
||||
if (!angular.isArray(tasks)) {
|
||||
ariaNgLogService.warn("[aria2TaskService.processDownloadTasks] tasks is not array");
|
||||
ariaNgLogService.warn('[aria2TaskService.processDownloadTasks] tasks is not array');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -649,7 +649,7 @@
|
|||
},
|
||||
estimateHealthPercentFromPeers: function (task, peers) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
}, 100);
|
||||
},
|
||||
showError: function (text) {
|
||||
ariaNgLogService.info("[ariaNgCommonService.showError] " + text);
|
||||
ariaNgLogService.info('[ariaNgCommonService.showError] ' + text);
|
||||
this.showDialog('Error', text, 'error');
|
||||
},
|
||||
showOperationSucceeded: function (text) {
|
||||
|
@ -174,7 +174,7 @@
|
|||
}
|
||||
},
|
||||
getValue: function () {
|
||||
return this.type + ":" + this.order;
|
||||
return this.type + ':' + this.order;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -227,7 +227,7 @@
|
|||
name: name,
|
||||
value: value,
|
||||
optionValue: time
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
return options;
|
||||
|
|
|
@ -87,6 +87,6 @@
|
|||
reader.readAsDataURL(file);
|
||||
}).trigger('click');
|
||||
}
|
||||
}
|
||||
};
|
||||
}]);
|
||||
}());
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
return {
|
||||
key: line.substring(0, equalSignPos),
|
||||
value: line.substring(equalSignPos + 1, line.length)
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
value: line
|
||||
|
|
|
@ -154,6 +154,6 @@
|
|||
getGlobalStatsData: function () {
|
||||
return this.getStatsData(globalStorageKey);
|
||||
}
|
||||
}
|
||||
};
|
||||
}]);
|
||||
}());
|
||||
|
|
|
@ -82,6 +82,6 @@
|
|||
clearNotificationInPage: function () {
|
||||
Notification.clearAll();
|
||||
}
|
||||
}
|
||||
};
|
||||
}]);
|
||||
}());
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
return ariaNgDefaultOptions.language;
|
||||
}
|
||||
|
||||
browserLang = browserLang.replace(/\-/g, "_");
|
||||
browserLang = browserLang.replace(/\-/g, '_');
|
||||
|
||||
if (!ariaNgLanguages[browserLang]) {
|
||||
return ariaNgDefaultOptions.language;
|
||||
|
|
Reference in a new issue