Precise setting of upload/download limits

This commit is contained in:
buinsky 2014-12-13 03:54:24 +03:00
parent c95e181378
commit 98deac97a0
3 changed files with 40 additions and 39 deletions

View file

@ -4,7 +4,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>_(Torrent Download Speed Limiting)</title>
<link rel="stylesheet" href="css/style.css" type="text/css" />
<link rel="stylesheet" href="css/mocha.css" type="text/css" />
<script type="text/javascript" src="scripts/mootools-1.2-core-yc.js" charset="utf-8"></script>
<script type="text/javascript" src="scripts/mootools-1.2-more.js" charset="utf-8"></script>
<script type="text/javascript" src="scripts/mocha-yc.js" charset="utf-8"></script>
@ -13,7 +12,7 @@
<body>
<div style="width: 100%; text-align: center; margin: 0 auto;">
<div id="dllimitSlider" class="slider">
<div id="dllimitUpdate" class="update">_(Download limit:) <span id="dllimitUpdatevalue" class="updatevalue">0</span> <span id="dlLimitUnit">_(KiB/s)</span></div>
<div id="dllimitUpdate" class="update">_(Download limit:) <input id="dllimitUpdatevalue" size="6" placeholder="∞" style="text-align: center;"> <span id="dlLimitUnit">_(KiB/s)</span></div>
<div class="sliderWrapper">
<div id="dllimitSliderknob" class="sliderknob"></div>
<div id="dllimitSliderarea" class="sliderarea"></div>
@ -23,7 +22,7 @@
<script type="text/javascript">
var hash = new URI().getData('hash');
setDlLimit = function() {
var limit = $("dllimitUpdatevalue").get('html').toInt() * 1024;
var limit = $("dllimitUpdatevalue").value.toInt() * 1024;
if(hash == "global") {
new Request({url: 'command/setGlobalDlLimit',
method: 'post',

View file

@ -46,23 +46,23 @@ MochaUI.extend({
initialStep: up_limit.round(),
onChange: function(pos) {
if (pos > 0) {
$('uplimitUpdatevalue').set('html', pos);
$('upLimitUnit').set('html', "_(KiB/s)");
$('uplimitUpdatevalue').value = pos;
$('upLimitUnit').style.visibility = "visible";
}
else {
$('uplimitUpdatevalue').set('html', '∞');
$('upLimitUnit').set('html', "");
$('uplimitUpdatevalue').value = '∞';
$('upLimitUnit').style.visibility = "hidden";
}
}.bind(this)
});
// Set default value
if (up_limit == 0) {
$('uplimitUpdatevalue').set('html', '∞');
$('upLimitUnit').set('html', "");
$('uplimitUpdatevalue').value = '∞';
$('upLimitUnit').style.visibility = "hidden";
}
else {
$('uplimitUpdatevalue').set('html', up_limit.round());
$('upLimitUnit').set('html', "_(KiB/s)");
$('uplimitUpdatevalue').value = up_limit.round();
$('upLimitUnit').style.visibility = "visible";
}
}
else {
@ -82,23 +82,23 @@ MochaUI.extend({
initialStep: (up_limit / 1024.).round(),
onChange: function(pos) {
if (pos > 0) {
$('uplimitUpdatevalue').set('html', pos);
$('upLimitUnit').set('html', "_(KiB/s)");
$('uplimitUpdatevalue').value = pos;
$('upLimitUnit').style.visibility = "visible";
}
else {
$('uplimitUpdatevalue').set('html', '∞');
$('upLimitUnit').set('html', "");
$('uplimitUpdatevalue').value = '∞';
$('upLimitUnit').style.visibility = "hidden";
}
}.bind(this)
});
// Set default value
if (up_limit == 0) {
$('uplimitUpdatevalue').set('html', '∞');
$('upLimitUnit').set('html', "");
$('uplimitUpdatevalue').value = '∞';
$('upLimitUnit').style.visibility = "hidden";
}
else {
$('uplimitUpdatevalue').set('html', (up_limit / 1024.).round());
$('upLimitUnit').set('html', "_(KiB/s)");
$('uplimitUpdatevalue').value = (up_limit / 1024.).round();
$('upLimitUnit').style.visibility = "visible";
}
}
}
@ -126,7 +126,10 @@ MochaUI.extend({
maximum = tmp / 1024.
}
else {
maximum = 1000
if (hash == "global")
maximum = 10000;
else
maximum = 1000;
}
}
// Get torrent download limit
@ -141,23 +144,23 @@ MochaUI.extend({
initialStep: dl_limit.round(),
onChange: function(pos) {
if (pos > 0) {
$('dllimitUpdatevalue').set('html', pos);
$('dlLimitUnit').set('html', "_(KiB/s)");
$('dllimitUpdatevalue').value = pos;
$('dlLimitUnit').style.visibility = "visible";
}
else {
$('dllimitUpdatevalue').set('html', '∞');
$('dlLimitUnit').set('html', "");
$('dllimitUpdatevalue').value = '∞';
$('dlLimitUnit').style.visibility = "hidden";
}
}.bind(this)
});
// Set default value
if (dl_limit == 0) {
$('dllimitUpdatevalue').set('html', '∞');
$('dlLimitUnit').set('html', "");
$('dllimitUpdatevalue').value = '∞';
$('dlLimitUnit').style.visibility = "hidden";
}
else {
$('dllimitUpdatevalue').set('html', dl_limit.round());
$('dlLimitUnit').set('html', "_(KiB/s)");
$('dllimitUpdatevalue').value = dl_limit.round();
$('dlLimitUnit').style.visibility = "visible";
}
}
else {
@ -177,23 +180,23 @@ MochaUI.extend({
initialStep: (dl_limit / 1024.).round(),
onChange: function(pos) {
if (pos > 0) {
$('dllimitUpdatevalue').set('html', pos);
$('dlLimitUnit').set('html', "_(KiB/s)");
$('dllimitUpdatevalue').value = pos;
$('dlLimitUnit').style.visibility = "visible";
}
else {
$('dllimitUpdatevalue').set('html', '∞');
$('dlLimitUnit').set('html', "");
$('dllimitUpdatevalue').value = '∞';
$('dlLimitUnit').style.visibility = "hidden";
}
}.bind(this)
});
// Set default value
if (dl_limit == 0) {
$('dllimitUpdatevalue').set('html', '∞');
$('dlLimitUnit').set('html', "");
$('dllimitUpdatevalue').value = '∞';
$('dlLimitUnit').style.visibility = "hidden";
}
else {
$('dllimitUpdatevalue').set('html', (dl_limit / 1024.).round());
$('dlLimitUnit').set('html', "_(KiB/s)");
$('dllimitUpdatevalue').value = (dl_limit / 1024.).round();
$('dlLimitUnit').style.visibility = "visible";
}
}
}

View file

@ -4,7 +4,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>_(Torrent Upload Speed Limiting)</title>
<link rel="stylesheet" href="css/style.css" type="text/css" />
<link rel="stylesheet" href="css/mocha.css" type="text/css" />
<script type="text/javascript" src="scripts/mootools-1.2-core-yc.js" charset="utf-8"></script>
<script type="text/javascript" src="scripts/mootools-1.2-more.js" charset="utf-8"></script>
<script type="text/javascript" src="scripts/mocha-yc.js" charset="utf-8"></script>
@ -13,7 +12,7 @@
<body>
<div style="width: 100%; text-align: center; margin: 0 auto;">
<div id="uplimitSlider" class="slider">
<div id="uplimitUpdate" class="update">_(Upload limit:) <span id="uplimitUpdatevalue" class="updatevalue">0</span> <span id="upLimitUnit">_(KiB/s)</span></div>
<div id="uplimitUpdate" class="update">_(Upload limit:) <input id="uplimitUpdatevalue" size="6" placeholder="∞" style="text-align: center;"> <span id="upLimitUnit">_(KiB/s)</span></div>
<div class="sliderWrapper">
<div id="uplimitSliderknob" class="sliderknob"></div>
<div id="uplimitSliderarea" class="sliderarea"></div>
@ -23,7 +22,7 @@
<script type="text/javascript">
var hash = new URI().getData('hash');
setUpLimit = function() {
var limit = $("uplimitUpdatevalue").get('html').toInt() * 1024;
var limit = $("uplimitUpdatevalue").value.toInt() * 1024;
if(hash == "global") {
new Request({url: 'command/setGlobalUpLimit',
method: 'post',