- Program preferences are now editable from Web UI :)

This commit is contained in:
Christophe Dumez
2009-11-26 10:10:40 +00:00
parent b6dc5f9675
commit 3e56cf96a3
31 changed files with 1041 additions and 238 deletions

View File

@@ -55,9 +55,68 @@
<script type="text/javascript">
applyPreferences = function() {
// Validate form data
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;
}
}
// Send it to qBT
// Close window
window.parent.closeWindows();
var dht = 0;
if($defined($('dht_checkbox').get('checked')) && $('dht_checkbox').get('checked'))
dht = 1;
new Request({url: '/command/setPreferences',
method: 'post',
data: {'up_limit': up_limit,
'dl_limit': dl_limit,
'dht': dht,
'max_connec': max_connec,
'max_connec_per_torrent': max_connec_per_torrent,
'max_uploads_per_torrent': max_uploads_per_torrent
},
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() {