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" <form action="#" method="post" id="torrent_upload_form"
enctype="multipart/form-data" target="torrent_upload_frame"> enctype="multipart/form-data" target="torrent_upload_frame">
<div class="dialog_message"> <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"/> <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> </div>
<a href="#upload" id="upload_confirm_button">Upload</a> <a href="#upload" id="upload_confirm_button">Upload</a>
<a href="#cancel" id="upload_cancel_button">Cancel</a> <a href="#cancel" id="upload_cancel_button">Cancel</a>

View File

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

View File

@ -121,7 +121,15 @@ TransmissionRemote.prototype =
removeTorrents: function( torrents ) { removeTorrents: function( torrents ) {
this.sendTorrentCommand( 'torrent-remove', 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 ) { savePrefs: function( args ) {
var remote = this; var remote = this;
var o = { }; 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 { div#upload_container div.dialog_window div.dialog_message input {
width: 249px; width: 249px;
margin: 10px 0 0 0; margin: 3px 0 0 0;
display: block; display: block;
} }