This repository has been archived on 2022-01-02. You can view files and clone it, but cannot push or open issues/pull-requests.
AriaNg/src/scripts/controllers/command.js

30 lines
1.1 KiB
JavaScript

(function () {
'use strict';
angular.module('ariaNg').controller('CommandController', ['$rootScope', '$location', '$routeParams', 'base64', 'ariaNgCommonService', 'aria2TaskService', 'ariaNgLogService', function ($rootScope, $location, $routeParams, base64, ariaNgCommonService, aria2TaskService, ariaNgLogService) {
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);
ariaNgLogService.info('[CommandController] new download: ' + url);
} else {
ariaNgCommonService.error('Parameter is invalid!');
}
}]);
}());