1

This is for a plasma widget that gets different exchange rates and multiplies them with each other if the option is enabled. ie rate1 * rate2 * rate3.

bear in mind that i'm new to this and am not sure how i'd implement this due to the necessity of callbacks. So the following is just a horribly written draft of what i'm trying to achieve.

function() {
    var result1 = getRate(url1, jsonKey1, function(rate) {
    rateText = Number(rate);

    if (multiplyBySecondaryRate) {    //Convert option 1 checked?
        var result2 = getRate(url2, jsonKey2, function(rate) {
            var rateText2 = Number(rate);
            root.secondRate = rateText2;
        }
        var rateText = rateText * root.secondRate;
    }

    if (multiplyByTertiaryRate) {    //Convert option 2 checked?
        var result3 = getRate(url3, jsonKey3, function(rate) {
            var rateText3 = Number(rate);
            root.thirdRate = rateText3;
        }
        var rateText = rateText * root.thirdRate;
    }

    root.displayRate = rateText;

}

i've tried a few things but sadly this is the closest to "operational" i've come. any advice would be appreciated.

yamahama
  • 39
  • 2

0 Answers0