Browse Source
* Prepare http server and preferences classes to add new settings to Web UI * Tabified Program preferences in Web UI since there will be a lot of settings soon * Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing * Added a command line parameter to change the web ui port * Fix PeerGuardian .p2b binary filter supportadaptive-webui-19844
Christophe Dumez
15 years ago
72 changed files with 20180 additions and 8826 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,614 @@ |
|||||||
|
<div id="ConnectionTab" class="PrefTab"> |
||||||
|
<fieldset> |
||||||
|
<legend><b>_(Listening port)</b></legend> |
||||||
|
<div style="padding-left: 30px;"> |
||||||
|
_(Port used for incoming connections:) |
||||||
|
<input type="text" id="port_value" style="width: 4em;"/> |
||||||
|
<br/> |
||||||
|
<table> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom;"><input type="checkbox" id="upnp_checkbox" style="margin-bottom: -2px;"/></td><td>_(Enable UPnP port mapping)</td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom;"><input type="checkbox" id="natpmp_checkbox" style="margin-bottom: -2px;"/></td><td>_(Enable NAT-PMP port mapping)</td> |
||||||
|
</tr> |
||||||
|
</table> |
||||||
|
</div> |
||||||
|
</fieldset> |
||||||
|
<fieldset> |
||||||
|
<legend><b>_(Connections limit)</b></legend> |
||||||
|
<div style="padding-left: 30px;"> |
||||||
|
<table> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom;"><input type="checkbox" id="max_connec_checkbox" onClick="updateMaxConnecEnabled();"/></td><td style="padding-right: 3px;">_(Global maximum number of connections:)</td><td><input type="text" id="max_connec_value" style="width: 4em;"/></td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom;"><input type="checkbox" id="max_connec_per_torrent_checkbox" onClick="updateMaxConnecPerTorrentEnabled();" style="margin-bottom: -2px;"/></td><td style="padding-right: 3px;">_(Maximum number of connections per torrent:)</td><td><input type="text" id="max_connec_per_torrent_value" style="width: 4em;"/></td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom;"><input type="checkbox" id="max_uploads_per_torrent_checkbox" onClick="updateMaxUploadsPerTorrentEnabled();" style="margin-bottom: -2px;"/></td><td style="padding-right: 3px;">_(Maximum number of upload slots per torrent:)</td><td><input type="text" id="max_uploads_per_torrent_value" style="width: 4em;"/></td> |
||||||
|
</tr> |
||||||
|
</table> |
||||||
|
</div> |
||||||
|
</fieldset> |
||||||
|
<fieldset> |
||||||
|
<legend><b>_(Global bandwidth limiting)</b></legend> |
||||||
|
<div style="padding-left: 30px;"> |
||||||
|
<table> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom;"><input type="checkbox" id="up_limit_checkbox" onClick="updateUpLimitEnabled();"/></td><td style="padding-right: 3px;">_(Upload:)</td><td><input type="text" id="up_limit_value" style="width: 4em;"/> _(KiB/s)</td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom;"><input type="checkbox" id="dl_limit_checkbox" onClick="updateDlLimitEnabled();"/></td><td style="padding-right: 3px;">_(Download:)</td><td><input type="text" id="dl_limit_value" style="width: 4em;"/> _(KiB/s)</td> |
||||||
|
</tr> |
||||||
|
</table> |
||||||
|
</div> |
||||||
|
</fieldset> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div id="BittorrentTab" class="PrefTab invisible"> |
||||||
|
<fieldset> |
||||||
|
<legend><b>_(Bittorrent features)</b></legend> |
||||||
|
<div style="padding-left: 30px;"> |
||||||
|
<table> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom; text-align: right;"><input type="checkbox" id="dht_checkbox"/></td><td>_(Enable DHT network (decentralized))</td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom; text-align: right;"><input type="checkbox" id="pex_checkbox"/></td><td>_(Enable Peer Exchange / PeX (requires restart))</td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom; text-align: right;"><input type="checkbox" id="lsd_checkbox"/></td><td>_(Enable Local Peer Discovery)</td> |
||||||
|
</tr> |
||||||
|
</table> |
||||||
|
_(Encryption:) |
||||||
|
<select id="encryption_select"> |
||||||
|
<option value="0">_(Enabled)</option> |
||||||
|
<option value="1">_(Forced)</option> |
||||||
|
<option value="2">_(Disabled)</option> |
||||||
|
</select><br/> |
||||||
|
</div> |
||||||
|
</fieldset> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div id="DownloadsTab" class="PrefTab invisible"> |
||||||
|
<fieldset> |
||||||
|
<legend><b>_(File system)</b></legend> |
||||||
|
<div style="padding-left: 30px;"> |
||||||
|
<table> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom; text-align: right;">_(Destination Folder:)</td><td><input type="text" id="savepath_text"/></td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom; text-align: right;"><input type="checkbox" id="temppath_checkbox" onclick="updateTempDirEnabled();"/></td><td>_(Use a different folder for incomplete downloads:)</td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom; text-align: right;"></td><td><input type="text" id="temppath_text"/></td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom; text-align: right;"><input type="checkbox" id="scandir_checkbox" onclick="updateScanDirEnabled();"/></td><td>_(Automatically load .torrent files from:)</td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom; text-align: right;"></td><td><input type="text" id="scandir_text"/></td> |
||||||
|
</tr> |
||||||
|
<tr id="appendexttr"> |
||||||
|
<td style="vertical-align: bottom; text-align: right;"><input type="checkbox" id="appendext_checkbox"/></td><td>_(Append .!qB extension to incomplete files)</td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom; text-align: right;"><input type="checkbox" id="preallocateall_checkbox"/></td><td>_(Pre-allocate all files)</td> |
||||||
|
</tr> |
||||||
|
</table> |
||||||
|
</div> |
||||||
|
</fieldset> |
||||||
|
<fieldset> |
||||||
|
<legend><b>_(Torrent queueing)</b></legend> |
||||||
|
<div style="padding-left: 30px;"> |
||||||
|
<table> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom; text-align: right;"><input type="checkbox" id="queueing_checkbox" onclick="updateQueuingSystem();"/></td><td>_(Enable queueing system)</td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom; text-align: right;">_(Maximum active downloads:)</td><td><input type="text" id="max_active_dl_value" style="width: 4em;"/></td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom; text-align: right;">_(Maximum active uploads:)</td><td><input type="text" id="max_active_up_value" style="width: 4em;"/></td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom; text-align: right;">_(Maximum active torrents:)</td><td><input type="text" id="max_active_to_value" style="width: 4em;"/></td> |
||||||
|
</tr> |
||||||
|
</table> |
||||||
|
</div> |
||||||
|
</fieldset> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div id="FilterTab" class="PrefTab invisible"> |
||||||
|
<legend><b>_(Filter Settings)</b></legend> |
||||||
|
<div style="padding-left: 30px;"> |
||||||
|
<input type="checkbox" id="ipfilter_enabled_checkbox" onclick="updateFilterSettings();"/> _(Activate IP Filtering) |
||||||
|
<table> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom;">_(Filter path (.dat, .p2p, .p2b):)</td><td><input type="text" id="ipfilter_text"/></td> |
||||||
|
</tr> |
||||||
|
</table> |
||||||
|
</div> |
||||||
|
</fieldset> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div id="ProxyTab" class="PrefTab invisible"> |
||||||
|
Not implemented yet. |
||||||
|
<!-- TODO --> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div id="WebUITab" class="PrefTab invisible"> |
||||||
|
<fieldset> |
||||||
|
<legend><b>_(User interface)</b></legend> |
||||||
|
<div style="padding-left: 30px;"> |
||||||
|
<table> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom;">_(Language:)</td> |
||||||
|
<td style="padding-right: 3px;"> |
||||||
|
<select id="locale_select"> |
||||||
|
<option value="en_GB" style="background-image: url(Icons/flags/united_kingdom.png) no-repeat;">English</option> |
||||||
|
<option value="fr_FR" style="background-image: url(Icons/flags/france.png) no-repeat;">Français</option> |
||||||
|
<option value="de_DE" style="background-image: url(Icons/flags/germany.png) no-repeat;">Deutsch</option> |
||||||
|
<option value="hu_HU" style="background-image: url(Icons/flags/hungary.png) no-repeat;">Magyar</option> |
||||||
|
<option value="it_IT" style="background-image: url(Icons/flags/italy.png) no-repeat;">Italiano</option> |
||||||
|
<option value="nl_NL" style="background-image: url(Icons/flags/netherlands.png) no-repeat;">Nederlands</option> |
||||||
|
<option value="es_ES" style="background-image: url(Icons/flags/spain.png) no-repeat;">Español</option> |
||||||
|
<option value="ca_ES" style="background-image: url(Icons/flags/spain_catalunya.png) no-repeat;">Català</option> |
||||||
|
<option value="pt_PT" style="background-image: url(Icons/flags/portugal.png) no-repeat;">Português</option> |
||||||
|
<option value="pt_BR" style="background-image: url(Icons/flags/brazil.png) no-repeat;">Português brasileiro</option> |
||||||
|
<option value="pl_PL" style="background-image: url(Icons/flags/poland.png) no-repeat;">Polski</option> |
||||||
|
<option value="cs_CZ" style="background-image: url(Icons/flags/czech.png) no-repeat;">Čeština</option> |
||||||
|
<option value="sk_SK" style="background-image: url(Icons/flags/slovakia.png) no-repeat;">Slovenčina</option> |
||||||
|
<option value="sr_CS" style="background-image: url(Icons/flags/serbia.png) no-repeat;">Српски</option> |
||||||
|
<option value="ro_RO" style="background-image: url(Icons/flags/romania.png) no-repeat;">Română</option> |
||||||
|
<option value="tr_TR" style="background-image: url(Icons/flags/turkey.png) no-repeat;">Türkçe</option> |
||||||
|
<option value="el_GR" style="background-image: url(Icons/flags/greece.png) no-repeat;">Ελληνικά</option> |
||||||
|
<option value="sv_SE" style="background-image: url(Icons/flags/sweden.png) no-repeat;">Svenska</option> |
||||||
|
<option value="fi_FI" style="background-image: url(Icons/flags/finland.png) no-repeat;">Suomi</option> |
||||||
|
<option value="nb_NO" style="background-image: url(Icons/flags/norway.png) no-repeat;">Norsk</option> |
||||||
|
<option value="da_DK" style="background-image: url(Icons/flags/denmark.png) no-repeat;">Dansk</option> |
||||||
|
<option value="bg_BG" style="background-image: url(Icons/flags/bulgaria.png) no-repeat;">Български</option> |
||||||
|
<option value="uk_UA" style="background-image: url(Icons/flags/ukraine.png) no-repeat;">Українська</option> |
||||||
|
<option value="ru_RU" style="background-image: url(Icons/flags/russia.png) no-repeat;">Русский</option> |
||||||
|
<option value="ja_JP" style="background-image: url(Icons/flags/japan.png) no-repeat;">日本語</option> |
||||||
|
<option value="zh_CN" style="background-image: url(Icons/flags/china.png) no-repeat;">中文 (简体)</option> |
||||||
|
<option value="zh_TW" style="background-image: url(Icons/flags/taiwan.png) no-repeat;">中文 (繁體)</option> |
||||||
|
<option value="ko_KR" style="background-image: url(Icons/flags/south_korea.png) no-repeat;">한글"</option> |
||||||
|
</select> |
||||||
|
</td> |
||||||
|
</tr> |
||||||
|
</table> |
||||||
|
</div> |
||||||
|
</fieldset> |
||||||
|
|
||||||
|
<fieldset> |
||||||
|
<legend><b>_(HTTP Server)</b></legend> |
||||||
|
<div style="padding-left: 30px;"> |
||||||
|
<table> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom;">_(Port:)</td><td style="padding-right: 3px;"><input type="text" id="webui_port_value" style="width: 4em;"/></td> |
||||||
|
</tr> |
||||||
|
</table> |
||||||
|
</div> |
||||||
|
</fieldset> |
||||||
|
<fieldset> |
||||||
|
<legend><b>_(Authentication)</b></legend> |
||||||
|
<div style="padding-left: 30px;"> |
||||||
|
<table> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom;">_(Username:)</td><td style="padding-right: 3px;"><input type="text" id="webui_username_text" /></td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td style="vertical-align: bottom;">_(Password:)</td><td style="padding-right: 3px;"><input type="password" id="webui_password_text" /></td> |
||||||
|
</tr> |
||||||
|
</table> |
||||||
|
</div> |
||||||
|
</fieldset> |
||||||
|
</div> |
||||||
|
|
||||||
|
<br/> |
||||||
|
<center><input type="button" value="_(Apply)" onclick="applyPreferences();"/></center> |
||||||
|
|
||||||
|
<script type="text/javascript"> |
||||||
|
applyPreferences = function() { |
||||||
|
// Validate form data |
||||||
|
// Connection |
||||||
|
var listen_port = $('port_value').get('value').toInt(); |
||||||
|
if(listen_port <= 1024 || listen_port > 65535) { |
||||||
|
alert("_(The port used for incoming connections must be greater than 1024 and less than 65535.)"); |
||||||
|
return; |
||||||
|
} |
||||||
|
var upnp = 0; |
||||||
|
if($defined($('upnp_checkbox').get('checked')) && $('upnp_checkbox').get('checked')) |
||||||
|
upnp = 1; |
||||||
|
var natpmp = 0; |
||||||
|
if($defined($('natpmp_checkbox').get('checked')) && $('natpmp_checkbox').get('checked')) |
||||||
|
natpmp = 1; |
||||||
|
|
||||||
|
var dl_limit = -1; |
||||||
|
if($defined($('dl_limit_checkbox').get('checked')) && $('dl_limit_checkbox').get('checked')) { |
||||||
|
dl_limit = $('dl_limit_value').get('value'); |
||||||
|
if(dl_limit <= 0) { |
||||||
|
alert("_(Download rate limit must be greater than 0 or disabled.)"); |
||||||
|
return; |
||||||
|
} |
||||||
|
} |
||||||
|
var up_limit = -1; |
||||||
|
if($defined($('up_limit_checkbox').get('checked')) && $('up_limit_checkbox').get('checked')) { |
||||||
|
up_limit = $('up_limit_value').get('value'); |
||||||
|
if(up_limit <= 0) { |
||||||
|
alert("_(Upload rate limit must be greater than 0 or disabled.)"); |
||||||
|
return; |
||||||
|
} |
||||||
|
} |
||||||
|
var max_connec = -1; |
||||||
|
if($defined($('max_connec_checkbox').get('checked')) && $('max_connec_checkbox').get('checked')) { |
||||||
|
max_connec = $('max_connec_value').get('value'); |
||||||
|
if(max_connec <= 0) { |
||||||
|
alert("_(Maximum number of connections limit must be greater than 0 or disabled.)"); |
||||||
|
return; |
||||||
|
} |
||||||
|
} |
||||||
|
var max_connec_per_torrent = -1; |
||||||
|
if($defined($('max_connec_per_torrent_checkbox').get('checked')) && $('max_connec_per_torrent_checkbox').get('checked')) { |
||||||
|
max_connec_per_torrent = $('max_connec_per_torrent_value').get('value'); |
||||||
|
if(max_connec_per_torrent <= 0) { |
||||||
|
alert("_(Maximum number of connections per torrent limit must be greater than 0 or disabled.)"); |
||||||
|
return; |
||||||
|
} |
||||||
|
} |
||||||
|
var max_uploads_per_torrent = -1; |
||||||
|
if($defined($('max_uploads_per_torrent_checkbox').get('checked')) && $('max_uploads_per_torrent_checkbox').get('checked')) { |
||||||
|
max_uploads_per_torrent = $('max_uploads_per_torrent_value').get('value'); |
||||||
|
if(max_uploads_per_torrent <= 0) { |
||||||
|
alert("_(Maximum number of upload slots per torrent limit must be greater than 0 or disabled.)"); |
||||||
|
return; |
||||||
|
} |
||||||
|
} |
||||||
|
// Bittorrent |
||||||
|
var dht = 0; |
||||||
|
if($defined($('dht_checkbox').get('checked')) && $('dht_checkbox').get('checked')) |
||||||
|
dht = 1; |
||||||
|
var pex = 0; |
||||||
|
if($defined($('pex_checkbox').get('checked')) && $('pex_checkbox').get('checked')) |
||||||
|
pex = 1; |
||||||
|
var lsd = 0; |
||||||
|
if($defined($('lsd_checkbox').get('checked')) && $('lsd_checkbox').get('checked')) |
||||||
|
lsd = 1; |
||||||
|
// Downloads |
||||||
|
var save_path = $("savepath_text").get('value'); |
||||||
|
var temp_path_enabled = 0 |
||||||
|
if($defined($('temppath_checkbox').get('checked')) && $('temppath_checkbox').get('checked')) |
||||||
|
temp_path_enabled = 1; |
||||||
|
var temp_path = $('temppath_text').get('value'); |
||||||
|
var scandir_enabled = 0; |
||||||
|
if($defined($('scandir_checkbox').get('checked')) && $('scandir_checkbox').get('checked')) |
||||||
|
scandir_enabled = 1; |
||||||
|
var scandir_path = ''; |
||||||
|
if(scandir_enabled) |
||||||
|
scandir_path = $('scandir_text').get('value'); |
||||||
|
var preallocate_all = 0; |
||||||
|
if($defined($('preallocateall_checkbox').get('checked')) && $('preallocateall_checkbox').get('checked')) |
||||||
|
preallocate_all = 1; |
||||||
|
if(!$('appendexttr').hasClass('invisible')) { |
||||||
|
var incomplete_files_ext = 0; |
||||||
|
if($defined($('appendext_checkbox').get('checked')) && $('appendext_checkbox').get('checked')) |
||||||
|
incomplete_files_ext = 1; |
||||||
|
} |
||||||
|
var queueing_enabled = 0; |
||||||
|
if($defined($('queueing_checkbox').get('checked')) && $('queueing_checkbox').get('checked')) |
||||||
|
queueing_enabled = 1; |
||||||
|
var max_active_downloads = $('max_active_dl_value').get('value'); |
||||||
|
var max_active_uploads = $('max_active_up_value').get('value'); |
||||||
|
var max_active_torrents = $('max_active_to_value').get('value'); |
||||||
|
// IP Filter |
||||||
|
var ip_filter_enabled = 0; |
||||||
|
if($defined($('ipfilter_enabled_checkbox').get('checked')) && $('ipfilter_enabled_checkbox').get('checked')) |
||||||
|
ip_filter_enabled = 1; |
||||||
|
var ip_filter_path = $('ipfilter_text').get('value'); |
||||||
|
// Web UI |
||||||
|
var webui_port = $('webui_port_value').get('value').toInt(); |
||||||
|
if(webui_port <= 1024 || webui_port > 65535) { |
||||||
|
alert("_(The port used for the Web UI must be greater than 1024 and less than 65535.)"); |
||||||
|
return; |
||||||
|
} |
||||||
|
var webui_username = $('webui_username_text').get('value'); |
||||||
|
var webui_password = $('webui_password_text').get('value'); |
||||||
|
// Add some username/password length checking |
||||||
|
if(webui_username.length < 3) { |
||||||
|
alert("_(The Web UI username must be at least 3 characters long.)"); |
||||||
|
return; |
||||||
|
} |
||||||
|
if(webui_password.length < 3) { |
||||||
|
alert("_(The Web UI password must be at least 3 characters long.)"); |
||||||
|
return; |
||||||
|
} |
||||||
|
var locale = $('locale_select').get('value'); |
||||||
|
|
||||||
|
// Send it to qBT |
||||||
|
var dict = new Hash(); |
||||||
|
// Connection |
||||||
|
dict.set('listen_port', listen_port); |
||||||
|
dict.set('upnp', upnp); |
||||||
|
dict.set('natpmp', natpmp); |
||||||
|
dict.set('up_limit', up_limit); |
||||||
|
dict.set('dl_limit', dl_limit); |
||||||
|
dict.set('max_connec', max_connec); |
||||||
|
dict.set('max_connec_per_torrent', max_connec_per_torrent); |
||||||
|
dict.set('max_uploads_per_torrent', max_uploads_per_torrent); |
||||||
|
// Bittorrent |
||||||
|
dict.set('dht', dht); |
||||||
|
dict.set('pex', pex); |
||||||
|
dict.set('lsd', lsd); |
||||||
|
dict.set('encryption', $('encryption_select').get('value')); |
||||||
|
// Downloads |
||||||
|
dict.set('save_path', save_path); |
||||||
|
dict.set('temp_path_enabled', temp_path_enabled); |
||||||
|
dict.set('temp_path', temp_path); |
||||||
|
dict.set('scan_dir', scandir_path); |
||||||
|
dict.set('preallocate_all', preallocate_all); |
||||||
|
if(!$('appendexttr').hasClass('invisible')) { |
||||||
|
dict.set('incomplete_files_ext', incomplete_files_ext); |
||||||
|
} |
||||||
|
dict.set('queueing_enabled', queueing_enabled); |
||||||
|
dict.set('max_active_uploads', max_active_uploads); |
||||||
|
dict.set('max_active_downloads', max_active_downloads); |
||||||
|
dict.set('max_active_torrents', max_active_torrents); |
||||||
|
// IP Filter |
||||||
|
dict.set('ip_filter_enabled', ip_filter_enabled); |
||||||
|
dict.set('ip_filter_path', ip_filter_path); |
||||||
|
// Web UI |
||||||
|
dict.set('web_ui_port', webui_port); |
||||||
|
dict.set('web_ui_username', webui_username); |
||||||
|
dict.set('web_ui_password', webui_password); |
||||||
|
dict.set('locale', locale); |
||||||
|
|
||||||
|
var json_str = JSON.encode(dict); |
||||||
|
|
||||||
|
new Request({url: '/command/setPreferences', |
||||||
|
method: 'post', |
||||||
|
data: {'json': json_str, |
||||||
|
}, |
||||||
|
onFailure: function() { |
||||||
|
alert("_(Unable to save program preferences, qBittorrent is probably unreachable.)"); |
||||||
|
window.parent.closeWindows(); |
||||||
|
}, |
||||||
|
onSuccess: function() { |
||||||
|
// Close window |
||||||
|
window.parent.closeWindows(); |
||||||
|
} |
||||||
|
}).send(); |
||||||
|
}; |
||||||
|
|
||||||
|
updateDlLimitEnabled = function() { |
||||||
|
if($defined($('dl_limit_checkbox').get('checked')) && $('dl_limit_checkbox').get('checked')) { |
||||||
|
$('dl_limit_value').set('disabled', 'false'); |
||||||
|
} else { |
||||||
|
$('dl_limit_value').set('disabled', 'true'); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
updateUpLimitEnabled = function() { |
||||||
|
if($defined($('up_limit_checkbox').get('checked')) && $('up_limit_checkbox').get('checked')) { |
||||||
|
$('up_limit_value').removeProperty('disabled'); |
||||||
|
} else { |
||||||
|
$('up_limit_value').set('disabled', 'true'); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
updateMaxConnecEnabled = function() { |
||||||
|
if($defined($('max_connec_checkbox').get('checked')) && $('max_connec_checkbox').get('checked')) { |
||||||
|
$('max_connec_value').removeProperty('disabled'); |
||||||
|
} else { |
||||||
|
$('max_connec_value').set('disabled', 'true'); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
updateMaxConnecPerTorrentEnabled = function() { |
||||||
|
if($defined($('max_connec_per_torrent_checkbox').get('checked')) && $('max_connec_per_torrent_checkbox').get('checked')) { |
||||||
|
$('max_connec_per_torrent_value').removeProperty('disabled'); |
||||||
|
} else { |
||||||
|
$('max_connec_per_torrent_value').set('disabled', 'true'); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
updateMaxUploadsPerTorrentEnabled = function() { |
||||||
|
if($defined($('max_uploads_per_torrent_checkbox').get('checked')) && $('max_uploads_per_torrent_checkbox').get('checked')) { |
||||||
|
$('max_uploads_per_torrent_value').removeProperty('disabled'); |
||||||
|
} else { |
||||||
|
$('max_uploads_per_torrent_value').set('disabled', 'true'); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
updateTempDirEnabled = function() { |
||||||
|
if($defined($('temppath_checkbox').get('checked')) && $('temppath_checkbox').get('checked')) { |
||||||
|
$('temppath_text').removeProperty('disabled'); |
||||||
|
} else { |
||||||
|
$('temppath_text').set('disabled', 'true'); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
updateScanDirEnabled = function() { |
||||||
|
if($defined($('scandir_checkbox').get('checked')) && $('scandir_checkbox').get('checked')) { |
||||||
|
$('scandir_text').removeProperty('disabled'); |
||||||
|
} else { |
||||||
|
$('scandir_text').set('disabled', 'true'); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
updateQueueingSystem = function() { |
||||||
|
if($defined($('queueing_checkbox').get('checked')) && $('queueing_checkbox').get('checked')) { |
||||||
|
$('max_active_dl_value').removeProperty('disabled'); |
||||||
|
$('max_active_up_value').removeProperty('disabled'); |
||||||
|
$('max_active_to_value').removeProperty('disabled'); |
||||||
|
} else { |
||||||
|
$('max_active_dl_value').set('disabled', 'true'); |
||||||
|
$('max_active_up_value').set('disabled', 'true'); |
||||||
|
$('max_active_to_value').set('disabled', 'true'); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
updateFilterSettings = function() { |
||||||
|
if($defined($('ipfilter_enabled_checkbox').get('checked')) && $('ipfilter_enabled_checkbox').get('checked')) { |
||||||
|
$('ipfilter_text').removeProperty('disabled'); |
||||||
|
} else { |
||||||
|
$('ipfilter_text').set('disabled', 'true'); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
loadPreferences = function() { |
||||||
|
var url = 'json/preferences'; |
||||||
|
var request = new Request.JSON({ |
||||||
|
url: url, |
||||||
|
method: 'get', |
||||||
|
noCache: true, |
||||||
|
onFailure: function() { |
||||||
|
alert("Could not contact qBittorrent"); |
||||||
|
}, |
||||||
|
onSuccess: function(pref) { |
||||||
|
if(pref){ |
||||||
|
// Connection |
||||||
|
var listen_port = pref.listen_port.toInt(); |
||||||
|
$('port_value').set('value', listen_port); |
||||||
|
|
||||||
|
if(pref.upnp) { |
||||||
|
$('upnp_checkbox').set('checked', 'checked'); |
||||||
|
} else { |
||||||
|
$('upnp_checkbox').removeProperty('checked'); |
||||||
|
} |
||||||
|
|
||||||
|
if(pref.natpmp) { |
||||||
|
$('natpmp_checkbox').set('checked', 'checked'); |
||||||
|
} else { |
||||||
|
$('natpmp_checkbox').removeProperty('checked'); |
||||||
|
} |
||||||
|
|
||||||
|
var dl_limit = pref.dl_limit.toInt(); |
||||||
|
if(dl_limit <= 0) { |
||||||
|
$('dl_limit_checkbox').removeProperty('checked'); |
||||||
|
} else { |
||||||
|
$('dl_limit_checkbox').set('checked', 'checked'); |
||||||
|
('dl_limit_value').set('value', dl_limit); |
||||||
|
} |
||||||
|
updateDlLimitEnabled(); |
||||||
|
var up_limit = pref.up_limit.toInt(); |
||||||
|
if(up_limit <= 0) { |
||||||
|
$('up_limit_checkbox').removeProperty('checked'); |
||||||
|
} else { |
||||||
|
$('up_limit_checkbox').set('checked', 'checked'); |
||||||
|
$('up_limit_value').set('value', up_limit); |
||||||
|
} |
||||||
|
updateUpLimitEnabled(); |
||||||
|
var max_connec = pref.max_connec.toInt(); |
||||||
|
if(max_connec <= 0) { |
||||||
|
$('max_connec_checkbox').removeProperty('checked'); |
||||||
|
$('max_connec_value').set('value', 500); |
||||||
|
} else { |
||||||
|
$('max_connec_checkbox').set('checked', 'checked'); |
||||||
|
$('max_connec_value').set('value', max_connec); |
||||||
|
} |
||||||
|
updateMaxConnecEnabled(); |
||||||
|
var max_connec_per_torrent = pref.max_connec_per_torrent.toInt(); |
||||||
|
if(max_connec_per_torrent <= 0) { |
||||||
|
$('max_connec_per_torrent_checkbox').removeProperty('checked'); |
||||||
|
$('max_connec_per_torrent_value').set('value', 100); |
||||||
|
} else { |
||||||
|
$('max_connec_per_torrent_checkbox').set('checked', 'checked'); |
||||||
|
$('max_connec_per_torrent_value').set('value', max_connec_per_torrent); |
||||||
|
} |
||||||
|
updateMaxConnecPerTorrentEnabled(); |
||||||
|
var max_uploads_per_torrent = pref.max_uploads_per_torrent.toInt(); |
||||||
|
if(max_uploads_per_torrent <= 0) { |
||||||
|
$('max_uploads_per_torrent_checkbox').removeProperty('checked'); |
||||||
|
$('max_uploads_per_torrent_value').set('value', 4); |
||||||
|
} else { |
||||||
|
$('max_uploads_per_torrent_checkbox').set('checked', 'checked'); |
||||||
|
$('max_uploads_per_torrent_value').set('value', max_uploads_per_torrent); |
||||||
|
} |
||||||
|
updateMaxUploadsPerTorrentEnabled(); |
||||||
|
// Bittorrent |
||||||
|
var dht = pref.dht; //bool |
||||||
|
if(dht) { |
||||||
|
$('dht_checkbox').set('checked', 'checked'); |
||||||
|
} else { |
||||||
|
$('dht_checkbox').removeProperty('checked'); |
||||||
|
} |
||||||
|
var pex = pref.pex; //bool |
||||||
|
if(pex) { |
||||||
|
$('pex_checkbox').set('checked', 'checked'); |
||||||
|
} else { |
||||||
|
$('pex_checkbox').removeProperty('checked'); |
||||||
|
} |
||||||
|
var lsd = pref.lsd; //bool |
||||||
|
if(lsd) { |
||||||
|
$('lsd_checkbox').set('checked', 'checked'); |
||||||
|
} else { |
||||||
|
$('lsd_checkbox').removeProperty('checked'); |
||||||
|
} |
||||||
|
var encryption = pref.encryption.toInt(); |
||||||
|
$('encryption_select').getChildren('option')[encryption].setAttribute('selected', ''); |
||||||
|
// Downloads |
||||||
|
var save_path = pref.save_path; |
||||||
|
$("savepath_text").set('value', save_path); |
||||||
|
var temp_path_enabled = pref.temp_path_enabled; |
||||||
|
if(temp_path_enabled) { |
||||||
|
$('temppath_checkbox').set('checked', 'checked'); |
||||||
|
} else { |
||||||
|
$('temppath_checkbox').removeProperty('checked'); |
||||||
|
} |
||||||
|
var temp_path = pref.temp_path; |
||||||
|
$('temppath_text').set('value', temp_path); |
||||||
|
updateTempDirEnabled(); |
||||||
|
var scan_dir_enabled = pref.scan_dir_enabled; |
||||||
|
if(scan_dir_enabled) { |
||||||
|
$('scandir_text').set('value', pref.scan_dir); |
||||||
|
} else { |
||||||
|
$('scandir_text').set('value', ''); |
||||||
|
} |
||||||
|
updateScanDirEnabled(); |
||||||
|
if(pref.preallocate_all) { |
||||||
|
$('preallocateall_checkbox').set('checked', 'checked'); |
||||||
|
} else { |
||||||
|
$('preallocateall_checkbox').removeProperty('checked'); |
||||||
|
} |
||||||
|
if($defined(pref.incomplete_files_ext)) { |
||||||
|
$('appendexttr').removeClass('invisible'); |
||||||
|
if(pref.incomplete_files_ext) { |
||||||
|
$('appendext_checkbox').set('checked', 'checked'); |
||||||
|
} else { |
||||||
|
$('appendext_checkbox').removeProperty('checked'); |
||||||
|
} |
||||||
|
} else { |
||||||
|
$('appendexttr').addClass('invisible'); |
||||||
|
} |
||||||
|
if(pref.queueing_enabled) { |
||||||
|
$('queueing_checkbox').set('checked', 'checked'); |
||||||
|
} else { |
||||||
|
$('queueing_checkbox').removeProperty('checked'); |
||||||
|
} |
||||||
|
$('max_active_dl_value').set('value', pref.max_active_downloads.toInt()); |
||||||
|
$('max_active_up_value').set('value', pref.max_active_uploads.toInt()); |
||||||
|
$('max_active_to_value').set('value', pref.max_active_torrents.toInt()); |
||||||
|
updateQueueingSystem(); |
||||||
|
// IP Filter |
||||||
|
if(pref.ip_filter_enabled) { |
||||||
|
$('ipfilter_enabled_checkbox').set('checked', 'checked'); |
||||||
|
} else { |
||||||
|
$('ipfilter_enabled_checkbox').removeProperty('checked'); |
||||||
|
} |
||||||
|
$('ipfilter_text').set('value', pref.ip_filter_path); |
||||||
|
updateFilterSettings(); |
||||||
|
// Web UI |
||||||
|
$('webui_port_value').set('value', pref.web_ui_port); |
||||||
|
$('webui_username_text').set('value', pref.web_ui_username); |
||||||
|
$('webui_password_text').set('value', pref.web_ui_password); |
||||||
|
$('locale_select').set('value', pref.locale); |
||||||
|
} |
||||||
|
} |
||||||
|
}).send(); |
||||||
|
} |
||||||
|
|
||||||
|
loadPreferences(); |
||||||
|
</script> |
Loading…
Reference in new issue