Add upload torrent by url to web interface

This commit is contained in:
Duncan Beevers 2009-01-20 03:41:19 +00:00
parent 69404a8c36
commit f00619bab7
4 changed files with 27 additions and 13 deletions

View File

@ -255,8 +255,10 @@
<form action="#" method="post" id="torrent_upload_form"
enctype="multipart/form-data" target="torrent_upload_frame">
<div class="dialog_message">
Please select a torrent file to upload:
<label for="torrent_upload_file">Please select a torrent file to upload:</label>
<input type="file" name="torrent_file" id="torrent_upload_file"/>
<label for="torrent_upload_url">Or enter a URL:</label>
<input type="text" id="torrent_upload_url"/>
</div>
<a href="#upload" id="upload_confirm_button">Upload</a>
<a href="#cancel" id="upload_cancel_button">Cancel</a>

View File

@ -1164,16 +1164,20 @@ Transmission.prototype =
} else {
var tr = this;
var args = { };
args.url = '/transmission/upload?paused=' + (this[Prefs._AutoStart] ? 'false' : 'true');
args.type = 'POST';
args.dataType = 'xml';
args.iframe = true;
args.success = function( data ) {
tr.remote.loadTorrents( );
tr.togglePeriodicRefresh( true );
};
this.togglePeriodicRefresh( false );
$('#torrent_upload_form').ajaxSubmit( args );
if ('' != $('#torrent_upload_url').val()) {
tr.remote.addTorrentByUrl($('#torrent_upload_url').val(), { paused: !this[Prefs._Autostart] });
} else {
args.url = '/transmission/upload?paused=' + (this[Prefs._AutoStart] ? 'false' : 'true');
args.type = 'POST';
args.dataType = 'xml';
args.iframe = true;
args.success = function( data ) {
tr.remote.loadTorrents( );
tr.togglePeriodicRefresh( true );
};
this.togglePeriodicRefresh( false );
$('#torrent_upload_form').ajaxSubmit( args );
}
}
},

View File

@ -121,7 +121,15 @@ TransmissionRemote.prototype =
removeTorrents: function( torrents ) {
this.sendTorrentCommand( 'torrent-remove', torrents );
},
addTorrentByUrl: function( url, options ) {
this.sendRequest( RPC._Root, $.toJSON({
method: 'torrent-add',
arguments: {
paused: (options.paused ? 'true' : 'false'),
filename: url
}
}) );
},
savePrefs: function( args ) {
var remote = this;
var o = { };

View File

@ -726,7 +726,7 @@ div#upload_container div.dialog_window div.dialog_message label {
div#upload_container div.dialog_window div.dialog_message input {
width: 249px;
margin: 10px 0 0 0;
margin: 3px 0 0 0;
display: block;
}