mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-10 23:42:46 -07:00
WebUI: Allow to control the alternative speed limits
setGlobalDownloadLimit and setGlobalUploadLimit will now modify the alternative speed limits if they are currently enabled and the regular speed limits otherwise. Add also two new commands to toggle the state of the alternative speed limits and get their current state. Closes #2203.
This commit is contained in:
parent
25e8cad16c
commit
c53b19d6c1
4 changed files with 63 additions and 3 deletions
|
@ -27,6 +27,7 @@ myTable = new dynamicTable();
|
|||
var updatePropertiesPanel = function(){};
|
||||
var updateTransferInfo = function(){};
|
||||
var updateTransferList = function(){};
|
||||
var alternativeSpeedsLimit = false;
|
||||
|
||||
var stateToImg = function (state) {
|
||||
if (state == "pausedUP" || state == "pausedDL") {
|
||||
|
@ -278,6 +279,40 @@ window.addEvent('load', function () {
|
|||
// Start fetching data now
|
||||
loadTransferInfo();
|
||||
|
||||
var updateAltSpeedIcon = function(enabled) {
|
||||
if (enabled)
|
||||
$('alternativeSpeedLimits').src = "images/slow.png";
|
||||
else
|
||||
$('alternativeSpeedLimits').src = "images/slow_off.png"
|
||||
}
|
||||
|
||||
// Determine whether the alternative speed limits are enabled or not
|
||||
new Request({url: 'command/alternativeSpeedLimitsEnabled',
|
||||
method: 'get',
|
||||
onSuccess : function (isEnabled) {
|
||||
alternativeSpeedsLimit = !!isEnabled;
|
||||
if (alternativeSpeedsLimit)
|
||||
$('alternativeSpeedLimits').src = "images/slow.png"
|
||||
}
|
||||
}).send();
|
||||
|
||||
$('alternativeSpeedLimits').addEvent('click', function() {
|
||||
// Change icon immediately to give some feedback
|
||||
updateAltSpeedIcon(!alternativeSpeedsLimit);
|
||||
|
||||
new Request({url: 'command/toggleAlternativeSpeedLimits',
|
||||
method: 'post',
|
||||
onComplete: function() {
|
||||
alternativeSpeedsLimit = !alternativeSpeedsLimit;
|
||||
updateTransferInfo();
|
||||
},
|
||||
onFailure: function() {
|
||||
// Restore icon in case of failure
|
||||
updateAltSpeedIcon(alternativeSpeedsLimit)
|
||||
}
|
||||
}).send();
|
||||
});
|
||||
|
||||
$('DlInfos').addEvent('click', globalDownloadLimitFN);
|
||||
$('UpInfos').addEvent('click', globalUploadLimitFN);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue