MediaWiki:DonationFormSandbox.js: Difference between revisions
Content deleted Content added
No edit summary |
No edit summary |
||
Line 8:
donationForm.loadedTime = Date.now();
donationForm.extraData = {};
// Don't offer recurring at all in these countries
Line 214 ⟶ 222:
'ZMK' : 5176,
'ZWD' : 373
};
let formatters = {
currencyFraction: new Intl.NumberFormat(
donationForm.locale, { style: 'currency', currency: donationForm.currency }
currencyWhole: new Intl.NumberFormat(
donationForm.locale, { style: 'currency', currency: donationForm.currency, minimumFractionDigits: 0 }
// Without currency symbol
amountFraction: new Intl.NumberFormat(
amountWhole: new Intl.NumberFormat(
donationForm.locale, {}
)
};
if ( amount % 1 !== 0 ) { // Not a whole number▼
return formatters.currencyFraction.format( amount );
} else {▼
return formatters.currencyWhole.format( amount );
}
};
donationForm.formatAmount = function( amount ) {
var formatterOptions, output;▼
if ( amount % 1 !== 0 ) { // Not a whole number
return formatters.amountFraction.format( amount );
return formatters.amountWhole.format( amount );
}
};
Line 1,152 ⟶ 1,194:
}
return false;
▲};
▲ * Note this doesn't include any currency symbol
▲donationForm.formatAmount = function( amount, locale = donationForm.locale ) {
▲ var formatterOptions, output;
▲ if ( amount % 1 !== 0 ) { // Not a whole number
▲ formatterOptions = { minimumFractionDigits: 2, maximumFractionDigits: 2 };
▲ } else {
▲ }
▲ try {
▲ } catch(e) {
▲ }
};
Line 1,360 ⟶ 1,377:
var form = document.forms.donateForm;
▲ donationForm.currency = form.currency_code.value;
▲ } catch (error) {
▲ donationForm.currency = 'USD';
▲ }
▲ donationForm.country = mw.util.getParamValue('country').toUpperCase();
▲ donationForm.locale = donationForm.getLocale( mw.config.get('wgPageContentLanguage'), donationForm.country );
// Minimum amount is usually about 1 USD
|