diff --git a/index.html b/index.html index acb7d30..f5b4a63 100755 --- a/index.html +++ b/index.html @@ -351,6 +351,13 @@ + + + + diff --git a/js/ctrls/main.js b/js/ctrls/main.js index 3fb2068..63858f3 100644 --- a/js/ctrls/main.js +++ b/js/ctrls/main.js @@ -36,6 +36,38 @@ function( rpc.once('unpause', [d.gid]); } + scope.restart = function(d) { + // assumes downloads which are started by URIs, not torrents. + // the preferences are also not transferred, just simple restart + + rpc.once('getFiles', [d.gid], function(data) { + var files = data[0]; + var uris = + _.chain(files).map(function(f) { return f.uris }) + .filter(function(uris) { return uris && uris.length }) + .map(function(uris) { + var u = _.chain(uris) + .map(function(u) { return u.uri }) + .uniq().value(); + return u; + }).value(); + + if (uris.length > 0) { + console.log('adding uris:', uris); + scope.remove(d, function() { + rpc.once('addUri', uris, angular.noop, true); + }, true); + } + }); + } + + + + scope.canRestart = function(d) { + return (['active', 'paused'].indexOf(d.status) == -1 + && !d.bittorrent); + } + // remove the download, // put it in stopped list if active, // otherwise permanantly remove it @@ -44,6 +76,7 @@ function( if (!noConfirm && !confirm("Remove %s and associated meta-data?".replace("%s", d.name))) { return; } + var method = 'remove'; if (scope.getType(d) == 'stopped') @@ -56,7 +89,7 @@ function( rpc.once(method, [d.gid], cb); } - // start filling in the model of active, +// start filling in the model of active, // waiting and stopped download rpc.subscribe('tellActive', [], function(data) { scope.$apply(function() { diff --git a/js/ctrls/modal.js b/js/ctrls/modal.js index 7886f6c..08ecc8b 100644 --- a/js/ctrls/modal.js +++ b/js/ctrls/modal.js @@ -74,7 +74,7 @@ angular }, parse: function() { return _ - .chain(this.uris.trim().split(/\n\r?/g)) + .chain(this.uris.trim().split(/\r?\n/g)) .map(function(d) { return d.trim().split(/\s+/g) }) .filter(function(d) { return d.length }) .value();