Browse Source

Precise setting of upload/download limits

adaptive-webui-19844
buinsky 10 years ago
parent
commit
98deac97a0
  1. 5
      src/webui/www/public/downloadlimit.html
  2. 69
      src/webui/www/public/scripts/parametrics.js
  3. 5
      src/webui/www/public/uploadlimit.html

5
src/webui/www/public/downloadlimit.html

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

69
src/webui/www/public/scripts/parametrics.js

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

5
src/webui/www/public/uploadlimit.html

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

Loading…
Cancel
Save