- Global Upload/Download rates can be set by clicking on the status bar values

This commit is contained in:
Christophe Dumez
2010-02-15 20:57:55 +00:00
parent f6bfacda2c
commit 13493e1afe
8 changed files with 177 additions and 55 deletions

View File

@@ -135,6 +135,9 @@ window.addEvent('load', function(){
}).send();
}
};
$('DlInfos').addEvent('click', globalDownloadLimitFN);
$('UpInfos').addEvent('click', globalUploadLimitFN);
var ajaxfn = function(){
var queueing_enabled = false;
var url = 'json/events';

View File

@@ -76,6 +76,22 @@ initializeWindows = function(){
});
});
globalUploadLimitFN = function() {
new MochaUI.Window({
id: 'uploadLimitPage',
title: "_(Global Upload Speed Limiting)",
loadMethod: 'iframe',
contentURL:'uploadlimit.html?hash=global',
scrollbars: false,
resizable: false,
maximizable: false,
paddingVertical: 0,
paddingHorizontal: 0,
width: 424,
height: 80
});
}
uploadLimitFN = function() {
var h = myTable.selectedIds();
if(h.length){
@@ -96,6 +112,22 @@ initializeWindows = function(){
}
};
globalDownloadLimitFN = function() {
new MochaUI.Window({
id: 'downloadLimitPage',
title: "_(Global Download Speed Limiting)",
loadMethod: 'iframe',
contentURL:'downloadlimit.html?hash=global',
scrollbars: false,
resizable: false,
maximizable: false,
paddingVertical: 0,
paddingHorizontal: 0,
width: 424,
height: 80
});
}
downloadLimitFN = function() {
var h = myTable.selectedIds();
if(h.length){

View File

@@ -32,40 +32,68 @@ MochaUI.extend({
maximum = tmp / 1024.
}
}
}
}).send();
// Get torrent upload limit
// And create slider
var req = new Request({
url: '/command/getTorrentUpLimit',
method: 'post',
data: {hash: hash},
onSuccess: function(data) {
if(data){
var up_limit = data.toInt();
// Get torrent upload limit
// And create slider
if(hash == 'global') {
var up_limit = maximum;
if(up_limit < 0) up_limit = 0;
maximum = 1000;
var mochaSlide = new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), {
steps: maximum,
offset: 0,
initialStep: (up_limit/1024.).round(),
onChange: function(pos){
if(pos > 0) {
$('uplimitUpdatevalue').set('html', pos);
$('upLimitUnit').set('html', "_(KiB/s)");
} else {
$('uplimitUpdatevalue').set('html', '∞');
$('upLimitUnit').set('html', "");
}
}.bind(this)
});
steps: maximum,
offset: 0,
initialStep: up_limit.round(),
onChange: function(pos){
if(pos > 0) {
$('uplimitUpdatevalue').set('html', pos);
$('upLimitUnit').set('html', "_(KiB/s)");
} else {
$('uplimitUpdatevalue').set('html', '∞');
$('upLimitUnit').set('html', "");
}
}.bind(this)
});
// Set default value
if(up_limit == 0) {
$('uplimitUpdatevalue').set('html', '∞');
$('upLimitUnit').set('html', "");
} else {
$('uplimitUpdatevalue').set('html', (up_limit/1024.).round());
$('uplimitUpdatevalue').set('html', up_limit.round());
$('upLimitUnit').set('html', "_(KiB/s)");
}
} else {
var req = new Request({
url: '/command/getTorrentUpLimit',
method: 'post',
data: {hash: hash},
onSuccess: function(data) {
if(data){
var up_limit = data.toInt();
if(up_limit < 0) up_limit = 0;
var mochaSlide = new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), {
steps: maximum,
offset: 0,
initialStep: (up_limit/1024.).round(),
onChange: function(pos){
if(pos > 0) {
$('uplimitUpdatevalue').set('html', pos);
$('upLimitUnit').set('html', "_(KiB/s)");
} else {
$('uplimitUpdatevalue').set('html', '∞');
$('upLimitUnit').set('html', "");
}
}.bind(this)
});
// Set default value
if(up_limit == 0) {
$('uplimitUpdatevalue').set('html', '∞');
$('upLimitUnit').set('html', "");
} else {
$('uplimitUpdatevalue').set('html', (up_limit/1024.).round());
$('upLimitUnit').set('html', "_(KiB/s)");
}
}
}
}).send();
}
}
}).send();
@@ -89,22 +117,16 @@ MochaUI.extend({
maximum = tmp / 1024.
}
}
}
}).send();
// Get torrent download limit
// And create slider
var req = new Request({
url: '/command/getTorrentDlLimit',
method: 'post',
data: {hash: hash},
onSuccess: function(data) {
if(data){
var dl_limit = data.toInt();
// Get torrent download limit
// And create slider
if(hash == "global") {
var dl_limit = maximum;
if(dl_limit < 0) dl_limit = 0;
maximum = 1000;
var mochaSlide = new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), {
steps: maximum,
offset: 0,
initialStep: (dl_limit/1024.).round(),
initialStep: dl_limit.round(),
onChange: function(pos){
if(pos > 0) {
$('dllimitUpdatevalue').set('html', pos);
@@ -120,9 +142,43 @@ MochaUI.extend({
$('dllimitUpdatevalue').set('html', '∞');
$('dlLimitUnit').set('html', "");
} else {
$('dllimitUpdatevalue').set('html', (dl_limit/1024.).round());
$('dllimitUpdatevalue').set('html', dl_limit.round());
$('dlLimitUnit').set('html', "_(KiB/s)");
}
} else {
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: maximum,
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)");
}
}
}
}).send();
}
}
}).send();