refactor code
This commit is contained in:
parent
5411660e31
commit
0797237deb
|
@ -57,10 +57,6 @@
|
||||||
var options = angular.copy($scope.context.options);
|
var options = angular.copy($scope.context.options);
|
||||||
var tasks = [];
|
var tasks = [];
|
||||||
|
|
||||||
if (pauseOnAdded) {
|
|
||||||
options.pause = 'true';
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = 0; i < urls.length; i++) {
|
for (var i = 0; i < urls.length; i++) {
|
||||||
tasks.push({
|
tasks.push({
|
||||||
urls: [urls[i].trim()],
|
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) {
|
if (!response.hasSuccess) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,10 +168,17 @@
|
||||||
var contexts = [];
|
var contexts = [];
|
||||||
|
|
||||||
for (var i = 0; i < context.tasks.length; i++) {
|
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({
|
contexts.push({
|
||||||
silent: !!context.silent,
|
silent: !!context.silent,
|
||||||
urls: context.tasks[i].urls,
|
urls: task.urls,
|
||||||
options: context.tasks[i].options
|
options: options
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -248,9 +248,10 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
newUriTasks: function (tasks, callback, silent) {
|
newUriTasks: function (tasks, pauseOnAdded, callback, silent) {
|
||||||
return aria2RpcService.addUriMulti({
|
return aria2RpcService.addUriMulti({
|
||||||
tasks: tasks,
|
tasks: tasks,
|
||||||
|
pauseOnAdded: !!pauseOnAdded,
|
||||||
silent: !!silent,
|
silent: !!silent,
|
||||||
callback: callback
|
callback: callback
|
||||||
});
|
});
|
||||||
|
|
Reference in a new issue