MediaWiki:DonationForm.js: Difference between revisions

Content deleted Content added
more PTF work
rm base64 decoding, being done in Civi now - phab:T381931
Tag: Undo
 
(177 intermediate revisions by 3 users not shown)
Line 1:
/* jshint strict:false */
/** MediaWiki:DonationForm.js - loaded on all donation forms
* TODO: lots of cleanup
Line 6 ⟶ 7:
 
donationForm.loadedTime = Date.now();
donationForm.extraData = {};
 
'vw' : window.innerWidth,
donationForm.country = mw.util.getParamValue('country').toUpperCase();
'vh' : window.innerHeight
try {
donationForm.currency = document.forms.donateForm.currency_code.value;
} catch (error) {
donationForm.currency = 'USD';
}
 
/**
* Make language and country into a standard javascript Intl locale identifier
*
* @param {string} language
* @param {string} country
* @return {string} locale identifier e.g. en-GB
*/
donationForm.getLocale = function( language, country ) {
// Sometimes in email testing links the uselang is a variable contiaining %
// In that case fall back to English so locale code doesn't break form
if ( language.match('%') ) {
language = 'en';
}
// MediaWiki allows some language codes like en-gb, en-ca, pt-br
// We don't want these for a javascript locale, so drop anything after '-'
language = language.split('-')[0];
 
return language + '-' + country;
};
 
donationForm.locale = donationForm.getLocale( mw.config.get('wgPageContentLanguage'), donationForm.country );
donationForm.minimums = {
 
/* From https://github.com/wikimedia/wikimedia-fundraising-SmashPig/blob/master/PaymentData/ReferenceData/CurrencyRates.php */
 
'ADF' : 5.65,
// Don't offer recurring at all in these countries
'ADP' : 143,
donationForm.noRecurringCountries = [ 'AR', 'IN' ];
'AED' : 3.67,
 
'AFA' : 73,
donationForm.noRecurringPaypalCountries = [ 'CL', 'CO', 'PE', 'UY', 'BR' ];
'AFN' : 73,
 
'ALL' : 109,
donationForm.currencyRates = {
'AMD' : 477,
// From https://github.com/wikimedia/wikimedia-fundraising-SmashPig/blob/master/PaymentData/ReferenceData/CurrencyRates.php
'ANG' : 1.79,
// Updated 2024-07-31
'AOA' : 278,
'AONADF' : 2786.04,
'ATSADP' : 12153,
'AUDAED' : 13.3967,
'AWGAFA' : 1.7870,
'AZMAFN' : 848670,
'AZNALL' : 1.790,
'BAMAMD' : 1.69368,
'BBDANG' : 21.79,
'BDTAOA' : 83844,
'BEFAON' : 35844,
'BGLARS' : 1.69887,
'BGNATS' : 1.6913,
'BHDAUD' : 01.385,
'BIFAWG' : 17481.79,
'BMDAZM' : 18500,
'BNDAZN' : 1.387,
'BOBBAM' : 61.8,
'BSDBBD' : 12,
'BTNBDT' : 72116,
'BWPBEF' : 1137,
'BYRBGL' : 210351.8,
'BZDBGN' : 1.988,
'CADBHD' : 10.3237355757356689,
'CDFBIF' : 15732842,
'CHFBMD' : 0.981,
'CNYBND' : 61.8335,
'CRCBOB' : 5726.71,
'CUCBRL' : 5.1,
'CUPBSD' : 251,
'CVEBTN' : 9583,
'CYPBWP' : 0.5113,
'CZKBYR' : 2232642,
'DEMBZD' : 1.6998,
'DJFCAD' : 1781.36,
'DKKCDF' : 6.422786,
'DOPCHF' : 500.9094629289448,
'DZDCLP' : 118890,
'ECSCNY' : 240947.23,
'EEKCOP' : 133803,
'EGPCRC' : 18498,
'ESPCUC' : 1431,
'ETBCUP' : 2725,
'EURCVE' : 0.87101,
'FIMCYP' : 50.1253848627984321,
'FJDCZK' : 2.123,
'FKPDEM' : 01.788,
'FRFDJF' : 5.65178,
'GBPDKK' : 06.7886,
'GELDOP' : 2.5258,
'GHCDZD' : 47467133,
'GHSECS' : 4.7524094,
'GIPEEK' : 0.7814,
'GMDEGP' : 4847,
'GNFESP' : 8983153,
'GRDETB' : 29457,
'GTQEUR' : 70.592005843390143,
'GYDFIM' : 2045.47,
'HKDFJD' : 72.8523,
'HNLFKP' : 240.78703952551207,
'HRKFRF' : 6.404,
'HTGGBP' : 680.78703952551207,
'HUFGEL' : 2822.71,
'IDRGHC' : 14966143125,
'IEPGHS' : 0.6814,
'ILSGIP' : 30.6178703952551207,
'INRGMD' : 7268,
'IQDGNF' : 11788493,
'IRRGRD' : 42000314,
'ISKGTQ' : 1097.57,
'ITLGYD' : 1669200,
'JMDHKD' : 1367.8,
'JODHNL' : 0.7124,
'JPYHRK' : 1126.93,
'KESHTG' : 100132,
'KGSHUF' : 69355,
'KHRIDR' : 402515986,
'KMFIEP' : 4240.72460490043714,
'KPWILS' : 1353.69,
'KRWINR' : 112083,
'KWDIQD' : 0.311290,
'KYDIRR' : 0.8442009,
'KZTISK' : 369138,
'LAKITL' : 83931781,
'LBPJMD' : 1508154,
'LKRJOD' : 1620.70900000000001,
'LRDJPY' : 154156,
'LSLKES' : 15130,
'LTLKGS' : 2.9888,
'LUFKHR' : 353993,
'LVLKMF' : 0.61453,
'LYDKPW' : 1.37135,
'MADKRW' : 9.391358,
'MDLKWD' : 170.30629670764681,
'MGAKYD' : 33110.83333299999999,
'MGFKZT' : 9150442,
'MKDLAK' : 5321103,
'MMKLBP' : 152989393,
'MNTLKR' : 2460298,
'MOPLRD' : 8.08193,
'MROLSL' : 35718,
'MTLLTL' : 03.3718,
'MURLUF' : 3337,
'MVRLVL' : 150.64662074757963,
'MWKLYD' : 7174.8,
'MYRMAD' : 49.1579,
'MZMMDL' : 5975417,
'MZNMGA' : 604379,
'NADMGF' : 159150,
'NGNMKD' : 35956,
'NIOMMK' : 322075,
'NLGMNT' : 1.92620,
'NOKMOP' : 8.403,
'NPRMRO' : 114391,
'NZDMTL' : 10.5239498108567387,
'OMRMUR' : 0.3945,
'PABMVR' : 115,
'PENMWK' : 3.31720,
'PGKMXN' : 3.2617,
'PHPMYR' : 544.68,
'PKRMZM' : 12363200,
'PLNMZN' : 3.7263,
'PTENAD' : 17318,
'PYGNGN' : 57631505,
'QARNIO' : 3.5736,
'ROLNLG' : 398892.03,
'RONNOK' : 3.9911,
'RSDNPR' : 101131,
'RUBNZD' : 681.63,
'RWFOMR' : 8620.38377594841305,
'SARPAB' : 3.751,
'SBDPEN' : 73.667,
'SCRPGK' : 133.76,
'SDDPHP' : 179558,
'SDGPKR' : 18277,
'SDPPLN' : 22613.91,
'SEKPTE' : 9.08184,
'SGDPYG' : 1.387355,
'SHPQAR' : 03.7856,
'SITROL' : 20745713,
'SKKRON' : 264.57,
'SLLRSD' : 8430108,
'SOSRUB' : 54291,
'SRDRWF' : 7.411277,
'SRGSAR' : 74083.75,
'STDSBD' : 210708.37,
'SVCSCR' : 8.7513,
'SYPSDD' : 21559800,
'SZLSDG' : 15598,
'THBSDP' : 332261,
'TJSSEK' : 9.3611,
'TMMSGD' : 170501.35,
'TMTSHP' : 30.4178703952551207,
'TNDSIT' : 2.76220,
'TOPSKK' : 2.2928,
'TRLSLL' : 662922319750,
'TRYSOS' : 6.63549,
'TTDSRD' : 6.6433,
'TWDSRG' : 3133320,
'TZSSTD' : 228122477,
'UAHSVC' : 288.75,
'UGXSYP' : 3749513,
'USDSZL' : 118,
'UZSTHB' : 778036,
'VEBTJS' : 605084113611,
'VEFTMM' : 605084116750,
'VNDTMT' : 231503.35,
'VUVTND' : 1113.11,
'WSTTOP' : 2.6432,
'XAFTRL' : 56532168418,
'XCDTRY' : 2.732,
'XOFTTD' : 5656.64,
'XPFTWD' : 10332,
'YERTZS' : 2502587,
'YUNUAH' : 10139,
'ZARUGX' : 153760,
'ZMKUSD' : 51761,
'ZWDUYU' : 37338,
'UZS' : 12662,
/* Astropay currencies have higher minimums - 1.50 USD */
'ARSVEB' : 58.53651907631,
'BRLVEF' : 6.233651908,
'CLPVND' : 103525451,
'COPVUV' : 4640112,
'MXNWST' : 282.567,
'XAF' : 604,
'XAG' : 0.031347411860134,
'XAU' : 0.00041128929241299,
'XCD' : 2.7,
'XEU' : 0.92005843390143,
'XOF' : 604,
'XPD' : 0.00098009826645798,
'XPF' : 110,
'XPT' : 0.00093444018680404,
'YER' : 249,
'YUN' : 108,
'ZAR' : 18,
'ZMK' : 5176,
'ZWD' : 373
};
 
/* Amount and currency formatting */
let formatters = {
// Amounts without currency symbol
amountFraction: new Intl.NumberFormat( donationForm.locale,
{ minimumFractionDigits: 2, maximumFractionDigits: 2 }
),
amountWhole: new Intl.NumberFormat( donationForm.locale,
{}
)
};
 
// currencyDisplay: 'narrowSymbol' fixes some issues like en-CO showing the ISO code
// but browser support is lacking, so wrap in a try/catch
try {
formatters.currencyFraction = new Intl.NumberFormat( donationForm.locale,
{ style: 'currency', currency: donationForm.currency, currencyDisplay: 'narrowSymbol' }
);
formatters.currencyWhole = new Intl.NumberFormat( donationForm.locale,
{ style: 'currency', currency: donationForm.currency, currencyDisplay: 'narrowSymbol', minimumFractionDigits: 0 }
);
} catch(e) {
formatters.currencyFraction = new Intl.NumberFormat( donationForm.locale,
{ style: 'currency', currency: donationForm.currency }
);
formatters.currencyWhole = new Intl.NumberFormat( donationForm.locale,
{ style: 'currency', currency: donationForm.currency, minimumFractionDigits: 0 }
);
}
 
donationForm.formatCurrency = function( amount ) {
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 );
} else {
return formatters.amountWhole.format( amount );
}
};
 
/* Localize the amount errors. Call when initialising form. */
donationForm.localizeErrors = function() {
var currency = documentdonationForm.paypalcontribution.currency_code.valuecurrency;
var minAmount = donationForm.minimums[ currency ];
 
$('.lp-error-smallamount').text( function( index, oldText ) {
return oldText.replace( '$1', minAmountdonationForm.formatAmount( donationForm.minLocal ) + ' \xa0' + currency );
});
 
if ( currency === 'USD' ) {
$('.lp-error-bigamount').text( function( index, oldText ) {
// we don't need to include the conversion
return oldText.replace( '$1', 10000 * minAmount )
$('.lp-error-bigamount').text( function( index, oldText ) {
.replace( '$2', currency )
return oldText.replace( '($31 $2) ', 'benefactors@wikimedia.org' );
.replace( '($1 $2) ', '' );
});
});
}
 
$('.lp-error-bigamount').text( function( index, oldText ) {
return oldText.replace( '$1', donationForm.formatAmount( donationForm.maxLocal ) )
.replace( '$2', currency )
.replace( '$3', 'benefactors@wikimedia.org' )
.replace( '$4', donationForm.formatAmount( donationForm.maxUSD ) );
});
};
 
 
function adjustHPC() {
/* Adjust amounts based on highest previous contribution (hpc)
or most recent contribution (mrc) parameter. Used for emails.
TODO: split data out? */
 
var hpcSet = mw.util.getParamValue('hpcSet');
// Look for 'hpc' parameter, then 'mrc'. If neither, then bail out.
var hpc = parseFloat( mw.util.getParamValue('hpc') );
if( isNaN(hpc) ) {
hpc = parseFloat( mw.util.getParamValue('mrc') );
if( isNaN(hpc) ) {
return;
}
}
 
// Look for 'hpc' parameter, then 'mrc'
var hpcSet = mw.util.getParamValue('hpcSet');
var hpc = parseFloat( mw.util.getParamValue('hpc') );
if( isNaN(hpc) ) {
hpc = parseFloat( mw.util.getParamValue('mrc') );
if( isNaN(hpc) ) {
if ( hpcSet ) {
// Allow using hpcSet even without hpc, for MG appeals
hpc = 0;
} else {
return;
}
}
}
 
var currency = $("input[name='currency_code']")donationForm.val()currency;
var language = mw.config.get('wgUserLanguage');
 
// If changing, please update https://docs.google.com/spreadsheets/d/1e02TsZ_bKDAS1BMVBCdyo9D7RGln_wCGnkg7IF5kU5s/edit
var radioAmountsData = {
var radioAmountsData = {
'USD' : {
"USD" : { // also used for CAD, AUD, NZD
'default' : [
"default" : [
[ 0, [ 5, 10, 20, 25, 35, 50, 100 ] ],
[ 0, [ 2.75, [ 5, [ 10, 15, 20, 35 25, 50 35, 100, 15050 ] ],
[ 5, [ 5, [ 10, [ 15, 20, 25, 35, 50, 100, 150 ] ],
[ 10, [ 10, [ 15, [ 20, 25, 35, 50, 75, 100, 250 ] ],
[ 15, [ 15, [ 20, [ 25, 35, 50, 75, 100, 150, 250 ] ],
[ 20, [ 20, [ 25, [ 30 35, 40, 50, 75, 100, 150, 250 ] ],
[ 25, [ 25, 30, [ 3540, [ 25, 50, 75, 100, 200, 250, 300150 ] ],
[ 35, [ 7535, [ 25, 50, 75, 100, 200, 300, 500 ] ],
[ 50, [ 50, 75, [ 100, [ 25200, 50300, 100, 150500, 250, 500, 1000750 ] ],
[ 75, [ 75, 100, [ 150, [ 50250, 100, 150500, 200, 350750, 500, 1000 ] ],
[ 200100, [ 100, 150, 200 250, 300 500, 400 750, 5001000, 1000 2500 ] ],
[ 150, [ 150, 200, 300, [ 500, [ 100, 250750, 500, 750, 1000, 1500, 2000 ] ],
[ 200, [ 200, 300, 500, [ 1000750, [ 500, 1000, 2000, 2500, 3000, 4000, 5000 ] ],
[ 500, [ 500, 750, 1000, 2500, 5000, 7500, 10000 ] ],
[ 1000, [ 1000, 2000, 3000, 4000, 5000, 7500, 10000 ] ],
'LTLA' : [
[ 03000, [ 33000, 104000, 155000, 206000, 357500, 5010000, 10012000 ] ],
],
[ 5, [ 5, 10, 20, 35, 50, 100, 150 ] ],
"FY2425_E1_T11_USD" : [ // Upgrade recurring +1 for lowest ask
[ 10, [ 10, 20, 35, 50, 75, 100, 150 ] ],
[ 0, [ 3.75, 5, 10, [ 1520, [ 15, 25, 35, 50, 75, 100, 250 ] ],
[ 5, [ 5, 10, [ 15, 20, [ 20, 30 35, 50, 75, 100, 150, 250 ] ],
[ 10, [ 10, 15, 20, [ 25, [ 25, 35, 50, 75, 100, 150, 250 ] ],
[ 15, [ 15, 20, 25, [ 35, [ 25, 50, 75, 100, 200, 250, 300 ] ],
[ 20, [ 20, 25, [ 7535, [ 25, 50, 75, 100, 200, 300, 500150 ] ],
[ 25, [ 25, 30, [ 10040, [ 25, 50, 100, 15075, 250 100, 500, 1000150 ] ],
[ 35, [ 35, 50, [ 15075, [ 50, 100, 150, 200, 350 300, 500, 1000 ] ],
[ 50, [ 50, 75, [ 200, [ 100, 150, 200, 300, 400 500, 500, 1000750 ] ],
[ 75, [ 75, 100, [ 500150, [ 100, 250, 500, 750, 1000, 1500, 2000 ] ],
[ 100, [ 100, 150, 250, 500, [ 1000750, [ 500, 1000, 2000, 2500, 3000, 4000, 5000 ] ],
[ 150, [ 150, 200, 300, 500, 750, 1000, 2000 ] ],
[ 200, [ 200, 300, 500, 750, 1000, 2500, 5000 ] ],
'midtier2018' : [
[ 0500, [ 3500, 5750, 101000, 202500, 305000, 507500, 10010000 ] ],
[ 51000, [ 51000, 102000, 203000, 354000, 505000, 1007500, 15010000 ] ],
[ 103000, [ 103000, 154000, 205000, 356000, 507500, 10010000, 15012000 ] ],
],
[ 15, [ 15, 20, 25, 35, 50, 100, 150 ] ],
"FY2425_E1_T14_USD" : [ // Upgrade recurring amount dynamically
[ 20, [ 20, 25, 35, 50, 75, 100, 150 ] ],
[ 0, [ 2.75, 5, [ 2510, [ 3520, 50, 7525, 100, 15035, 250, 50050 ] ],
[ 5, [ 2.75, 5, [ 3510, [ 5020, 75, 10025, 150, 25035, 350, 50050 ] ],
[ 10, [ 2.75, 10, [ 5015, [ 7520, 100, 15025, 200, 25035, 350, 50050 ] ],
[ 15, [ 3.50, 10, 20, [ 7530, [ 100, 15050, 200, 30075, 400, 500, 1000100 ] ],
[ 20, [ 3.75, 10, 25, [ 10035, [ 150, 20050, 250, 30075, 400, 500, 1000100 ] ],
[ 25, [ 4.50, 10, 25, [ 15035, [ 200, 25050, 300, 40075, 500, 1000, 2500100 ] ],
[ 35, [ 6.75, 15, 30, [ 20050, [ 500, 75075, 1000, 2000, 3500100, 5000, 7500150 ] ],
[ 75, [ 15.75, 50, 75, [ 500100, [ 750200, 1000, 1500, 2500300, 5000, 7500, 10000500 ] ],
[ 100, [ 24.75, 50, 75, 100, [ 1000200, [ 1000, 2000300, 3000, 4000, 5000, 7500, 10000500 ] ],
[ 150, [ 44.75, 100, 150, 250, 500, 750, 1000 ] ],
[ 200, [ 50, 100, 150, 250, 500, 750, 1000 ] ],
'LT2018' : [
[ 0500, [ 5150, 10250, 20.18300, 25500, 35750, 501000, 1002000 ] ],
[ 51000, [ 10 250, 15500, 20.18750, 351000, 502500, 1005000, 15010000 ] ],
[ 103000, [ 15 500, 20.181000, 252000, 353500, 505000, 1007500, 15010000 ] ],
],
[ 15, [ 20.18, 25, 35, 50, 75, 100, 250 ] ],
"FY2425_E1_T21_USD" : [ // Give less reactivation amount
[ 20, [ 25, 35, 50, 75, 100, 150, 250 ] ],
[ 0, [ 2.75, 5, 10, [ 2520, [ 30, 4025, 50, 7535, 100, 150, 25050 ] ],
[ 5, [ 2.75, 5, 10, [ 3520, [ 25, 50, 7535, 100, 200, 250, 30050 ] ],
[ 10, [ 5, 10, [15, 75, [ 2520, 50, 7535, 100, 20050, 300, 500100 ] ],
[ 15, [ 10, 15, 20, [ 100, [ 25, 50, 10035, 150, 25050, 500, 1000100 ] ],
[ 20, [ 15, 20, 25, [ 150, [ 5035, 100, 15050, 200, 35075, 500, 1000100 ] ],
[ 25, [ 20, 25, 35, [ 200, [ 10050, 150, 20075, 300, 400100, 500, 1000150 ] ],
[ 35, [ 25, 30, 40, [ 500, [ 10050, 250, 50075, 750, 1000100, 1500, 2018 150 ] ],
[ 75, [ 35, 50, 75, [ 1000100, [ 500, 1000200, 2018, 2500, 3000300, 4000, 5000 500 ] ],
[ 100, [ 75, 100, 150, 250, 500, 750, 1000 ] ],
]
[ 150, [ 100, 150, 250, 500, 750, 1000, 2500 ] ],
},
[ 200, [ 150, 200, 300, 500, 750, 1000, 2000 ] ],
'BRL' : [
[ 0500, [ 15200, 25300, 50500, 75750, 1001000, 1502500, 3005000 ] ],
[ 51000, [ 25500, 35750, 501000, 752500, 1005000, 2007500, 30010000 ] ],
[ 103000, [ 301000, 502000, 753000, 1004000, 1505000, 3007500, 50010000 ] ],
],
[ 15, [ 50, 75, 100, 150, 225, 300, 500 ] ],
// Direct Mail - fixed amounts
[ 20, [ 50, 100, 150, 225, 300, 400, 500 ] ],
"directmail" : [
[ 25, [ 75, 125, 200, 250, 300, 400, 500 ] ],
[ 0, [ 25, [ 35, [ 100 50, 150, 225100, 300150, 500250, 750, 1000300 ] ],
],
[ 75, [ 100, 150, 225, 300, 500, 1000, 1500 ] ],
"directmail250" : [
[ 100, [ 100, 150, 300, 500, 1000, 1500, 3000 ] ],
[ 0, [ 150250, [ 250300, 500, 750, 1000, 1500, 30002500, 5000 ] ],
]
[ 200, [ 500, 1000, 2000, 3000, 4000, 5000, 10000 ] ],
},
[ 500, [ 1000, 2500, 5000, 7500, 10000, 12500, 15000 ] ],
"EUR" : {
[ 1000, [ 1000, 2500, 5000, 7500, 10000, 12500, 15000 ] ]
"default" : [
],
[ 0, [ 2.50, 5, 10, 20, 25, 35, 50 ] ],
'JPY' : [
[ 5, [ 5, [ 010, [ 50015, 1000, 200020, 2500, 400035, 5000 50, 10000 100 ] ],
[ 10, [ 10, 15, [ 520, [ 1000 25, 1500, 250035, 4000, 500050, 10000, 15000100 ] ],
[ 15, [ 15, 20, [ 10 25, [ 1500, 200035, 3000, 400050, 5000 75, 10000, 15000100 ] ],
[ 20, [ 20, 25, [ 15 35, [ 2000, 250050, 3500, 500075, 7500100, 10000, 25000150 ] ],
[ 25, [ 25, [ 2030, [ 2500 40, 3500, 500050, 7500, 1000075, 15000 100, 25000 150 ] ],
[ 35, [ 35, 50, [ 2575, [ 3000100, 4000, 5000200, 7500, 10000300, 15000, 25000500 ] ],
[ 50, [ 50, 75, [ 35100, [ 2500200, 5000, 7500300, 10000, 20000500, 30000, 50000750 ] ],
[ 75, [ 75, 100, [ 75150, [ 2500250, 5000, 7500500, 10000, 20000750, 50000, 1000001000 ] ],
[ 100, [ 100, 150, [ 100250, [ 5000500, 10000, 15000, 20000750, 350001000, 50000, 1000002500 ] ],
[ 150, [ 150, 200, 300, [ 500, [ 10000, 25000750, 50000, 750001000, 100000, 150000, 2000002000 ] ],
[ 200, [ 200, 300, 500, 750, 1000, 2500, 5000 ] ],
],
[ 500, [ 500, 750, 1000, 2500, 5000, 7500, 10000 ] ],
'SEK' : [
[ 1000, [ 1000, 02000, [ 203000, 504000, 100, 2005000, 300, 5007500, 100010000 ] ],
[ 3000, [ 3000, 34000, [ 305000, 506000, 100, 2007500, 30010000, 500, 100012000 ] ],
],
[ 5, [ 50, 100, 150, 200, 300, 500, 1000 ] ],
"FY2425_E1_T11_EUR" : [ // Upgrade recurring +1 for lowest ask
[ 23, [ 50, 100, 200, 300, 500, 750, 1000 ] ]
[ 0, [ 3.50, 5, 10, 20, 25, 35, 50 ] ],
]
[ 5, [ 5, 10, 15, 20, 35, 50, 100 ] ],
};
[ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ],
radioAmountsData.AUD = radioAmountsData.USD;
[ 15, [ 15, 20, 25, 35, 50, 75, 100 ] ],
radioAmountsData.CAD = radioAmountsData.USD;
[ 20, [ 20, 25, 35, 50, 75, 100, 150 ] ],
radioAmountsData.GBP = radioAmountsData.USD;
[ 25, [ 25, 30, 40, 50, 75, 100, 150 ] ],
radioAmountsData.NZD = radioAmountsData.USD;
[ 35, [ 35, 50, 75, 100, 200, 300, 500 ] ],
radioAmountsData.EUR = radioAmountsData.USD;
[ 50, [ 50, 75, 100, 200, 300, 500, 750 ] ],
[ 75, [ 75, 100, 150, 250, 500, 750, 1000 ] ],
[ 100, [ 100, 150, 250, 500, 750, 1000, 2500 ] ],
[ 150, [ 150, 200, 300, 500, 750, 1000, 2000 ] ],
[ 200, [ 200, 300, 500, 750, 1000, 2500, 5000 ] ],
[ 500, [ 500, 750, 1000, 2500, 5000, 7500, 10000 ] ],
[ 1000, [ 1000, 2000, 3000, 4000, 5000, 7500, 10000 ] ],
[ 3000, [ 3000, 4000, 5000, 6000, 7500, 10000, 12000 ] ]
],
"FY2425_E1_T14_EUR" : [ // Upgrade recurring amount dynamically
[ 0, [ 2.50, 5, 10, 20, 25, 35, 50 ] ],
[ 5, [ 2.50, 5, 10, 20, 25, 35, 50 ] ],
[ 10, [ 2.50, 10, 15, 20, 25, 35, 50 ] ],
[ 15, [ 2.50, 10, 20, 30, 50, 75, 100 ] ],
[ 20, [ 3.50, 10, 25, 35, 50, 75, 100 ] ],
[ 25, [ 4.25, 10, 25, 35, 50, 75, 100 ] ],
[ 35, [ 6.25, 15, 30, 50, 75, 100, 150 ] ],
[ 75, [ 15, 50, 75, 100, 200, 300, 500 ] ],
[ 100, [ 25, 50, 75, 100, 200, 300, 500 ] ],
[ 150, [ 45, 100, 150, 250, 500, 750, 1000 ] ],
[ 200, [ 50, 100, 150, 250, 500, 750, 1000 ] ],
[ 500, [ 150, 250, 300, 500, 750, 1000, 2000 ] ],
[ 1000, [ 250, 500, 750, 1000, 2500, 5000, 10000 ] ],
[ 3000, [ 500, 1000, 2000, 3500, 5000, 7500, 10000 ] ]
],
"FY2425_E1_T21_EUR" : [ // Give less reactivation amount
[ 0, [ 2.50, 5, 10, 20, 25, 35, 50 ] ],
[ 5, [ 2.50, 5, 10, 20, 25, 35, 50 ] ],
[ 10, [ 5, 10, 15, 20, 35, 50, 100 ] ],
[ 15, [ 10, 15, 20, 25, 35, 50, 100 ] ],
[ 20, [ 15, 20, 25, 35, 50, 75, 100 ] ],
[ 25, [ 20, 25, 35, 50, 75, 100, 150 ] ],
[ 35, [ 25, 30, 40, 50, 75, 100, 150 ] ],
[ 75, [ 35, 50, 75, 100, 200, 300, 500 ] ],
[ 100, [ 75, 100, 150, 250, 500, 750, 1000 ] ],
[ 150, [ 100, 150, 250, 500, 750, 1000, 2500 ] ],
[ 200, [ 150, 200, 300, 500, 750, 1000, 2000 ] ],
[ 500, [ 200, 300, 500, 750, 1000, 2500, 5000 ] ],
[ 1000, [ 500, 750, 1000, 2500, 5000, 7500, 10000 ] ],
[ 3000, [ 1000, 2000, 3000, 4000, 5000, 7500, 10000 ] ]
]
},
"GBP" : {
"default" : [
[ 0, [ 2, 5, 10, 20, 25, 35, 50 ] ],
[ 5, [ 5, 10, 15, 20, 35, 50, 100 ] ],
[ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ],
[ 15, [ 15, 20, 25, 35, 50, 75, 100 ] ],
[ 20, [ 20, 25, 35, 50, 75, 100, 150 ] ],
[ 25, [ 25, 30, 40, 50, 75, 100, 150 ] ],
[ 35, [ 35, 50, 75, 100, 200, 300, 500 ] ],
[ 50, [ 50, 75, 100, 200, 300, 500, 750 ] ],
[ 75, [ 75, 100, 150, 250, 500, 750, 1000 ] ],
[ 100, [ 100, 150, 250, 500, 750, 1000, 2500 ] ],
[ 150, [ 150, 200, 300, 500, 750, 1000, 2000 ] ],
[ 200, [ 200, 300, 500, 750, 1000, 2500, 5000 ] ],
[ 500, [ 500, 750, 1000, 2500, 5000, 7500, 10000 ] ],
[ 1000, [ 1000, 2000, 3000, 4000, 5000, 7500, 10000 ] ],
[ 3000, [ 3000, 4000, 5000, 6000, 7500, 10000, 12000 ] ]
],
"FY2425_E1_T11_GBP" : [ // Upgrade recurring +1 for lowest ask
[ 0, [ 3, 5, 10, 20, 25, 35, 50 ] ],
[ 5, [ 5, 10, 15, 20, 35, 50, 100 ] ],
[ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ],
[ 15, [ 15, 20, 25, 35, 50, 75, 100 ] ],
[ 20, [ 20, 25, 35, 50, 75, 100, 150 ] ],
[ 25, [ 25, 30, 40, 50, 75, 100, 150 ] ],
[ 35, [ 35, 50, 75, 100, 200, 300, 500 ] ],
[ 50, [ 50, 75, 100, 200, 300, 500, 750 ] ],
[ 75, [ 75, 100, 150, 250, 500, 750, 1000 ] ],
[ 100, [ 100, 150, 250, 500, 750, 1000, 2500 ] ],
[ 150, [ 150, 200, 300, 500, 750, 1000, 2000 ] ],
[ 200, [ 200, 300, 500, 750, 1000, 2500, 5000 ] ],
[ 500, [ 500, 750, 1000, 2500, 5000, 7500, 10000 ] ],
[ 1000, [ 1000, 2000, 3000, 4000, 5000, 7500, 10000 ] ],
[ 3000, [ 3000, 4000, 5000, 6000, 7500, 10000, 12000 ] ]
],
"FY2425_E1_T14_GBP" : [ // Upgrade recurring amount dynamically
[ 0, [ 2, 5, 10, 20, 25, 35, 50 ] ],
[ 5, [ 2, 5, 10, 20, 25, 35, 50 ] ],
[ 10, [ 2, 10, 15, 20, 25, 35, 50 ] ],
[ 15, [ 2, 10, 20, 30, 50, 75, 100 ] ],
[ 20, [ 3, 10, 25, 35, 50, 75, 100 ] ],
[ 25, [ 4, 10, 25, 35, 50, 75, 100 ] ],
[ 35, [ 6, 15, 30, 50, 75, 100, 150 ] ],
[ 75, [ 15, 50, 75, 100, 200, 300, 500 ] ],
[ 100, [ 20, 50, 75, 100, 200, 300, 500 ] ],
[ 150, [ 40, 100, 150, 250, 500, 750, 1000 ] ],
[ 200, [ 45, 100, 150, 250, 500, 750, 1000 ] ],
[ 500, [ 125, 250, 300, 500, 750, 1000, 2000 ] ],
[ 1000, [ 200, 500, 750, 1000, 2500, 5000, 10000 ] ],
[ 3000, [ 400, 1000, 2000, 3500, 5000, 7500, 10000 ] ]
],
"FY2425_E1_T21_GBP" : [ // Give less reactivation amount
[ 0, [ 2, 5, 10, 20, 25, 35, 50 ] ],
[ 5, [ 2, 5, 10, 20, 25, 35, 50 ] ],
[ 10, [ 5, 10, 15, 20, 35, 50, 100 ] ],
[ 15, [ 10, 15, 20, 25, 35, 50, 100 ] ],
[ 20, [ 15, 20, 25, 35, 50, 75, 100 ] ],
[ 25, [ 20, 25, 35, 50, 75, 100, 150 ] ],
[ 35, [ 25, 30, 40, 50, 75, 100, 150 ] ],
[ 75, [ 35, 50, 75, 100, 200, 300, 500 ] ],
[ 100, [ 75, 100, 150, 250, 500, 750, 1000 ] ],
[ 150, [ 100, 150, 250, 500, 750, 1000, 2500 ] ],
[ 200, [ 150, 200, 300, 500, 750, 1000, 2000 ] ],
[ 500, [ 200, 300, 500, 750, 1000, 2500, 5000 ] ],
[ 1000, [ 500, 750, 1000, 2500, 5000, 7500, 10000 ] ],
[ 3000, [ 1000, 2000, 3000, 4000, 5000, 7500, 10000 ] ]
]
},
"JPY" : [
[ 0, [ 500, 1000, 2000, 2500, 4000, 5000, 10000 ] ],
[ 1000, [ 1000, 1500, 2500, 4000, 5000, 10000, 15000 ] ],
[ 1500, [ 1500, 2000, 3000, 4000, 5000, 10000, 15000 ] ],
[ 2000, [ 2000, 2500, 3500, 5000, 7500, 10000, 25000 ] ],
[ 2500, [ 2500, 3500, 5000, 7500, 10000, 15000, 25000 ] ],
[ 3000, [ 3000, 4000, 5000, 7500, 10000, 15000, 25000 ] ],
[ 2500, [ 2500, 5000, 7500, 10000, 20000, 30000, 50000 ] ],
[ 2500, [ 2500, 5000, 7500, 10000, 20000, 50000, 100000 ] ],
[ 5000, [ 5000, 10000, 15000, 20000, 35000, 50000, 100000 ] ],
[ 10000, [ 10000, 25000, 50000, 75000, 100000, 150000, 200000 ] ]
],
"SEK" : [
[ 0, [ 30, 100, 150, 200, 500, 750, 1000 ] ],
[ 50, [ 50, 100, 150, 200, 300, 750, 1000 ] ],
[ 200, [ 50, 100, 200, 300, 500, 750, 1000 ] ]
]
};
radioAmountsData.AUD = radioAmountsData.USD;
radioAmountsData.CAD = radioAmountsData.USD;
radioAmountsData.NZD = radioAmountsData.USD;
 
// Major gifts appeals, hacky but this is easier than adding a load of new forms to maintain
var appealAmountsData = {
var currencyList = [ 'USD', 'CAD', 'AUD', 'NZD', 'GBP', 'EUR' ]; // close enough
'USD' : [
for ( let i = 0; i < currencyList.length; i++ ) {
[ 0, [ 5, 10, 20 ] ],
radioAmountsData[ currencyList[i] ].MG_2024_500 = [ [ 0, [ 500, 10750, [1000, 1250, 101500, 201750, 2000 50] ] ],;
radioAmountsData[ currencyList[i] ].MG_2024_650 = [ [ 0, [ 650, 20750, [1000, 1250, 201500, 301750, 2000 50] ] ],;
}
[ 35, [ 20, 30, 50 ] ],
[ 50, [ 20, 50, 100 ] ],
[ 75, [ 50, 75, 100 ] ],
[ 100, [ 75, 100, 150 ] ],
[ 150, [ 75, 100, 200 ] ],
[ 200, [ 100, 200, 300 ] ]
],
'JPY' : [
[ 0, [ 300, 500, 1000 ] ],
[ 3, [ 500, 1000, 1500 ] ],
[ 5, [ 1000, 1500, 2000 ] ],
[ 10, [ 1500, 2000, 5000 ] ],
[ 20, [ 2000, 3000, 5000 ] ],
[ 50, [ 2000, 5000, 10000 ] ],
[ 100, [ 5000, 10000, 15000 ] ]
],
'SEK' : [
[ 0, [ 20, 50, 100 ] ],
[ 3, [ 30, 50, 100 ] ],
[ 5, [ 50, 100, 150 ] ],
[ 15, [ 100, 150, 200 ] ],
[ 23, [ 100, 200, 300 ] ],
[ 38, [ 100, 200, 500 ] ],
[ 75, [ 100, 500, 750 ] ],
[ 112, [ 100, 500, 1000 ] ]
]
};
appealAmountsData.AUD = appealAmountsData.USD;
appealAmountsData.CAD = appealAmountsData.USD;
appealAmountsData.GBP = appealAmountsData.USD;
appealAmountsData.NZD = appealAmountsData.USD;
appealAmountsData.EUR = appealAmountsData.USD;
 
var formatsappealAmountsData = {
"USD" : [ // also used for CAD, AUD, NZD, GBP, EUR
"USD" : "$\t",
[ 0, [ 5, "EUR" :10, { 20 ] ],
[ 10, [ 10, 20, 50 ] "en" : "€\t"],
[ 20, [ 20, 30, 50 ] "cy" : "€\t"],
[ 35, [ 20, 30, 50 ] "ga" : "€\t"],
[ 50, [ 20, 50, 100 ] "mt" : "€\t"],
[ 75, [ 50, 75, 100 ] "nl" : "€ \t"],
[ 100, [ 75, 100, 150 ] ],
"lv" : "€ \t",
[ 150, [ 75, 100, 200 ] ],
"tr" : "€ \t",
[ 200, [ 100, 200, 300 ] ]
"default" : "\t €"
],
},
"AUDJPY" : "$\t",[
[ 0, [ 300, "CAD" :500, { 1000 ] ],
[ 3, [ 500, 1000, 1500 ] "fr" : "\t $"],
[ 5, [ 1000, 1500, 2000 ] "default" : "$\t"],
[ 10, [ 1500, 2000, }5000 ] ],
[ 20, [ 2000, 3000, "GBP"5000 :] "£\t"],
[ 50, [ 2000, 5000, 10000 "NZD"] : "$\t"],
[ 100, [ 5000, 10000, 15000 ] ]
"JPY" : "¥\t",
],
"SEK" : "\t kr",
"BRLSEK" : "R$\t"[
[ 0, [ 20, 50, 100 ] ],
};
[ 3, [ 30, 50, 100 ] ],
[ 5, [ 50, 100, 150 ] ],
[ 15, [ 100, 150, 200 ] ],
[ 23, [ 100, 200, 300 ] ],
[ 38, [ 100, 200, 500 ] ],
[ 75, [ 100, 500, 750 ] ],
[ 112, [ 100, 500, 1000 ] ]
]
};
appealAmountsData.AUD = appealAmountsData.USD;
appealAmountsData.CAD = appealAmountsData.USD;
appealAmountsData.GBP = appealAmountsData.USD;
appealAmountsData.NZD = appealAmountsData.USD;
appealAmountsData.EUR = appealAmountsData.USD;
 
// Radio button amounts
var format = formats[currency][language] || formats[currency]["default"] || formats[currency] || '\t';
var radioAmounts = pickAmountArray( radioAmountsData, currency, hpc, hpcSet );
if ( radioAmounts.length ) {
// Change buttons
for (var j = 0; j < radioAmounts.length; j++) {
var $radio = $("#input_amount_" + j);
var $label = $("label[for='input_amount_" + j + "']");
$radio.val( radioAmounts[j] );
$label.text( donationForm.formatCurrency( radioAmounts[j] ) );
}
}
 
// Radio buttonAppeal amounts
var radioAmountsappealAmounts = pickAmountArray( radioAmountsDataappealAmountsData, currency, hpc, hpcSet );
if ( radioAmountsappealAmounts.length ) {
var appealAmountString = appealAmounts.map( donationForm.formatCurrency ).join( ', ');
// Change buttons
$('.consider-amounts').html(appealAmountString);
for (var j = 0; j < radioAmounts.length; j++) {
}
var $radio = $("#input_amount_" + j);
var $label = $("label[for='input_amount_" + j + "']");
$radio.val( radioAmounts[j] );
$label.text( format.replace('\t', radioAmounts[j]) );
}
}
 
// Appeal amounts
var appealAmounts = pickAmountArray( appealAmountsData, currency, hpc, hpcSet );
if ( appealAmounts.length ) {
// Build string
var appealAmountString = '';
for( var k = 0; k < appealAmounts.length; k++ ) {
appealAmountString += format.replace('\t', appealAmounts[k]) + ', ';
}
appealAmountString = appealAmountString.trim();
 
$('.consider-amounts').html(appealAmountString);
}
 
}
 
function pickAmountArray( data, currency, hpc, hpcSet ) {
/**
* Choose the amounts for radio buttons / appeal based on hpc
* @param {Object} data
* @param {String} currency
* @param {Number} hpc
* @param {String} hpcSet
* @return {Array} Array of amounts (as numbers)
*/
 
var set, amounts;
 
if ( !(currency in data) ) {
return [];
}
}
 
if ( $.isArray(data[currency]) ) {
// No variant sets
set = data[currency];
} else {
// We need to go deeper. Check the variants.
if ( hpcSet in data[currency] ) {
set = data[currency][hpcSet];
} else {
set = data[currency]['default'];
}
}
}
}
 
// Find correct amount array for this hpc
for (var i = 0; i < set.length; i++) {
if ( set[i][0] > hpc ) {
break;
}
}
amounts = set[i][1];
}
}
 
return amounts;
 
}
 
function preSelect() {
/* Check for a 'preSelect' url parameter, and select that option.
If there isn't an option, add it to the "Other" box and select that */
var preSelectAmount = parseFloat( mw.util.getParamValue('preSelect') );
if ( preSelectAmount > 0 ) {
var $preSelectOption = $('input[name="amount"][value="' + preSelectAmount + '"]');
if ( $preSelectOption.length ) {
// Select existing input
$preSelectOption.prop('checked', true);
} else {
$('#input_amount_other_box').val( preSelectAmount );
$('#input_amount_other').prop('checked', true);
}
}
donationForm.updateFeeDisplay();
}
}
}
 
function addCardTypesClass(country) {
/**
* Add card types class to credit card button, so we can show correct logos
* Banner equivalent: https://meta.wikimedia.org/wiki/MediaWiki:FundraisingBanners/LocalizeJS-2017.js
* @param {String} country ISO code
*/
var cardTypes = {
// Big 6
'US' : 'vmad',
'CA' : 'vma',
'GB' : 'vmaj',
'IE' : 'vmaj',
'AU' : 'vmaj',
'NZ' : 'vma',
// Euro countries
'AT' : 'vmaj',
'BE' : 'vmaj',
'ES' : 'vmaj',
'FR' : 'CBvmavma', // Adyen - Carte Bancaire was removed
'IT' : 'vmaj',
'LU' : 'vmaj',
'LV' : 'vma',
'NL' : 'vmaj',
'PT' : 'vmaj',
'SK' : 'vmaj',
'GR' : 'vma',
// Others
// Others
'DK' : 'vma',
'HUCZ' : 'vmavmad',
'ILDK' : 'vmadvma', // Adyen
'JPHU' : 'vmajvma',
'MYIL' : 'vmajvmad', // Adyen
'NOJP' : 'vmavmaj',
'PLMY' : 'vmavmaj',
'RONO' : 'vma',
'SEPL' : 'vma',
'UARO' : 'vma', // Adyen
'ZASE' : 'vmvma',
'UA' : 'vma', // Adyen
};
'ZA' : 'vm',
if ( cardTypes[country] ) {
'ZZ' : 'vmad' // For testing
$('.paymentmethod-cc').addClass('cctypes-' + cardTypes[country] );
};
}
if ( cardTypes[country] ) {
$('.paymentmethod-cc').addClass('cctypes-' + cardTypes[country] );
$('.cc-text-label').addClass('sr-only');
}
}
 
/* Form functions */
function clearOther(box) {
document.getElementById("'input_amount_other"').checked = true;
box.value = "";
}
 
function selectOther() {
document.getElementById("'input_amount_other"').checked = true;
}
 
function selectAmount() {
$('#input_amount_other_box').val('');
$('input[name="amountGiven"]').val('');
}
 
/* -- Moved from Template:2012FR/Form-section/Processing/Default -- */
/**
donationForm.redirectPayment = function(paymentMethod, paymentSubMethod, skipValidation) {
* Validate form, and prep most of the parameters
*
* @param {string} paymentMethod - method e.g. 'cc', 'paypal'
* @param {string} paymentSubMethod - submethod e.g. 'rtbt_ideal' (a submethod of 'rtbt')
* @param {string} skipAmountValidation - skip validating amount for PayPal forced to USD
*/
donationForm.redirectPayment = function( paymentMethod, paymentSubMethod, skipAmountValidation ) {
 
if ( donationForm.validate( skipAmountValidation ) ) {
 
var params = {};
 
params.currency = donationForm.currency;
var form = document.paypalcontribution; // we should really change this some day
params.country = donationForm.country;
 
// Overrides for specific cc gateways
if ( skipValidation || donationForm.validate() ) {
if ( paymentMethod === 'cc-adyen' ) {
params.payment_method = 'cc';
params.gateway = 'adyen';
} else if ( paymentMethod === 'cc-dlocal' ) {
params.payment_method = 'cc';
params.gateway = 'astropay';
} else {
params.payment_method = paymentMethod;
}
 
if ( params.payment_method === 'cc' && params.country === 'ZA' ) {
if (typeof paymentSubMethod == 'undefined') {
params.gateway = 'astropay';
paymentSubMethod = '';
}
}
var paymentsURL = 'https://payments.wikimedia.org/index.php/Special:GatewayFormChooser';
 
if ( paymentSubMethod ) {
form.action = paymentsURL;
params.payment_submethod = paymentSubMethod;
}
 
let frequency = donationForm.getFrequency();
if (typeof paymentSubMethod == 'undefined') {
if ( frequency === 'monthly' ) {
paymentSubMethod = '';
params.recurring = '1';
}
params.frequency_unit = 'month';
} else if ( frequency === 'annual' ) {
params.recurring = '1';
params.frequency_unit = 'year';
}
 
params.uselang = mw.config.get('wgPageContentLanguage'); // see T281285 for why not wgUserLanguage
// WorldPay override for cc
if ( paymentMethod === 'cc-wp' ) {
paymentMethod = 'cc';
form.payment_method.value = 'cc';
form.gateway.value = 'worldpay';
form.ffname.value = 'worldpay';
}
 
if ( params.uselang === 'pt' && params.country === 'BR' ) {
// Adyen override for cc
params.uselang = 'pt-br';
if ( paymentMethod === 'cc-adyen' ) {
}
paymentMethod = 'cc';
if ( params.uselang === 'es' &&
form.payment_method.value = 'cc';
( params.country === 'AR' || params.country === 'CL' ||
form.gateway.value = 'adyen';
params.country === 'CO' || params.country === 'MX' ||
form.ffname.value = 'adyen';
params.country === 'PE' || params.country === 'UY' ||
}
params.country === 'US' )
) {
params.uselang = 'es-419';
}
 
var amount = donationForm.getAmount();
var frequency = $("input[name='frequency']:checked").val();
if ( $('#ptf-checkbox').prop('checked') ) {
if( frequency !== 'monthly' ){
amount = amount + donationForm.calculateFee( amount );
frequency = 'onetime';
donationForm.extraData.ptf = 1;
form.recurring.value = 'false';
}
} else {
params.amount = amount;
form.recurring.value = 'true';
}
 
// Email optin
form.payment_method.value = paymentMethod;
if ( $('input[name="opt_in"]').length > 0 ) {
form.payment_submethod.value = paymentSubMethod;
var opt_inValue = $('input[name="opt_in"]:checked').val();
params.opt_in = opt_inValue; // donationForm.validate() already checked it's 1 or 0
}
 
if ( mw.util.getParamValue( 'pym_variant' ) ) {
var full_dotted_payment_method = paymentMethod;
params.variant = mw.util.getParamValue( 'pym_variant' );
if ( form.recurring.value == 'true' ) {
}
full_dotted_payment_method = 'r' + full_dotted_payment_method;
if ( params.recurring && params.variant && params.variant.match( /monthlyConvert/ ) ) {
}
// Post-payments monthly convert makes no sense if it's already recurring
if ( paymentSubMethod ) {
// Avoid things like T312905
full_dotted_payment_method = form.payment_method.value + '.' + paymentSubMethod;
delete params.variant;
}
}
 
// TODO: refactor this to a list of parameters to pass unchanged
donationForm.extraData.time = Math.round( (Date.now() - donationForm.loadedTime)/1000 );
// or just pass everything by default?
if ( mw.util.getParamValue( 'pym_appeal' ) ) {
params.appeal = mw.util.getParamValue( 'pym_appeal' );
}
// https://phabricator.wikimedia.org/T381405
if ( mw.util.getParamValue( 'contact_id' ) ) {
params.contact_id = mw.util.getParamValue( 'contact_id' );
}
if ( mw.util.getParamValue( 'contact_hash' ) ) {
params.contact_hash = mw.util.getParamValue( 'contact_hash' );
}
// SMS
if ( mw.util.getParamValue( 'recipient_id' ) ) {
params.recipient_id = mw.util.getParamValue( 'recipient_id' );
}
 
// Monthly convert
form.utm_medium.value = mw.util.getParamValue( 'utm_medium' );
if ( mc ) { // check just in-case this wasn't loaded for some reason
form.utm_campaign.value = mw.util.getParamValue( 'utm_campaign' );
mc.main( params, donationForm.finalStep );
form.utm_source.value = donationForm.buildUtmSource() + '.' + full_dotted_payment_method;
} else {
form.utm_key.value = donationForm.buildUtmKey( donationForm.extraData );
donationForm.finalStep( params );
}
 
} else {
form.method = 'GET';
donationForm.extraData.validateError = 1; // Flag they had an error, even if fixed later
form.submit();
}
} else {
donationForm.extraData.validateError = 1; // Flag they had an error, even if fixed later
}
 
return false; // don't submit if called by a button
};
 
/**
* Build afinal utm_sourcetracking valueparameters, includingand thesubmit landingto page info.payments
* @param {Object} params
*/
donationForm.finalStep = function( params ) {
 
var url = new URL('https://payments.wikimedia.org/index.php/Special:GatewayChooser');
 
// Skip form chooser for Apple Pay / Google Pay
if ( params.payment_method === 'apple' || params.payment_method === 'google' ) {
url = new URL('https://payments.wikimedia.org/index.php/Special:AdyenCheckoutGateway');
}
 
// Skip form chooser for Venmo
if ( params.payment_method === 'venmo' ) {
url = new URL('https://payments.wikimedia.org/index.php/Special:BraintreeGateway');
}
 
donationForm.extraData.time = Math.round( (Date.now() - donationForm.loadedTime)/1000 );
 
// Tracking data
params.wmf_medium = mw.util.getParamValue( 'wmf_medium' ) || mw.util.getParamValue( 'utm_medium' );
params.wmf_campaign = mw.util.getParamValue( 'wmf_campaign' ) || mw.util.getParamValue( 'utm_campaign' );
params.wmf_source = donationForm.buildTrackingSource( params );
params.wmf_key = donationForm.buildTrackingKey( donationForm.extraData );
if ( document.referrer ) { // TODO: do we need this?
// Strip protocol to stop firewall complaining
params.referrer = document.referrer.replace(/https?:\/\//i, '');
}
 
for ( var key of Object.keys( params ) ) {
url.searchParams.set( key, params[key] );
}
 
if ( window.top !== window.self ) {
// In a frame, open payments in a new tab
window.open( url.toString() );
} else {
window.location.href = url.toString();
}
};
 
/**
* Build a wmf_source value, including the landing page info.
*
* Own function so it can be overriden for weird tests
* Note this doesn't include payment method, that's added in redirectPayment method
*
* @returnparam {stringObject} utm_sourceparams
* @return {string} wmf_source
*/
donationForm.buildUtmSourcebuildTrackingSource = function( params ) {
 
var utm_sourcewmf_source = mw.util.getParamValue( 'utm_sourcewmf_source' ) +|| 'mw.util.getParamValue( 'utm_source' );
wmf_source += '.';
 
var fullDottedPaymentMethod = params.payment_method;
var getParam = function( param, removeText, dflt ) {
if ( params.recurring ) {
if ( mw.util.getParamValue( param ) ) {
fullDottedPaymentMethod = 'r' + fullDottedPaymentMethod;
return mw.util.getParamValue( param ).replace( removeText, '' );
}
} else {
if ( params.payment_submethod ) {
return dflt;
fullDottedPaymentMethod = fullDottedPaymentMethod + '.' + params.payment_submethod;
}
}
};
 
/* Get URL parameter, but remove parts using old format. Allow fallback to a default value */
/* The landing page info, separated by ~. This mostly exists for legacy reasons */
var getParam = function( param, removeText, dflt ) {
utm_source += getParam( 'template' , 'Lp-layout' , 'default' ) + '~';
if ( mw.util.getParamValue( param ) ) {
utm_source += getParam( 'appeal-template' , 'Appeal-template-' , 'default' ) + '~';
return mw.util.getParamValue( param ).replace( removeText, '' );
utm_source += getParam( 'appeal' , 'Appeal-' , 'default' ) + '~';
} else {
utm_source += getParam( 'form-template' , 'Form-template-' , 'default' ) + '~';
return dflt;
utm_source += getParam( 'form-countryspecific', 'Form-countryspecific-', 'control' );
}
};
 
/* The landing page info, separated by ~. This mostly exists for legacy reasons */
return utm_source;
wmf_source += getParam( 'template' , 'Lp-layout' , 'default' ) + '~';
wmf_source += getParam( 'appeal-template' , 'Appeal-template-' , 'default' ) + '~';
wmf_source += getParam( 'appeal' , 'Appeal-' , 'default' ) + '~';
wmf_source += getParam( 'form-template' , 'Form-template-' , 'default' ) + '~';
wmf_source += getParam( 'form-countryspecific', 'Form-countryspecific-', 'control' );
 
wmf_source += '.' + fullDottedPaymentMethod;
 
return wmf_source;
 
};
 
/**
* Build a string for utm_keywmf_key from extra tracking data
*
* @param {Object} data
* @return {string} utm_keywmf_key
*/
donationForm.buildUtmKeybuildTrackingKey = function(data) {
var existingKey = mw.util.getParamValue( 'wmf_key' ) || mw.util.getParamValue( 'utm_key' ),
var dataArray = [];
dataArray = [];
for (var key in data) {
 
if (data.hasOwnProperty(key)) {
if ( existingKey ) {
dataArray.push( key + '_' + data[key] );
dataArray.push( existingKey );
}
}
}
for (var key in data) {
return dataArray.join('.');
if (data.hasOwnProperty(key)) {
dataArray.push( key + '_' + data[key] );
}
}
return dataArray.join('~');
};
 
/* Return amount selected or input */
donationForm.getAmount = function() {
var form = document.paypalcontribution;forms.donateForm,
var amount = null;
donationForm.extraData.otherAmt = 0;
 
// If there are some amount radio buttons, then look for the checked one
if ( form.amount ) {
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 ) {
amount = donationForm.parseOtherAmount( form.input_amount_other_box.value );
donationForm.extraData.otherAmt = 1;
}
 
return amount;
// Check the "other" amount box
if ( form.input_amount_other_box.value !== '' ) {
var otherAmount = form.input_amount_other_box.value;
otherAmount = otherAmount.replace(/[,.](\d)$/, '\:$10');
otherAmount = otherAmount.replace(/[,.](\d)(\d)$/, '\:$1$2');
otherAmount = otherAmount.replace(/[\$£€¥,.]/g, '');
otherAmount = otherAmount.replace(/:/, '.');
form.amountGiven.value = otherAmount; // TODO: change this
amount = otherAmount;
donationForm.extraData.otherAmt = 1;
}
 
};
amount = parseFloat(amount);
 
/**
if ( isNaN(amount) ) {
* Parse Other field value into amount
return 0;
*
} else {
* Does some awful regex stuff to rm symbols and turn the string into a number
return amount;
* 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 ) {
var amount;
 
value = value.replace(/[,.](\d)$/, '\:$10');
};
value = value.replace(/[,.](\d)(\d)$/, '\:$1$2');
value = value.replace(/[\$£€¥,.]/g, '');
value = value.replace(/:/, '.');
 
amount = parseFloat( value );
if ( isNaN( amount ) ) {
return 0;
} else {
return amount;
}
};
 
/**
* Validate the form.
*/
donationForm.validate = function( skipAmountValidation ) {
 
var error = false;
var form = document.paypalcontributionforms.donateForm;
 
// Reset all errors
$('.lp-haserror').removeClass('lp-haserror');
$('.lp-error').hide();
 
if ( !skipAmountValidation if (&& !donationForm.validateAmount() ) {
error = true;
}
}
 
if ( form.opt_in ) {
if ( $("'input[name='"opt_in'"]:checked"').val() === undefined ) {
$('#error-optin').show().focus();
error = true;
} else {
$('#error-optin').hide();
}
form.variant.value = 'emailExplain';
}
}
}
 
return !error;
};
 
Line 740 ⟶ 1,060:
donationForm.validateAmount = function() {
 
var amount = donationForm.getAmount();
var currency = document.paypalcontribution.currency_code.value;
var minAmount = donationForm.minimums[ currency ] || 1;
 
if ( amount === null || isNaN(amount) || amount <= 0 || amount < minAmountdonationForm.minLocal ) {
$('.amount-options').addClass('lp-haserror');
$('.lp-error-smallamountbigamount').showhide();
$('.lp-error-smallamount').show().focus();
return false;
return false;
} else if ( amount > 10000 * minAmount ) {
} else if ( amount > donationForm.maxLocal ) {
$('.amount-options').addClass('lp-haserror');
$('.amount-options').addClass('lp-haserror');
$('.lp-error-bigamount').show();
$('.lp-error-bigamount').show().focus();
return false;
return false;
} else {
} else {
$('.amount-options').removeClass('lp-haserror');
$('.amount-options').removeClass('lp-haserror');
$('.lp-error-smallamount, .lp-error-bigamount').hide();
$('.lp-error-smallamount, .lp-error-bigamount').hide();
return true;
return true;
}
}
 
};
 
donationForm.toggleMonthlygetFrequency = function(monthly) {
return document.forms.donateForm.dataset.frequency || 'onetime';
if (monthly) {
};
$('#form-wrapper').addClass('form-monthly');
 
} else {
donationForm.setFrequency = function( frequency ) {
$('#form-wrapper').removeClass('form-monthly');
// TODO: add some validation to reject invalid frequency values
}
let form = document.forms.donateForm;
 
form.frequency.value = frequency; // change input
form.dataset.frequency = frequency;
};
 
/* Wrapper for compatibility with old forms */
donationForm.toggleMonthly = function( monthly ) {
if ( monthly ) {
donationForm.setFrequency( 'monthly' );
} else {
donationForm.setFrequency( 'onetime' );
}
};
 
donationForm.updateFeeDisplay = function() {
var feeAmountselectedAmount = donationForm.calculateFeegetAmount( donationForm.getAmount );,
feeAmount = donationForm.calculateFee( selectedAmount ),
$('.ptf-checkbox-label span').text( feeAmount );
feeText;
$('.ptf').slideDown();
 
feeText = donationForm.formatCurrency( feeAmount );
 
$('.ptf label span').text( feeText );
if ( selectedAmount + feeAmount <= donationForm.maxLocal ) {
$('.ptf').slideDown();
}
};
 
Line 780 ⟶ 1,119:
*/
donationForm.calculateFee = function( amount ) {
// var currency = frb.getCurrency(mw.centralNotice.data.country),
// feeMultiplier = 0.04,
// feeMinimum = frb.amounts.feeMinimums[currency] || 1,
// feeAmount = amount * feeMultiplier;
 
// Minimum fee/PTF amounts. Default is 0.35.
var feeMultiplier = 0.04,
// Updated 2019-05-21 to approx 0.35 USD equivalent
feeMinimum = 1,
var feeMinimums = {
feeAmount = amount * feeMultiplier;
'DKK' : 2,
'HUF' : 100,
'ILS' : 1.2,
'INR' : 4,
'JPY' : 35,
'MYR' : 1,
'NOK' : 3,
'PLN' : 1.35,
'CZK' : 7.5,
'RON' : 1.5,
'SEK' : 3,
'UAH' : 10,
'ZAR' : 5,
// Latin America // Updated 2024-08-22 to approx 0.35 USD equivalent
'BRL' : 1.75,
'ARS' : 300,
'CLP' : 300,
'COP' : 1400,
'MXN' : 6,
'PEN' : 1.2,
'UYU' : 14
};
 
var feeMultiplier = 0.04,
if ( feeAmount < feeMinimum ) {
feeMinimum = feeMinimums[ donationForm.currency ] || 0.35,
feeAmount = feeMinimum;
feeAmount = amount * feeMultiplier;
}
 
return parseFloat( feeAmount.toFixed(2) );
if ( feeAmount < feeMinimum ) {
feeAmount = feeMinimum;
}
return parseFloat( feeAmount.toFixed(2) );
};
 
 
donationForm.initOptin = function() {
$('.optin-options').on('change', function(e) {
 
$('#error-optin').hide();
 
// Only do all this if we have translated prompts
if ( $('.optin-no-prompt').data('is-translated') === 'yes' ) {
if ( e.target.id === 'optin-no' ) {
$('.optin-no-prompt').removeClass('is-positive');
if ( !$('.optin-no-prompt').is(':visible') ) {
$('.optin-no-prompt').slideDown();
}
} else {
$('.optin-no-prompt').addClass('is-positive');
}
}
});
};
 
/**
* Block typing letters and symbols in given input. Used for Other amount inputs
*
* If we don't do this, Safari allows typing them and then chokes on submit
* https://phabricator.wikimedia.org/T118741, https://phabricator.wikimedia.org/T173431
*
* @param {Element} inputElement The element to block typing on
*/
donationForm.otherInputControl = function( inputElement ) {
if ( inputElement ) {
inputElement.onkeypress = function(e) {
// Allow special keys in Firefox
if ((e.code == 'ArrowLeft') || (e.code == 'ArrowRight') ||
(e.code == 'ArrowUp') || (e.code == 'ArrowDown') ||
(e.code == 'Delete') || (e.code == 'Backspace')) {
return;
}
var chr = String.fromCharCode(e.which);
if ('0123456789., '.indexOf(chr) === -1) {
return false;
}
};
}
};
 
/**
* Should we show Apple Pay?
*
* Note there is a ~500ms delay in Safari when checking, so only call this if needed
*
* @param {string} country
* @return {boolean}
*/
donationForm.shouldShowApplePay = function ( country ) {
if ( location.search.match('forceApplePay') ) {
return true;
}
if ( window.ApplePaySession ) {
if ( ApplePaySession.canMakePayments() ) {
return true;
}
}
return false;
};
 
/*
Based on github:braintree/braintree-web/src/venmo/shared/supports-venmo.js
See also on meta: MediaWiki:FundraisingBanners/VenmoBrowserCheck.js
*/
donationForm.isVenmoSupported = function(options) {
var options = options || {
allowNewBrowserTab: false,
allowWebviews: true,
allowDesktop: true,
allowDesktopWebLogin: true
};
var ua = window.navigator.userAgent;
 
var merchantAllowsReturningToNewBrowserTab,
merchantAllowsWebviews,
merchantAllowsDesktopBrowsers;
var isMobileDevice = isAndroid() || isIos();
var isAndroidChrome = isAndroid() && isChrome();
var isMobileDeviceThatSupportsReturnToSameTab = isIosSafari() || isAndroidChrome;
var isKnownUnsupportedMobileBrowser = isIosChrome() || isFacebookOwnedBrowserOnAndroid() || isSamsung();
 
options = options || {};
// NEXT_MAJOR_VERSION allowDesktop will default to true, but can be opted out
merchantAllowsDesktopBrowsers =
(options.allowDesktopWebLogin || options.allowDesktop) === true;
merchantAllowsReturningToNewBrowserTab = options.hasOwnProperty(
"allowNewBrowserTab"
)
? options.allowNewBrowserTab
: true;
// NEXT_MAJOR_VERSION webviews are not supported, except for the case where
// the merchant themselves is presenting venmo in a webview using the deep
// link url to get back to their app. For the next major version, we should
// just not have this option and instead require the merchant to determine
// if the venmo button should be displayed when presenting it in the
// merchant's app via a webview.
merchantAllowsWebviews = options.hasOwnProperty("allowWebviews")
? options.allowWebviews
: true;
 
if (isKnownUnsupportedMobileBrowser) {
return false;
}
 
if (
!merchantAllowsWebviews &&
(isAndroidWebview() || isIosWebview())
) {
return false;
}
 
if (!isMobileDevice) {
return merchantAllowsDesktopBrowsers;
}
 
if (!merchantAllowsReturningToNewBrowserTab) {
return isMobileDeviceThatSupportsReturnToSameTab;
}
 
return isMobileDevice;
 
/* -- functions mostly from github:braintree/browser-detection library -- */
 
function isAndroid() {
return /Android/i.test(ua);
}
 
function isIos(checkIpadOS = true) {
const iOsTest = /iPhone|iPod|iPad/i.test(ua);
return checkIpadOS ? iOsTest || isIpadOS() : iOsTest;
}
 
function isIpadOS() {
// "ontouchend" is used to determine if a browser is on an iPad, otherwise
// user-agents for iPadOS behave/identify as a desktop browser
return /Mac|iPad/i.test(ua) && "ontouchend" in window.document;
}
 
function isEdge() {
return ua.indexOf("Edge/") !== -1 || ua.indexOf("Edg/") !== -1;
}
 
function isSamsung() {
return /SamsungBrowser/i.test(ua);
}
 
function isDuckDuckGo() {
return ua.indexOf("DuckDuckGo/") !== -1;
}
 
function isOpera() {
return (
ua.indexOf("OPR/") !== -1 ||
ua.indexOf("Opera/") !== -1 ||
ua.indexOf("OPT/") !== -1
);
}
 
function isSilk() {
return ua.indexOf("Silk/") !== -1;
}
 
function isChrome() {
return (
(ua.indexOf("Chrome") !== -1 || ua.indexOf("CriOS") !== -1) &&
!isEdge() &&
!isSamsung() &&
!isDuckDuckGo() &&
!isOpera() &&
!isSilk()
);
}
 
function isIosFirefox() {
return /FxiOS/i.test(ua);
}
 
function isWebkit() {
const webkitRegexp = /webkit/i;
return webkitRegexp.test(ua);
}
 
function isIosChrome() {
return ua.indexOf("CriOS") > -1;
}
 
function isFacebook() {
return ua.indexOf("FBAN") > -1;
}
 
function isIosSafari() {
return (
isIos() &&
isWebkit() &&
!isIosChrome() &&
!isIosFirefox() &&
!isFacebook()
);
}
 
function isFacebookOwnedBrowserOnAndroid() {
var e = ua.toLowerCase();
return -1 < e.indexOf("huawei") && -1 < e.indexOf("fban") || isAndroid() && (-1 < e.indexOf("fb_iab") || -1 < e.indexOf("instagram"));
}
 
function isSamsungBrowser() {
return /SamsungBrowser/i.test(ua);
}
 
function isAndroidWebview() {
return isAndroid() && -1 < ua.toLowerCase().indexOf("wv");
}
 
function isGoogleSearchApp() {
return /\bGSA\b/.test(ua);
}
 
function isIosGoogleSearchApp() {
return isIos() && isGoogleSearchApp();
}
 
function isIosWebview() {
if (isIos()) {
// The Google Search iOS app is technically a webview and doesn't support popups.
if (isIosGoogleSearchApp()) {
return true;
}
// Historically, a webview could be identified by the presence of AppleWebKit and _no_ presence of Safari after.
return /.+AppleWebKit(?!.*Safari)/i.test(ua);
}
return false;
}
};
 
Line 799 ⟶ 1,399:
$(document).ready(function() {
 
mw.loader.using( ['mediawiki.util'] ).done( function() {
 
var form = document.forms.donateForm;
 
// Minimum amount is usually about 1 USD
donationForm.minLocal = donationForm.currencyRates[ donationForm.currency ];
donationForm.minLocal = Math.ceil( donationForm.minLocal * 100 ) / 100; // Round it up
donationForm.maxUSD = 25000;
donationForm.maxLocal = Math.floor( donationForm.currencyRates[ donationForm.currency ] * donationForm.maxUSD );
 
// Overrides for India
if ( donationForm.currency === 'INR' ) {
donationForm.minLocal = 10;
// Until https://phabricator.wikimedia.org/T370583 fixed?
donationForm.maxUSD = 3000;
donationForm.maxLocal = 250000;
}
 
// Block typing symbols in Other field
donationForm.otherInputControl( document.getElementById('input_amount_other_box') );
 
// Clear errors and update fee when selected/entered
$('.amount-options').on( 'input change', function() {
// Ideally we would validate the amount, but this causes issues with focus
$('.amount-options .lp-error').hide();
donationForm.updateFeeDisplay();
});
 
// Disable submitting form with Enter key
$('form[name="donateForm"]').on('keypress', function(e) {
var code = ( e.keyCode ? e.keyCode : e.which );
if ( code == 13 ) {
e.preventDefault();
}
});
 
// But allow Enter on buttons
$('.payment-method-button').keyup(function(e) {
if (event.keyCode === 13) {
e.target.click();
}
});
 
if ( form ) {
 
// hide frequency options for some countries
// Block typing symbols in input field, otherwise Safari allows them and then chokes
if ( donationForm.noRecurringCountries.indexOf( donationForm.country ) !== -1 ) {
// https://phabricator.wikimedia.org/T118741, https://phabricator.wikimedia.org/T173431
$('#frequency_onetime').prop('checked', true);
$('.frequency-options, #cancel-monthly, #donate-recurring-smallprint').hide();
}
 
if ( donationForm.noRecurringPaypalCountries.indexOf( donationForm.country ) !== -1 ) {
var amountOtherInput = document.getElementById('input_amount_other_box');
$( '.paymentmethod-pp, .paymentmethod-pp-usd' ).addClass( 'not-monthly-capable' );
if ( amountOtherInput ) {
}
amountOtherInput.onkeypress = function(e) {
// Allow special keys in Firefox
if ((e.code == 'ArrowLeft') || (e.code == 'ArrowRight') ||
(e.code == 'ArrowUp') || (e.code == 'ArrowDown') ||
(e.code == 'Delete') || (e.code == 'Backspace')) {
return;
}
var chr = String.fromCharCode(e.which);
if ("0123456789., ".indexOf(chr) === -1) {
return false;
}
};
}
 
// Format amounts on buttons
// Validate amount and update fee when selected/entered
$( '.amount-options li' ).oneach( 'inputfunction( change',index function() {
let amount = this.querySelector( 'input' ).value;
donationForm.validateAmount();
if ( amount !== 'Other' ) {
donationForm.updateFeeDisplay();
this.querySelector( 'label' ).innerText = donationForm.formatCurrency( amount );
});
}
});
 
addCardTypesClass( donationForm.country );
// Disable submitting form with Enter key
$('form[name="paypalcontribution"]').on('keypress', function(e) {
var code = ( e.keyCode ? e.keyCode : e.which );
if ( code == 13 ) {
e.preventDefault();
}
});
 
// Only show Amazon for links from Ways to give
// But allow Enter on buttons
if (
$('.payment-method-button').keyup(function(e) {
mw.util.getParamValue( 'wmf_source' ) === 'Waystogive' ||
if (event.keyCode === 13) {
mw.util.getParamValue( 'wmf_source' ) === 'Ways_to_Give'
e.target.click();
) {
}
$('.paymentmethod-amazon').show();
});
}
 
// Apple Pay
if ( document.paypalcontribution ) {
if ( $('.paymentmethod-applepay').length > 0 ) {
document.paypalcontribution.utm_medium.value = mw.util.getParamValue( 'utm_medium' );
if ( !donationForm.shouldShowApplePay( donationForm.country ) ) {
document.paypalcontribution.utm_campaign.value = mw.util.getParamValue( 'utm_campaign' );
$('.paymentmethod-applepay').remove();
document.paypalcontribution.utm_key.value = mw.util.getParamValue( 'utm_key' );
}
}
 
// Venmo browser check
// Strip protocol to stop firewall throwing fits
if ( $('.paymentmethod-venmo').length > 0 ) {
document.paypalcontribution.referrer.value = document.referrer.replace(/https?:\/\//i, "");
if ( !donationForm.isVenmoSupported() || donationForm.country !== 'US' ) {
$('.paymentmethod-venmo').remove();
}
}
 
// Dumb hack to remove ACH for Portal test against Fundraise Up
// hide frequency options in India, where we can only handle one-time donations
if ( mw.util.getParamValue( 'wmf_source' ) === 'portalBanner_en6C_2024_overlayBanner4WikiForm' ) {
if (document.paypalcontribution.country.value === 'IN') {
$('.paymentmethod-ach').remove();
$("#frequency_onetime").prop('checked', true);
}
$(".frequency-options").hide();
$("#cancel-monthly").hide();
}
 
}
addCardTypesClass(document.paypalcontribution.country.value);
}
 
// Links open in new tab
$('.links-in-new-tab a').attr('target', '_blank');
 
// Disable logo link
$("'#p-logo a"').attr(" { href": '#', "#"title: '' } );
$("#p-logo a").attr("title", "");
 
// These don't need to be tabbable on the landing page
$('#searchInput, .mw-jump-link').attr('tabindex', '-1');
 
$("'.input_amount_other"').click(function() {
$("'#input_amount_other_box"').focus();
});
 
// Allow preselecting monthlyfrequency if possible
if (
if( mw.util.getParamValue('monthly') ) {
donationForm.noRecurringCountries.indexOf( donationForm.country ) === -1
$('#frequency_monthly').click();
&& mw.util.getParamValue( 'utm_medium' ) !== 'endowment'
}
&& mw.util.getParamValue( 'wmf_medium' ) !== 'endowment'
) {
if ( mw.util.getParamValue( 'frequency' ) ) {
donationForm.setFrequency( mw.util.getParamValue( 'frequency' ) );
} else if ( mw.util.getParamValue('monthly') && mw.util.getParamValue('monthly') !== '0' ) {
// old method with "monthly=" parameter
donationForm.setFrequency( 'monthly' );
} else {
donationForm.setFrequency( 'onetime' );
}
}
 
donationForm.initOptin();
// If the optin section has some javascript to run, do that
if ( typeof initOptin === 'function' ) {
initOptin();
}
 
try {
adjustHPC();
preSelect(); // Make sure to do this *after* other fiddling with values
donationForm.localizeErrors();
}
}
finally {
$('.ptffrb-monthly-pitch, .frb-monthly-pitch-thanks').appendTo('.amountfrequency-options');
$('.optin-optionsptf').insertAfterappendTo('.amount-options');
$('.optin-options').insertAfter('.amount-options');
$('.consider-amounts').show();
$('#actual.consider-formamounts').show();
$('#actual-form-loading').hideshow();
$('#actual-form-loading').hide();
}
}
 
});
 
});