mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-18 06:28:03 -06: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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user