Browse Source

Merge pull request #2307 from pmzqla/webui-altspeed

WebUI: Alternative speed limits fixes
adaptive-webui-19844
sledgehammer999 10 years ago
parent
commit
7bc7b0e6b8
  1. 12
      src/webui/www/public/scripts/client.js

12
src/webui/www/public/scripts/client.js

@ -27,7 +27,7 @@ myTable = new dynamicTable();
var updatePropertiesPanel = function(){}; var updatePropertiesPanel = function(){};
var updateTransferInfo = function(){}; var updateTransferInfo = function(){};
var updateTransferList = function(){}; var updateTransferList = function(){};
var alternativeSpeedsLimit = false; var alternativeSpeedLimits = false;
var stateToImg = function (state) { var stateToImg = function (state) {
if (state == "pausedUP" || state == "pausedDL") { if (state == "pausedUP" || state == "pausedDL") {
@ -297,25 +297,25 @@ window.addEvent('load', function () {
new Request({url: 'command/alternativeSpeedLimitsEnabled', new Request({url: 'command/alternativeSpeedLimitsEnabled',
method: 'get', method: 'get',
onSuccess : function (isEnabled) { onSuccess : function (isEnabled) {
alternativeSpeedsLimit = !!isEnabled; alternativeSpeedLimits = !!parseInt(isEnabled);
if (alternativeSpeedsLimit) if (alternativeSpeedLimits)
$('alternativeSpeedLimits').src = "images/slow.png" $('alternativeSpeedLimits').src = "images/slow.png"
} }
}).send(); }).send();
$('alternativeSpeedLimits').addEvent('click', function() { $('alternativeSpeedLimits').addEvent('click', function() {
// Change icon immediately to give some feedback // Change icon immediately to give some feedback
updateAltSpeedIcon(!alternativeSpeedsLimit); updateAltSpeedIcon(!alternativeSpeedLimits);
new Request({url: 'command/toggleAlternativeSpeedLimits', new Request({url: 'command/toggleAlternativeSpeedLimits',
method: 'post', method: 'post',
onComplete: function() { onComplete: function() {
alternativeSpeedsLimit = !alternativeSpeedsLimit; alternativeSpeedLimits = !alternativeSpeedLimits;
updateTransferInfo(); updateTransferInfo();
}, },
onFailure: function() { onFailure: function() {
// Restore icon in case of failure // Restore icon in case of failure
updateAltSpeedIcon(alternativeSpeedsLimit) updateAltSpeedIcon(alternativeSpeedLimits)
} }
}).send(); }).send();
}); });

Loading…
Cancel
Save