MediaWiki:DonationForm.js: Difference between revisions
Content deleted Content added
Load monthly convert JS if needed |
split out parseOtherAmount function so we can re-use it for monthlyconvert other amount |
||
Line 270:
var language = mw.config.get('wgPageContentLanguage');
var radioAmountsData = {
'USD' : {
Line 848:
/* Return amount selected or input */
donationForm.getAmount = function() {
var form = document.forms['donateForm']
donationForm.extraData.otherAmt = 0;
Line 856:
for ( var i = 0; i < form.amount.length; i++ ) {
if ( form.amount[i].checked ) {
amount = parseFloat( form.amount[i].value );
}
}
}
// Check the "other" amount box
if ( document.getElementById('input_amount_other').checked ) {
otherAmount = otherAmount.replace(/[,.](\d)$/, '\:$10');▼
otherAmount = otherAmount.replace(/[,.](\d)(\d)$/, '\:$1$2');▼
otherAmount = otherAmount.replace(/[\$£€¥,.]/g, '');▼
otherAmount = otherAmount.replace(/:/, '.');▼
amount = otherAmount;▼
donationForm.extraData.otherAmt = 1;
}
};
if ( isNaN(amount) ) {▼
/**
* Parse Other field value into amount
*
* Does some awful regex stuff to rm symbols and turn the string into a number
* Remember some locales flip . & , for decimal point/thousands separator
*
* @param {string} value Value of "Other" field
* @return {float} Float with amount, or 0 if NaN
*/
donationForm.parseOtherAmount = function( value ) {
amount = parseFloat( value );
▲ if ( isNaN( amount ) ) {
return 0;
} else {
return amount;
}
};
/**
Line 1,035 ⟶ 1,047:
// Load monthly convert JS if needed
}
// These get used in quite a few places
|