refactor code

This commit is contained in:
MaysWind 2016-06-20 23:37:25 +08:00
parent 5411660e31
commit 0797237deb
3 changed files with 12 additions and 8 deletions

View file

@ -57,10 +57,6 @@
var options = angular.copy($scope.context.options);
var tasks = [];
if (pauseOnAdded) {
options.pause = 'true';
}
for (var i = 0; i < urls.length; i++) {
tasks.push({
urls: [urls[i].trim()],
@ -68,7 +64,7 @@
});
}
$rootScope.loadPromise = aria2TaskService.newUriTasks(tasks, function (response) {
$rootScope.loadPromise = aria2TaskService.newUriTasks(tasks, pauseOnAdded, function (response) {
if (!response.hasSuccess) {
return;
}

View file

@ -168,10 +168,17 @@
var contexts = [];
for (var i = 0; i < context.tasks.length; i++) {
var task = context.tasks[i];
var options = angular.copy(task.options);
if (context.pauseOnAdded) {
options.pause = 'true';
}
contexts.push({
silent: !!context.silent,
urls: context.tasks[i].urls,
options: context.tasks[i].options
urls: task.urls,
options: options
});
}

View file

@ -248,9 +248,10 @@
}
});
},
newUriTasks: function (tasks, callback, silent) {
newUriTasks: function (tasks, pauseOnAdded, callback, silent) {
return aria2RpcService.addUriMulti({
tasks: tasks,
pauseOnAdded: !!pauseOnAdded,
silent: !!silent,
callback: callback
});