MediaWiki:MonthlyConvert.js: Difference between revisions

Content deleted Content added
re-use donationForm.parseOtherAmount
No edit summary
Line 123:
mc.amounts.NZD = mc.amounts.USD;
 
mc.getConvertAskgetSuggestedAmount = function ( amount, currency ) {
var i,
amountsForCurrency = mc.amounts[ currency ],
Line 141:
mc.formatAmount = function ( amount, currency, locale ) {
var formattedAmount;
 
try {
formattedAmount = amount.toLocaleString( locale, { currency: currency, style: 'currency' } );
Line 154 ⟶ 153:
var otherInput = document.getElementById('mc-other-amount-input'),
otherAmount = null;
 
if ( otherInput.value !== '' ) {
otherAmount = donationForm.parseOtherAmount( otherInput.value );
}
 
return otherAmount;
};
Line 189 ⟶ 186:
};
 
mc.main = function( amount, currencyparams ) {
 
var suggestedAmountinitialAmount = mcparams.getConvertAsk( amount, currency ),
currency = params.currency,
suggestedAmount = mc.getSuggestedAmount( initialAmount, currency ),
locale = 'en-US';
 
if ( params.recurring ) {
// Already recurring
return falseparams;
}
 
if ( donationForm.noRecurringCountries.indexOf( params.country ) !== -1 ) {
// Country where we don't offer any recurring
return params;
}
 
if ( suggestedAmount === 0 ) {
// Amount too low, or we don't have any suggestions
return false;
return params;
}
 
if (
$('.mc-currencycode').text( currency );
( params.paymentMethod === 'paypal' ) ||
( params.paymentMethod === 'rtbt' && params.payment_submethod === 'rtbt_ideal' ) ||
( params.paymentMethod === 'cc' && params.gateway === 'adyen' )
) {
// suitable method!
} else {
return params;
}
 
$('.mc-amt-initialcurrencycode').text( mc.formatAmount( amount, currency, locale) );
$('.mc-amt-initial').text( mc.formatAmount( initialAmount, currency, locale) );
$('.mc-amt-suggest').text( mc.formatAmount( suggestedAmount, currency, locale ) );