From afaf40eee0b6c1b54cf01c11ac66d69fbfdf1f62 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Wed, 25 Nov 2009 10:09:14 +0000 Subject: [PATCH] - Allow to set up per-torrent download rate limit from Web UI too --- src/webui.qrc | 1 + src/webui/downloadlimit.html | 44 +++++++++++++++++++++++++++++ src/webui/scripts/parametrics.js | 48 +++++++++++++++++++++++++++++--- src/webui/uploadlimit.html | 4 +-- 4 files changed, 91 insertions(+), 6 deletions(-) create mode 100644 src/webui/downloadlimit.html diff --git a/src/webui.qrc b/src/webui.qrc index 640058592..f6af6ac7f 100644 --- a/src/webui.qrc +++ b/src/webui.qrc @@ -12,6 +12,7 @@ webui/prop-files.html webui/properties.html webui/uploadlimit.html + webui/downloadlimit.html webui/css/mocha.css webui/css/dynamicTable.css webui/css/style.css diff --git a/src/webui/downloadlimit.html b/src/webui/downloadlimit.html new file mode 100644 index 000000000..53fbab409 --- /dev/null +++ b/src/webui/downloadlimit.html @@ -0,0 +1,44 @@ + + + + + _(Torrent Download Speed Limiting) + + + + + + + + +
+
+
_(Download limit:) 0 _(KiB/s)
+
+
+
+
+
+
+ + +
+ + + + + \ No newline at end of file diff --git a/src/webui/scripts/parametrics.js b/src/webui/scripts/parametrics.js index 0a881f08e..eef3f4641 100644 --- a/src/webui/scripts/parametrics.js +++ b/src/webui/scripts/parametrics.js @@ -34,20 +34,60 @@ MochaUI.extend({ onChange: function(pos){ if(pos > 0) { $('uplimitUpdatevalue').set('html', pos); - $('UpLimitUnit').set('html', "_(KiB/s)"); + $('upLimitUnit').set('html', "_(KiB/s)"); } else { $('uplimitUpdatevalue').set('html', '∞'); - $('UpLimitUnit').set('html', ""); + $('upLimitUnit').set('html', ""); } }.bind(this) }); // Set default value if(up_limit == 0) { $('uplimitUpdatevalue').set('html', '∞'); - $('UpLimitUnit').set('html', ""); + $('upLimitUnit').set('html', ""); } else { $('uplimitUpdatevalue').set('html', (up_limit/1024.).round()); - $('UpLimitUnit').set('html', "_(KiB/s)"); + $('upLimitUnit').set('html', "_(KiB/s)"); + } + } + } + }).send(); + } + }, + + addDlLimitSlider: function(hash){ + if ($('dllimitSliderarea')) { + var windowOptions = MochaUI.Windows.windowOptions; + var sliderFirst = true; + var req = new Request({ + url: '/command/getTorrentDlLimit', + method: 'post', + data: {hash: hash}, + onSuccess: function(data) { + if(data){ + var dl_limit = data.toInt(); + if(dl_limit < 0) dl_limit = 0; + var mochaSlide = new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), { + steps: 500, + offset: 0, + initialStep: (dl_limit/1024.).round(), + onChange: function(pos){ + if(pos > 0) { + $('dllimitUpdatevalue').set('html', pos); + $('dlLimitUnit').set('html', "_(KiB/s)"); + } else { + $('dllimitUpdatevalue').set('html', '∞'); + $('dlLimitUnit').set('html', ""); + } + }.bind(this) + }); + // Set default value + if(dl_limit == 0) { + $('dllimitUpdatevalue').set('html', '∞'); + $('dlLimitUnit').set('html', ""); + } else { + $('dllimitUpdatevalue').set('html', (dl_limit/1024.).round()); + $('dlLimitUnit').set('html', "_(KiB/s)"); } } } diff --git a/src/webui/uploadlimit.html b/src/webui/uploadlimit.html index 001680390..643934a34 100644 --- a/src/webui/uploadlimit.html +++ b/src/webui/uploadlimit.html @@ -2,7 +2,7 @@ - _(Torrent Download Speed Limiting) + _(Torrent Upload Speed Limiting) @@ -13,7 +13,7 @@
-
_(Upload limit:) 0 _(KiB/s)
+
_(Upload limit:) 0 _(KiB/s)