Some work about adaptive color scheme for Web UI (PR #19901) http://[316:c51a:62a3:8b9::4]/d4708/qBittorrent/src/branch/adaptive-webui
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

230 lines
9.9 KiB

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>_(Download from URL)</title>
<link rel="stylesheet" href="css/style.css" type="text/css" />
<script type="text/javascript" src="scripts/mootools-1.2-core-yc.js" charset="utf-8"></script>
</head>
<body style="padding: 5px;">
<!-- preferences -->
<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;"/>&nbsp;&nbsp;_(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;"/>&nbsp;&nbsp;_(KiB/s)</td>
</tr>
</table>
</div>
</fieldset>
<br/>
<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>
<br/>
<fieldset>
<legend><b>_(Bittorrent features)</b></legend>
<div style="padding-left: 30px;">
<table>
<tr>
<td style="vertical-align: bottom;"><input type="checkbox" id="dht_checkbox"/></td><td>_(Enable DHT network (decentralized))</td>
</tr>
</table>
</div>
</fieldset>
<br/>
<center><input type="button" value="_(Apply)" onclick="applyPreferences();"/></center>
<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
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() {
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');
}
}
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){
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 dht = pref.dht; //bool
if(dht) {
$('dht_checkbox').set('checked', 'checked');
} else {
$('dht_checkbox').removeProperty('checked');
}
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();
}
}
}).send();
}
loadPreferences();
</script>
</body>
</html>