diff --git a/src/index.html b/src/index.html
index 0d25503..eaf6aa8 100644
--- a/src/index.html
+++ b/src/index.html
@@ -281,6 +281,7 @@
+
diff --git a/src/langs/zh_CN.json b/src/langs/zh_CN.json
index f424491..a3213d2 100644
--- a/src/langs/zh_CN.json
+++ b/src/langs/zh_CN.json
@@ -119,6 +119,7 @@
"Disabled": "禁用",
"Changes to the settings take effect after refreshing page.": "设置将在页面刷新后生效.",
"Type is illegal!": "类型错误!",
+ "Parameter is invalid!": "请求参数无效",
"format": {
"longdate": "YYYY年MM月DD日 HH:mm:ss",
"time.millisecond": "{{value}} 毫秒",
diff --git a/src/scripts/config/defaultLanguage.js b/src/scripts/config/defaultLanguage.js
index 09cf749..06f930a 100644
--- a/src/scripts/config/defaultLanguage.js
+++ b/src/scripts/config/defaultLanguage.js
@@ -123,6 +123,7 @@
'Disabled': 'Disabled',
'Changes to the settings take effect after refreshing page.': 'Changes to the settings take effect after refreshing page.',
'Type is illegal!': 'Type is illegal!',
+ 'Parameter is invalid!': 'Parameter is invalid!',
'format': {
'longdate': 'MM/DD/YYYY HH:mm:ss',
'time.millisecond': '{{value}} Millisecond',
diff --git a/src/scripts/controllers/command.js b/src/scripts/controllers/command.js
new file mode 100644
index 0000000..d8cddd9
--- /dev/null
+++ b/src/scripts/controllers/command.js
@@ -0,0 +1,28 @@
+(function () {
+ 'use strict';
+
+ angular.module('ariaNg').controller('CommandController', ['$rootScope', '$location', '$routeParams', 'base64', 'ariaNgCommonService', 'aria2TaskService', function ($rootScope, $location, $routeParams, base64, ariaNgCommonService, aria2TaskService) {
+ var path = $location.path();
+
+ var newUrlDownload = function (url) {
+ return aria2TaskService.newUriTask({
+ urls: [url],
+ options: {}
+ }, false, function (response) {
+ if (!response.success) {
+ return;
+ }
+
+ $location.path('/downloading');
+ });
+ };
+
+ if (path.indexOf('/new/') == 0) {
+ var base64Url = $routeParams.url;
+ var url = base64.urldecode(base64Url);
+ $rootScope.loadPromise = newUrlDownload(url);
+ } else {
+ ariaNgCommonService.error('Parameter is invalid!');
+ }
+ }]);
+})();
diff --git a/src/scripts/core/router.js b/src/scripts/core/router.js
index 42691ea..be18800 100644
--- a/src/scripts/core/router.js
+++ b/src/scripts/core/router.js
@@ -19,6 +19,10 @@
templateUrl: 'views/new.html',
controller: 'NewTaskController'
})
+ .when('/new/:url', {
+ template: '',
+ controller: 'CommandController'
+ })
.when('/task/detail/:gid', {
templateUrl: 'views/task-detail.html',
controller: 'TaskDetailController'
diff --git a/src/scripts/services/aria2RpcService.js b/src/scripts/services/aria2RpcService.js
index a3d4ba5..46c2ea4 100644
--- a/src/scripts/services/aria2RpcService.js
+++ b/src/scripts/services/aria2RpcService.js
@@ -164,23 +164,25 @@
return requestParams;
},
addUri: function (context) {
- return invoke(buildRequestContext('addUri', context, context.urls, context.options));
+ var urls = context.task.urls;
+ var options = angular.copy(context.task.options);
+
+ if (context.pauseOnAdded) {
+ options.pause = 'true';
+ }
+
+ return invoke(buildRequestContext('addUri', context, urls, options));
},
addUriMulti: function (context) {
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: task.urls,
- options: options
+ task: task,
+ pauseOnAdded: context.pauseOnAdded
});
}
diff --git a/src/scripts/services/aria2TaskService.js b/src/scripts/services/aria2TaskService.js
index 4b39778..fe59343 100644
--- a/src/scripts/services/aria2TaskService.js
+++ b/src/scripts/services/aria2TaskService.js
@@ -258,6 +258,14 @@
}
});
},
+ newUriTask: function (task, pauseOnAdded, callback, silent) {
+ return aria2RpcService.addUri({
+ task: task,
+ pauseOnAdded: !!pauseOnAdded,
+ silent: !!silent,
+ callback: callback
+ });
+ },
newUriTasks: function (tasks, pauseOnAdded, callback, silent) {
return aria2RpcService.addUriMulti({
tasks: tasks,