Page MenuHomePhabricator

Fundraising stylesheets and scripts should be minified
Closed, ResolvedPublic

Description

Currently scripts like the following are shipped to the client unminified.

fundraisingAmounts.pick = function(source, currency, country) {
    /*
     * Select the correct amount or array of amounts from object in "source"
     * In future may extend to allow a language parameter too
     * 
     * @param {object} source   - the amounts object e.g. fundraisingAmounts.asks, fundraisingAmounts.averages
     * @param {string} currency - ISO code of currency
     * @param {string} country  - ISO code of country (optional)
     * @return {array/number}   - depending on source
     */

    if ( source[currency]["default"] ) { // we need to go deeper
        if ( source[currency][country] !== undefined ) {
            return source[currency][country];
        } else {
            return source[currency]["default"];
        }
    } else {
        return source[currency];
    }
};

function convertAsk(amount, currency, country) {
    /*
     * Given an amount in USD, find an "equivalent" local ask amount for the given currency and country
     * @TODO: namespace this
     * 
     * @param {number} amount   - USD amount
     * @param {string} currency - ISO code of currency
     * @param {string} country  - ISO code of country
     * @return {number}         - local amount
     */
    var usdbase = [3, 5, 10, 20, 30, 50, 100];
    var usdamount = parseInt(amount, 10);
    if(isNaN(usdamount)){
        return 0;
    }
 ...

Event Timeline

Krinkle raised the priority of this task from to Needs Triage.
Krinkle updated the task description. (Show Details)
Krinkle subscribed.

We're gradually adding functionality to Central Notice's campaign mixins to replace this sort of on-wiki javascript. Currency functions like these look like good candidates for new mixins. Mixins are delivered via ResourceLoader, so they'll be minified.

Krinkle triaged this task as Medium priority.Oct 4 2022, 2:11 AM
Krinkle claimed this task.