MediaWiki:DonationForm mctest.js: Difference between revisions

Jump to navigation Jump to search
Content deleted Content added
split finalStep from redirectPayments, so we can call it back from monthlyconvert if needed
hook in monthly convert
Line 711: Line 711:
params.country = donationForm.country;
params.country = donationForm.country;
params.uselang = mw.config.get('wgPageContentLanguage'); // see T281285 for why not wgUserLanguage
params.uselang = mw.config.get('wgPageContentLanguage'); // see T281285 for why not wgUserLanguage

if ( params.uselang === 'pt' && params.country === 'BR' ) {
if ( params.uselang === 'pt' && params.country === 'BR' ) {
params.uselang = 'pt-br';
params.uselang = 'pt-br';
Line 750: Line 750:
}
}


// Check for monthly convert. TODO: make it possible to test JS variants
donationForm.finalStep( params );
if ( mw.util.getParamValue('monthlyconvert') ) {
mc.main( params, donationForm.finalStep );
} else {
donationForm.finalStep( params );
}


} else {
} else {
Line 787: Line 792:
window.location.href = uri.toString();
window.location.href = uri.toString();
}
}
}
};


/**
/**
Line 881: Line 886:
* Does some awful regex stuff to rm symbols and turn the string into a number
* Does some awful regex stuff to rm symbols and turn the string into a number
* Remember some locales flip . & , for decimal point/thousands separator
* Remember some locales flip . & , for decimal point/thousands separator
*
*
* @param {string} value Value of "Other" field
* @param {string} value Value of "Other" field
* @return {float} Float with amount, or 0 if NaN
* @return {float} Float with amount, or 0 if NaN
Line 892: Line 897:
value = value.replace(/[\$£€¥,.]/g, '');
value = value.replace(/[\$£€¥,.]/g, '');
value = value.replace(/:/, '.');
value = value.replace(/:/, '.');

amount = parseFloat( value );
amount = parseFloat( value );
if ( isNaN( amount ) ) {
if ( isNaN( amount ) ) {
Line 1,051: Line 1,056:


var form = document.forms['donateForm'];
var form = document.forms['donateForm'];

// Load monthly convert JS if needed
// Load monthly convert JS if needed
// TODO: allow loading different JS variants, either here or defined in the Template
// TODO: allow loading different JS variants, either here or defined in the Template