2014-03-10 01:18:05 -04:00
$ ( document ) . ready ( function ( ) {
2014-10-28 22:55:59 -04:00
var loading = '<img src="' + sbRoot + '/images/loading16' + themeSpinner + '.gif" height="16" width="16" />' ;
function toggle _torrent _title ( ) {
if ( $ ( '#use_torrents' ) . prop ( 'checked' ) )
$ ( '#no_torrents' ) . show ( ) ;
else
$ ( '#no_torrents' ) . hide ( ) ;
}
2014-03-20 14:03:22 -04:00
$ . fn . nzb _method _handler = function ( ) {
2014-10-28 22:55:59 -04:00
var selectedProvider = $ ( '#nzb_method :selected' ) . val ( ) ,
blackhole _settings = '#blackhole_settings' ,
sabnzbd _settings = '#sabnzbd_settings' ,
testSABnzbd = '#testSABnzbd' ,
testSABnzbd _result = '#testSABnzbd_result' ,
nzbget _settings = '#nzbget_settings' ;
$ ( blackhole _settings ) . hide ( ) ;
$ ( sabnzbd _settings ) . hide ( ) ;
$ ( testSABnzbd ) . hide ( ) ;
$ ( testSABnzbd _result ) . hide ( ) ;
$ ( nzbget _settings ) . hide ( ) ;
if ( 'blackhole' == selectedProvider ) {
$ ( blackhole _settings ) . show ( ) ;
} else if ( 'nzbget' == selectedProvider ) {
$ ( nzbget _settings ) . show ( ) ;
2014-03-10 01:18:05 -04:00
} else {
2014-10-28 22:55:59 -04:00
$ ( sabnzbd _settings ) . show ( ) ;
$ ( testSABnzbd ) . show ( ) ;
$ ( testSABnzbd _result ) . show ( ) ;
2014-03-10 01:18:05 -04:00
}
2014-03-20 14:03:22 -04:00
}
2014-03-10 01:18:05 -04:00
2014-03-20 14:03:22 -04:00
$ . fn . torrent _method _handler = function ( ) {
2014-10-28 22:55:59 -04:00
$ ( '#options_torrent_clients' ) . hide ( ) ;
$ ( '#options_torrent_blackhole' ) . hide ( ) ;
var selectedProvider = $ ( '#torrent_method :selected' ) . val ( ) ,
host = ' host:port' ,
username = ' username' ,
password = ' password' ,
label = ' label' ,
directory = ' directory' ,
client = '' ,
option _panel = '#options_torrent_blackhole' ;
2015-01-26 14:52:18 -05:00
rpcurl = ' RPC URL'
2014-10-28 22:55:59 -04:00
if ( 'blackhole' != selectedProvider ) {
var label _warning _deluge = '#label_warning_deluge' ,
2014-11-26 15:48:37 -05:00
label _anime _warning _deluge = '#label_anime_warning_deluge' ,
2014-10-28 22:55:59 -04:00
host _desc _rtorrent = '#host_desc_rtorrent' ,
host _desc _torrent = '#host_desc_torrent' ,
torrent _verify _cert _option = '#torrent_verify_cert_option' ,
torrent _path _option = '#torrent_path_option' ,
torrent _seed _time _option = '#torrent_seed_time_option' ,
torrent _high _bandwidth _option = '#torrent_high_bandwidth_option' ,
torrent _label _option = '#torrent_label_option' ,
2014-11-26 15:48:37 -05:00
torrent _label _anime _option = '#torrent_label_anime_option' ,
2014-10-28 22:55:59 -04:00
path _synology = '#path_synology' ,
torrent _paused _option = '#torrent_paused_option' ;
$ ( label _warning _deluge ) . hide ( ) ;
2014-11-26 15:48:37 -05:00
$ ( label _anime _warning _deluge ) . hide ( ) ;
$ ( label _anime _warning _deluge ) . hide ( ) ;
2014-10-28 22:55:59 -04:00
$ ( host _desc _rtorrent ) . hide ( ) ;
$ ( host _desc _torrent ) . show ( ) ;
$ ( torrent _verify _cert _option ) . hide ( ) ;
2015-01-29 23:53:29 -05:00
$ ( torrent _verify _deluge ) . hide ( ) ;
$ ( torrent _verify _rtorrent ) . hide ( ) ;
$ ( torrent _auth _type ) . hide ( ) ;
2014-10-28 22:55:59 -04:00
$ ( torrent _path _option ) . show ( ) ;
$ ( torrent _path _option ) . find ( '.fileBrowser' ) . show ( ) ;
$ ( torrent _seed _time _option ) . hide ( ) ;
$ ( torrent _high _bandwidth _option ) . hide ( ) ;
$ ( torrent _label _option ) . show ( ) ;
2014-11-26 15:48:37 -05:00
$ ( torrent _label _anime _option ) . show ( ) ;
2014-10-28 22:55:59 -04:00
$ ( path _synology ) . hide ( ) ;
$ ( torrent _paused _option ) . show ( ) ;
2015-01-26 12:19:16 -05:00
$ ( torrent _rpcurl _option ) . hide ( ) ;
2014-10-28 22:55:59 -04:00
if ( 'utorrent' == selectedProvider ) {
client = 'uTorrent' ;
$ ( torrent _path _option ) . hide ( ) ;
$ ( torrent _seed _time _option ) . show ( ) ;
2015-02-02 21:27:29 -05:00
$ ( '#host_desc_torrent' ) . text ( 'URL to your uTorrent client (e.g. http://localhost:8000)' ) ;
2014-10-28 22:55:59 -04:00
} else if ( 'transmission' == selectedProvider ) {
client = 'Transmission' ;
$ ( torrent _seed _time _option ) . show ( ) ;
$ ( torrent _high _bandwidth _option ) . show ( ) ;
$ ( torrent _label _option ) . hide ( ) ;
2014-11-26 15:48:37 -05:00
$ ( torrent _label _anime _option ) . hide ( ) ;
2015-01-26 12:19:16 -05:00
$ ( torrent _rpcurl _option ) . show ( ) ;
2015-02-02 21:27:29 -05:00
$ ( '#host_desc_torrent' ) . text ( 'URL to your Transmission client (e.g. http://localhost:9091)' ) ;
2014-10-28 22:55:59 -04:00
//$('#directory_title').text(client + directory);
} else if ( 'deluge' == selectedProvider ) {
client = 'Deluge' ;
$ ( torrent _verify _cert _option ) . show ( ) ;
2015-01-29 23:53:29 -05:00
$ ( torrent _verify _deluge ) . show ( ) ;
$ ( torrent _verify _rtorrent ) . hide ( ) ;
2014-10-28 22:55:59 -04:00
$ ( label _warning _deluge ) . show ( ) ;
2014-11-26 15:48:37 -05:00
$ ( label _anime _warning _deluge ) . show ( ) ;
2015-02-02 21:27:29 -05:00
$ ( '#host_desc_torrent' ) . text ( 'URL to your Deluge client (e.g. http://localhost:8112)' ) ;
2014-10-28 22:55:59 -04:00
//$('#directory_title').text(client + directory);
} else if ( 'download_station' == selectedProvider ) {
client = 'Synology DS' ;
$ ( torrent _label _option ) . hide ( ) ;
2014-11-26 15:48:37 -05:00
$ ( torrent _label _anime _option ) . hide ( ) ;
2014-10-28 22:55:59 -04:00
$ ( '#torrent_paused_option' ) . hide ( ) ;
$ ( torrent _path _option ) . find ( '.fileBrowser' ) . hide ( ) ;
2015-02-02 21:27:29 -05:00
$ ( '#host_desc_torrent' ) . text ( 'URL to your Synology DS client (e.g. http://localhost:5000)' ) ;
2014-10-28 22:55:59 -04:00
//$('#directory_title').text(client + directory);
$ ( path _synology ) . show ( ) ;
} else if ( 'rtorrent' == selectedProvider ) {
client = 'rTorrent' ;
$ ( torrent _paused _option ) . hide ( ) ;
2015-02-02 21:27:29 -05:00
$ ( '#host_desc_torrent' ) . text ( 'URL to your rTorrent client (e.g. scgi://localhost:5000 </br> or https://localhost/rutorrent/plugins/httprpc/action.php)' ) ;
2015-01-29 23:53:29 -05:00
$ ( torrent _verify _cert _option ) . show ( ) ;
$ ( torrent _verify _deluge ) . hide ( ) ;
$ ( torrent _verify _rtorrent ) . show ( ) ;
$ ( torrent _auth _type ) . show ( ) ;
2014-10-28 22:55:59 -04:00
//$('#directory_title').text(client + directory);
}
$ ( '#host_title' ) . text ( client + host ) ;
$ ( '#username_title' ) . text ( client + username ) ;
$ ( '#password_title' ) . text ( client + password ) ;
$ ( '#torrent_client' ) . text ( client ) ;
2015-01-26 14:52:18 -05:00
$ ( '#rpcurl_title' ) . text ( client + rpcurl ) ;
2014-10-28 22:55:59 -04:00
option _panel = '#options_torrent_clients' ;
2014-03-10 01:18:05 -04:00
}
2014-10-28 22:55:59 -04:00
$ ( option _panel ) . show ( ) ;
2014-03-20 14:03:22 -04:00
}
2014-03-10 01:18:05 -04:00
$ ( '#nzb_method' ) . change ( $ ( this ) . nzb _method _handler ) ;
$ ( this ) . nzb _method _handler ( ) ;
$ ( '#testSABnzbd' ) . click ( function ( ) {
2014-10-28 22:55:59 -04:00
$ ( '#testSABnzbd_result' ) . html ( loading ) ;
2014-03-10 01:18:05 -04:00
var sab _host = $ ( '#sab_host' ) . val ( ) ;
var sab _username = $ ( '#sab_username' ) . val ( ) ;
var sab _password = $ ( '#sab_password' ) . val ( ) ;
var sab _apiKey = $ ( '#sab_apikey' ) . val ( ) ;
2014-10-28 22:55:59 -04:00
$ . get ( sbRoot + '/home/testSABnzbd' , { 'host' : sab _host , 'username' : sab _username , 'password' : sab _password , 'apikey' : sab _apiKey } ,
function ( data ) { $ ( '#testSABnzbd_result' ) . html ( data ) ; } ) ;
2014-03-10 01:18:05 -04:00
} ) ;
2014-10-28 22:55:59 -04:00
2014-03-10 01:18:05 -04:00
$ ( '#torrent_method' ) . change ( $ ( this ) . torrent _method _handler ) ;
2014-10-28 22:55:59 -04:00
$ ( this ) . torrent _method _handler ( ) ;
2014-03-10 01:18:05 -04:00
$ ( '#use_torrents' ) . click ( function ( ) {
2014-10-28 22:55:59 -04:00
toggle _torrent _title ( ) ;
2014-03-10 01:18:05 -04:00
} ) ;
2014-10-28 22:55:59 -04:00
$ ( '#test_torrent' ) . click ( function ( ) {
$ ( '#test_torrent_result' ) . html ( loading ) ;
var torrent _method = $ ( '#torrent_method :selected' ) . val ( ) ;
2014-03-10 01:18:05 -04:00
var torrent _host = $ ( '#torrent_host' ) . val ( ) ;
var torrent _username = $ ( '#torrent_username' ) . val ( ) ;
var torrent _password = $ ( '#torrent_password' ) . val ( ) ;
2014-10-28 22:55:59 -04:00
$ . get ( sbRoot + '/home/testTorrent' , { 'torrent_method' : torrent _method , 'host' : torrent _host , 'username' : torrent _username , 'password' : torrent _password } ,
function ( data ) { $ ( '#test_torrent_result' ) . html ( data ) ; } ) ;
2014-03-10 01:18:05 -04:00
} ) ;
} ) ;