Donate donatewiki https://donate.wikimedia.org/wiki/Special:FundraiserRedirector MediaWiki 1.47.0-wmf.10 first-letter Media Special Talk User User talk Donate Donate talk File File talk MediaWiki MediaWiki talk Template Template talk Help Help talk Category Category talk Campaign Campaign talk TimedText TimedText talk Module Module talk MediaWiki:DonationForm.js 8 7993 42898 42854 2026-07-10T15:30:58Z Pcoombe 5 refactor parameters to pass through to payments as a list 42898 javascript text/javascript /* jshint strict:false */ /** MediaWiki:DonationForm.js - loaded on all donation forms * TODO: lots of cleanup */ var donationForm = {}; donationForm.loadedTime = Date.now(); donationForm.extraData = { 'vw' : window.innerWidth, 'vh' : window.innerHeight }; donationForm.country = mw.util.getParamValue('country').toUpperCase(); 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 ); // Don't offer recurring at all in these countries donationForm.noRecurringCountries = [ 'AR', 'IN' ]; donationForm.noRecurringPaypalCountries = [ 'CL', 'CO', 'PE', 'UY', 'BR' ]; donationForm.currencyRates = { // From https://github.com/wikimedia/wikimedia-fundraising-SmashPig/blob/master/PaymentData/ReferenceData/CurrencyRates.php // Updated 2025-11-03 'ADF' : 5.69, 'ADP' : 144, 'AED' : 3.67, 'AFA' : 66, 'AFN' : 66, 'ALL' : 83, 'AMD' : 374, 'ANG' : 1.79, 'AOA' : 912, 'AON' : 912, 'ARS' : 1457, 'ATS' : 12, 'AUD' : 1.53, 'AWG' : 1.79, 'AZM' : 8500, 'AZN' : 1.7, 'BAM' : 1.7, 'BBD' : 2, 'BDT' : 121, 'BEF' : 35, 'BGL' : 1.7, 'BGN' : 1.7, 'BHD' : 0.37401652162054, 'BIF' : 2923, 'BMD' : 1, 'BND' : 1.3, 'BOB' : 6.76, 'BRL' : 5.37, 'BSD' : 1, 'BTN' : 89, 'BWP' : 13, 'BYR' : 34102, 'BZD' : 1.98, 'CAD' : 1.4, 'CDF' : 2224, 'CHF' : 0.80650783228772, 'CLP' : 940, 'CNY' : 7.12, 'COP' : 3853, 'CRC' : 496, 'CUC' : 1, 'CUP' : 25, 'CVE' : 96, 'CYP' : 0.50784522451156, 'CZK' : 21, 'DEM' : 1.7, 'DJF' : 178, 'DKK' : 6.48, 'DOP' : 64, 'DZD' : 130, 'ECS' : 24094, 'EEK' : 14, 'EGP' : 47, 'ESP' : 144, 'ETB' : 153, 'EUR' : 0.86770508259643, 'FIM' : 5.16, 'FJD' : 2.27, 'FKP' : 0.76116218937783, 'FRF' : 5.69, 'GBP' : 0.76116218937783, 'GEL' : 2.68, 'GHC' : 108957, 'GHS' : 11, 'GIP' : 0.76116218937783, 'GMD' : 71, 'GNF' : 8637, 'GRD' : 296, 'GTQ' : 7.55, 'GYD' : 205, 'HKD' : 7.77, 'HNL' : 26, 'HRK' : 6.54, 'HTG' : 130, 'HUF' : 336, 'IDR' : 16671, 'IEP' : 0.68337328567002, 'ILS' : 3.25, 'INR' : 89, 'IQD' : 1292, 'IRR' : 42020, 'ISK' : 126, 'ITL' : 1680, 'JMD' : 159, 'JOD' : 0.70900000000001, 'JPY' : 154, 'KES' : 128, 'KGS' : 87, 'KHR' : 3971, 'KMF' : 427, 'KPW' : 135, 'KRW' : 1429, 'KWD' : 0.30641816376358, 'KYD' : 0.83333299999999, 'KZT' : 526, 'LAK' : 21568, 'LBP' : 89680, 'LKR' : 303, 'LRD' : 182, 'LSL' : 17, 'LTL' : 3, 'LUF' : 35, 'LVL' : 0.60982660286911, 'LYD' : 5.44, 'MAD' : 9.19, 'MDL' : 17, 'MGA' : 4474, 'MGF' : 9150, 'MKD' : 53, 'MMK' : 2093, 'MNT' : 2620, 'MOP' : 8.01, 'MRO' : 395, 'MTL' : 0.37250579195865, 'MUR' : 45, 'MVR' : 15, 'MWK' : 1730, 'MXN' : 19, 'MYR' : 4.2, 'MZM' : 63200, 'MZN' : 63, 'NAD' : 17, 'NGN' : 1446, 'NIO' : 36, 'NLG' : 1.91, 'NOK' : 10, 'NPR' : 141, 'NZD' : 1.75, 'OMR' : 0.38352905117543, 'PAB' : 1, 'PEN' : 3.35, 'PGK' : 4.17, 'PHP' : 59, 'PKR' : 282, 'PLN' : 3.69, 'PTE' : 174, 'PYG' : 6991, 'QAR' : 3.6, 'ROL' : 44083, 'RON' : 4.41, 'RSD' : 101, 'RUB' : 81, 'RWF' : 1446, 'SAR' : 3.75, 'SBD' : 8.21, 'SCR' : 14, 'SDD' : 59715, 'SDG' : 597, 'SDP' : 2261, 'SEK' : 9.49, 'SGD' : 1.3, 'SHP' : 0.76116218937783, 'SIT' : 208, 'SKK' : 26, 'SLL' : 19750, 'SOS' : 550, 'SRD' : 39, 'SRG' : 38521, 'STD' : 21169, 'SVC' : 8.75, 'SYP' : 513, 'SZL' : 17, 'THB' : 32, 'TJS' : 9.15, 'TMM' : 16757, 'TMT' : 3.35, 'TND' : 2.93, 'TOP' : 2.4, 'TRL' : 42048152, 'TRY' : 42, 'TTD' : 6.69, 'TWD' : 31, 'TZS' : 2442, 'UAH' : 42, 'UGX' : 3463, 'USD' : 1, 'UYU' : 40, 'UZS' : 11982, 'VEB' : 22204414173, 'VEF' : 22204414, 'VND' : 26302, 'VUV' : 112, 'WST' : 2.71, 'XAF' : 569, 'XAG' : 0.020582109674161, 'XAU' : 0.000249595454823, 'XCD' : 2.7, 'XEU' : 0.86770508259643, 'XOF' : 569, 'XPD' : 0.00068810810716198, 'XPF' : 104, 'XPT' : 0.00063604563466001, 'YER' : 238, 'YUN' : 101, 'ZAR' : 17, '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 = donationForm.currency; $('.lp-error-smallamount').text( function( index, oldText ) { return oldText.replace( '$1', donationForm.formatAmount( donationForm.minLocal ) + '\xa0' + currency ); }); if ( currency === 'USD' ) { // we don't need to include the conversion $('.lp-error-bigamount').text( function( index, oldText ) { return oldText.replace( '($1 $2) ', '' ) .replace( '($1&nbsp;$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 adjustMinAmounts() { // Amounts spreadsheet https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 // Defining lookup table here. Using mw.loader.getScript was visibly too slow for the user (amounts flashing) const minPlusLookup = { // US - Canada - UK - EUR - Australia - New Zealand // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 USD: { amount1: { from: 2.75, to: 4.50 }, amount2: { from: 5, to: 7 }, }, GBP: { amount1: { from: 2, to: 4 }, amount2: { from: 5, to: 7 }, }, EUR: { amount1: { from: 2.50, to: 4.50 }, amount2: { from: 5, to: 7 }, }, // English Bundle // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=891721479#gid=891721479 HUF: { amount1: { from: 500, to: 750 }, }, MYR: { amount1: { from: 10, to: 20 }, amount2: { from: 30, to: 40 }, }, RON: { amount1: { from: 10, to: 30 }, }, // Other // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1865233115#gid=1865233115 CZK: { amount1: { from: 50, to: 100 }, amount2: { from: 100, to: 150 }, }, DKK: { amount1: { from: 20, to: 40 }, amount2: { from: 75, to: 80 }, }, JPY: { amount1: { from: 500, to: 1000 }, amount2: { from: 1000, to: 2000 }, amount3: { from: 2000, to: 3000 }, amount4: { from: 2500, to: 4000 }, amount5: { from: 4000, to: 5000 }, amount6: { from: 5000, to: 10000 }, amount7: { from: 10000, to: 15000 }, }, ZAR: { amount1: { from: 30, to: 50 }, amount2: { from: 50, to: 75 }, }, NOK: { amount1: { from: 30, to: 50 }, }, SEK: { amount1: { from: 30, to: 50 }, amount2: { from: 50, to: 70 }, }, ILS: { amount1: { from: 10, to: 20 }, }, PLN: { amount1: { from: 10, to: 20 }, amount2: { from: 20, to: 30 }, }, CHF: { amount1: { from: 20, to: 30 }, }, THB: { amount1: { from: 100, to: 150 }, amount2: { from: 200, to: 250 }, }, }; // CAD, AUD, NZD = USD amounts minPlusLookup.CAD = minPlusLookup.USD; minPlusLookup.AUD = minPlusLookup.USD; minPlusLookup.NZD = minPlusLookup.USD; if ( mw.util.getParamValue( 'minPlus' ) === '1' || mw.util.getParamValue( 'minPlus' ) === 'true' ) { const currencyEntry = minPlusLookup[ donationForm.currency ]; // Currency not in lookup table. No swapping. if ( !currencyEntry ) return null; const amountKeys = Object.keys( currencyEntry ); // ["amount1", "amount2"] or however many keys in lookup amountKeys.forEach( (amount, index) => { const $radio = $( `#input_amount_${index}` ); const $label = $( `label[for='input_amount_${index}` ); // If the button's amount is equal to "from" in the lookup, perform the swap. // Guards from hpc adjusted amounts as those values won't be present in the lookup. if ( currencyEntry[amount].from === parseFloat( $radio.val() ) ) { $radio.val( currencyEntry[amount].to ); $label.text( donationForm.formatCurrency( currencyEntry[amount].to ) ); } }); } } 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' 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 = donationForm.currency; // https://phabricator.wikimedia.org/T381437 var hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== currency ) { console.log('Highest previous contribution currency does not match form currency, using default amounts'); return; } // Consult this sheet for amounts: https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 var radioAmountsData = { "USD" : { // also used for CAD, AUD, NZD "default" : [ [ 0, [ 2.75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2.75, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], // Direct Mail - fixed amounts "directmail" : [ [ 0, [ 25, 35, 50, 100, 150, 250, 300 ] ] ], "directmail250" : [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ] }, "EUR" : { "default" : [ [ 0, [ 2.50, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2.50, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], }, "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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], }, "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 ] ], [ 5000, [ 5000, 10000, 15000, 20000, 35000, 50000, 100000 ] ], [ 10000, [ 10000, 25000, 50000, 75000, 100000, 150000, 200000 ] ] ], "SEK" : [ [ 0, [ 30, 50, 100, 150, 200, 300, 500 ] ], [ 50, [ 50, 100, 150, 200, 300, 500, 750 ] ], [ 200, [ 200, 300, 500, 750, 1000, 1500, 2000 ] ] ] }; 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 currencyList = [ 'USD', 'CAD', 'AUD', 'NZD', 'GBP', 'EUR' ]; // close enough for ( let i = 0; i < currencyList.length; i++ ) { // FY2425 hpcSets // Major Gifts hpcSets radioAmountsData[ currencyList[i] ].MG_2024_500 = [ [ 0, [ 500, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2024_650 = [ [ 0, [ 650, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; // FY2526 hpcSets // Direct Mail hpcSets radioAmountsData[ currencyList[i] ].DM_2526_15 = [ [ 0, [ 15, 25, 35, 50, 100, 200, 250 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2526_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2526_5000 = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; // Major Gifts hpcSets radioAmountsData[ currencyList[i] ].MG_2526_500_9999 = [ [ 0, [ 750, 850, 1000, 1250, 1500, 1750, 2000 ] ], [ 1000, [ 1500, 2000, 2500, 3000, 3750, 4500, 5000 ] ], [ 3000, [ 4000, 5000, 6000, 7000, 8000, 9000, 10000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_10K = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_250_399 = [ [ 0, [ 500, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_400_499 = [ [ 0, [ 650, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_HNWI_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_HNWI_350 = [ [ 0, [ 350, 400, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_2500 = [ [ 0, [ 2500, 3000, 5000, 7500, 10000, 15000, 25000 ] ] ]; } var appealAmountsData = { "USD" : [ // also used for CAD, AUD, NZD, GBP, EUR [ 0, [ 5, 10, 20 ] ], [ 10, [ 10, 20, 50 ] ], [ 20, [ 20, 30, 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; // Radio button amounts 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] ) ); } } // Appeal amounts var appealAmounts = pickAmountArray( appealAmountsData, currency, hpc, hpcSet ); if ( appealAmounts.length ) { var appealAmountString = appealAmounts.map( donationForm.formatCurrency ).join( ', '); $('.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') || mw.util.getParamValue('preselect') ); if ( preSelectAmount > 0 ) { let hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== donationForm.currency ) { console.log('Highest previous contribution currency does not match form currency, not doing preselection'); return; } 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 preSelectBox() { /* Check for a 'preSelectBox' url parameter, and select that numbered option. If the value provided is invalid or doesn't exist, exit. Valid choices are 1 to 7 (8 is "Other"). If 'preSelect' exists, ignore this function. */ if(!mw.util.getParamValue('preSelect')){ // Check hpcCurrency first before running preselection. let hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== donationForm.currency ) { console.log('Highest previous contribution currency does not match form currency, not preselecting box.'); return; } // If hpc & hpcCurrency provided are okay OR hpc wasn't provided then continue. var preSelectBoxNumber = parseInt( mw.util.getParamValue('preSelectBox') ); if (preSelectBoxNumber >= 1 && preSelectBoxNumber <= 7) { var $preSelectOption = $('input[id="input_amount_' + (preSelectBoxNumber - 1) + '"]'); if ( $preSelectOption.length ) { $preSelectOption.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' : 'vma', 'IT' : 'vmaj', 'LU' : 'vmaj', 'LV' : 'vma', 'NL' : 'vmaj', 'PT' : 'vmaj', 'SK' : 'vmaj', 'GR' : 'vma', // Others 'CZ' : 'vmad', 'DK' : 'vma', 'HU' : 'vma', 'IL' : 'vmad', // 'JP' : 'vmaj', - use text only as there were complaints about Diners Club not being included 'MY' : 'vmaj', 'NO' : 'vma', 'PL' : 'vma', 'RO' : 'vma', 'SE' : 'vma', 'UA' : 'vma', 'ZA' : 'vm', 'ZZ' : 'vmad' // For testing }; 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(''); } /* -- Moved from Template:2012FR/Form-section/Processing/Default -- */ /** * 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; params.country = donationForm.country; // Overrides for specific gateways if ( paymentMethod === 'cc-adyen' ) { params.payment_method = 'cc'; params.gateway = 'adyen'; } else if ( paymentMethod === 'cc-dlocal' ) { params.payment_method = 'cc'; params.gateway = 'dlocal'; } else if ( paymentMethod === 'trustly' ) { params.payment_method = 'dd'; params.payment_submethod = 'ach'; params.gateway = 'gravy'; } else if ( paymentSubMethod === 'sepadirectdebit' ) { params.payment_method = 'rtbt'; params.payment_submethod = 'sepadirectdebit'; params.gateway = 'gravy'; } else if ( paymentMethod === 'bt' && params.country === 'CZ' ) { params.payment_method = 'bt'; params.gateway = 'gravy'; } else if ( paymentSubMethod === 'vipps' ) { params.payment_method = 'ew'; params.payment_submethod = 'vipps'; params.gateway = 'gravy'; } else { params.payment_method = paymentMethod; } // dlocal let dlocalCountries = [ 'AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY', 'ZA' ], dlocalMethods = [ 'cc', 'bt', 'cash', 'cash_boleto', 'pix' ]; if ( dlocalCountries.includes( params.country ) && dlocalMethods.includes( params.payment_method ) ) { params.gateway = 'gravy'; } if ( params.payment_method === 'cc' && params.gateway === undefined ) { params.gateway = 'gravy'; } if ( params.payment_method === 'paypal' ) { params.gateway = 'gravy'; } if ( params.payment_method === 'rtbt' && paymentSubMethod === 'rtbt_ideal' ) { params.gateway = 'gravy'; } if ( params.payment_method === 'apple' || params.payment_method === 'google' ) { params.gateway = 'gravy'; } if ( paymentSubMethod ) { params.payment_submethod = paymentSubMethod; } let frequency = donationForm.getFrequency(); if ( frequency === 'monthly' ) { 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 if ( params.uselang === 'pt' && params.country === 'BR' ) { params.uselang = 'pt-br'; } if ( params.uselang === 'es' && ( params.country === 'AR' || params.country === 'CL' || params.country === 'CO' || params.country === 'MX' || params.country === 'PE' || params.country === 'UY' || params.country === 'US' ) ) { params.uselang = 'es-419'; } var amount = donationForm.getAmount(); if ( $('#ptf-checkbox').prop('checked') ) { amount = amount + donationForm.calculateFee( amount ); donationForm.extraData.ptf = 1; } params.amount = amount; // Email optin if ( $('input[name="opt_in"]').length > 0 ) { 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' ) ) { params.variant = mw.util.getParamValue( 'pym_variant' ); } if ( params.recurring && params.variant && params.variant.match( /monthlyConvert/ ) ) { // Post-payments monthly convert makes no sense if it's already recurring // Avoid things like T312905 delete params.variant; } if ( mw.util.getParamValue( 'pym_appeal' ) ) { params.appeal = mw.util.getParamValue( 'pym_appeal' ); } // Pass through specified parameters to payments unchanged const passThroughParams = [ 'contact_id', 'contact_hash', // https://phabricator.wikimedia.org/T381405 'checksum', 'contribution_recur_id', // https://phabricator.wikimedia.org/T396271 'recipient_id', // SMS 'app_install_id' // https://phabricator.wikimedia.org/T411535 ]; passThroughParams.forEach( ( param ) => { const value = mw.util.getParamValue( param ); if ( value ) { params[ param ] = value; } } ); // Monthly convert if ( mc ) { // check just in-case this wasn't loaded for some reason mc.main( params, donationForm.finalStep ); } else { donationForm.finalStep( params ); } } 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 final tracking parameters, and submit to payments * @param {Object} params */ donationForm.finalStep = function( params ) { var url = new URL('https://payments.wikimedia.org/index.php/Special:GatewayChooser'); // Skip form chooser for Venmo if ( params.payment_method === 'venmo' ) { url = new URL('https://payments.wikimedia.org/index.php/Special:GravyGateway'); } // Skip form chooser for Pix if ( params.payment_method === 'cash' && params.payment_submethod === 'pix' ) { url = new URL('https://payments.wikimedia.org/index.php/Special:GravyGateway'); } 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 * * @param {Object} params * @return {string} wmf_source */ donationForm.buildTrackingSource = function( params ) { var wmf_source = mw.util.getParamValue( 'wmf_source' ) || mw.util.getParamValue( 'utm_source' ); wmf_source += '.'; var fullDottedPaymentMethod = params.payment_method; if ( params.recurring ) { fullDottedPaymentMethod = 'r' + fullDottedPaymentMethod; } if ( params.payment_submethod ) { fullDottedPaymentMethod = fullDottedPaymentMethod + '.' + params.payment_submethod; } /* Get URL parameter, but remove parts using old format. Allow fallback to a default value */ var getParam = function( param, removeText, dflt ) { if ( mw.util.getParamValue( param ) ) { return mw.util.getParamValue( param ).replace( removeText, '' ); } else { return dflt; } }; /* The landing page info, separated by ~. This mostly exists for legacy reasons */ 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 wmf_key from extra tracking data * * @param {Object} data * @return {string} wmf_key */ donationForm.buildTrackingKey = function(data) { var existingKey = mw.util.getParamValue( 'wmf_key' ) || mw.util.getParamValue( 'utm_key' ), dataArray = []; if ( existingKey ) { dataArray.push( existingKey ); } for (var key in data) { if (data.hasOwnProperty(key)) { dataArray.push( key + '_' + data[key] ); } } return dataArray.join('~'); }; /* Return amount selected or input */ donationForm.getAmount = function() { var form = document.forms.donateForm, 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; }; /** * 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 ) { 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.forms.donateForm; // Reset all errors $('.lp-haserror').removeClass('lp-haserror'); $('.lp-error').hide(); if ( !skipAmountValidation && !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(); } } return !error; }; /** * Check if selected amount is valid i.e. a positive number, between minimum and maximum. * If not, show an error and return false. */ donationForm.validateAmount = function() { var amount = donationForm.getAmount(); if ( amount === null || isNaN(amount) || amount <= 0 || amount < donationForm.minLocal ) { $('.amount-options').addClass('lp-haserror'); $('.lp-error-bigamount').hide(); $('.lp-error-smallamount').show().focus(); return false; } else if ( amount > donationForm.maxLocal ) { $('.amount-options').addClass('lp-haserror'); $('.lp-error-bigamount').show().focus(); return false; } else { $('.amount-options').removeClass('lp-haserror'); $('.lp-error-smallamount, .lp-error-bigamount').hide(); return true; } }; donationForm.getFrequency = function() { return document.forms.donateForm.dataset.frequency || 'onetime'; }; donationForm.setFrequency = function( frequency ) { // 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 selectedAmount = donationForm.getAmount(), feeAmount = donationForm.calculateFee( selectedAmount ), feeText; feeText = donationForm.formatCurrency( feeAmount ); $('.ptf label span').text( feeText ); if ( selectedAmount + feeAmount <= donationForm.maxLocal ) { $('.ptf').slideDown(); } }; /** * Calculate approximate transaction fee on given amount * @param {number} amount * @return {number} Rounded to 2 decimal places */ donationForm.calculateFee = function( amount ) { // Minimum fee/PTF amounts. Default is 0.35. // Updated 2019-05-21 to approx 0.35 USD equivalent var feeMinimums = { 'DKK' : 2, 'HUF' : 100, 'ILS' : 1.2, 'INR' : 4, 'JPY' : 35, 'KHR' : 1000, 'MYR' : 1, 'NOK' : 3, 'PLN' : 1.35, 'CZK' : 7.5, 'RON' : 1.5, 'SEK' : 3, 'UAH' : 10, 'ZAR' : 5, // Latin America // Updated 2025-06-10 to approx 0.35 USD equivalent 'BRL' : 2, 'ARS' : 415, 'CLP' : 325, 'COP' : 1450, 'MXN' : 6.75, 'PEN' : 1.28, 'UYU' : 14.5 }; var feeMultiplier = 0.04, feeMinimum = feeMinimums[ donationForm.currency ] || 0.35, feeAmount = amount * feeMultiplier; 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.screen.width >= 640 && country !== 'JP' ) { // T397002 // On a desktop browser, people can scan with their iphone return true; } else if ( window.ApplePaySession ) { // On mobile, check if Apple Pay is available natively if ( ApplePaySession.canMakePayments() ) { return true; } } return false; }; /** * Determine if the annual option should be shown on the donation form, and show it if so * * @returns {boolean} true if the annual option is enabled */ donationForm.initAnnualRecurring = function() { /* Before adding a language here, please check that we have annual translations in-place for: - the button here on donatewiki ([[MediaWiki:Frequency-Annual]]) - the thank you receipt email - donor relations macros - the thank you page (optional if it has no recurring-specific messaging) */ const annualLanguages = ['%%isolang%%', '%25%25ISOLANG%25%25', '%25%25isolang%25%25', 'el', 'en', 'en-ca', 'en-gb', 'en-us', 'es', 'es-419', 'fr', 'it', 'ja', 'nl', 'pt', 'pt-br'] const annualInput = document.getElementById( 'frequency_annual' ); if ( !annualInput ) { // old form without required input return false; } let annualEnabled = annualLanguages.includes( mw.config.get( 'wgPageContentLanguage' ) ); // Allow overriding with URL params if ( mw.util.getParamValue( 'form-countryspecific' ) === 'Form-countryspecific-annual' // compatibility with old method || mw.util.getParamValue( 'annual_enabled' ) === '1' ) { annualEnabled = true; } if ( mw.util.getParamValue( 'annual_enabled' ) === '0' ) { annualEnabled = false; } annualInput.parentNode.style.display = annualEnabled ? 'block' : 'none'; if ( annualEnabled ) { document.forms.donateForm.classList.add( 'annual-enabled' ); } return annualEnabled; }; /* 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; } }; /* End form functions */ $(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 ) { donationForm.initAnnualRecurring(); // hide frequency options for some countries if ( donationForm.noRecurringCountries.indexOf( donationForm.country ) !== -1 ) { $('#frequency_onetime').prop('checked', true); $('.frequency-options, #cancel-monthly, #donate-recurring-smallprint').hide(); } if ( donationForm.noRecurringPaypalCountries.indexOf( donationForm.country ) !== -1 ) { $( '.paymentmethod-pp, .paymentmethod-pp-usd' ).addClass( 'not-monthly-capable' ); } // Format amounts on buttons $( '.amount-options li' ).each( function( index ) { let amount = this.querySelector( 'input' ).value; if ( amount !== 'Other' ) { this.querySelector( 'label' ).innerText = donationForm.formatCurrency( amount ); } }); addCardTypesClass( donationForm.country ); // Only show Amazon for links from Ways to give if ( mw.util.getParamValue( 'wmf_source' ) === 'Waystogive' || mw.util.getParamValue( 'wmf_source' ) === 'Ways_to_Give' ) { $('.paymentmethod-amazon').show(); } // Only show DAF for certain Major Gifts links if ( mw.util.getParamValue( 'wmf_campaign' ) === 'MG2WIR25' ) { $('.paymentmethod-daf').show(); } else { $('.paymentmethod-daf').hide(); } // Apple Pay if ( $('.paymentmethod-applepay').length > 0 ) { if ( !donationForm.shouldShowApplePay( donationForm.country ) ) { $('.paymentmethod-applepay').remove(); } } // Venmo browser check if ( $('.paymentmethod-venmo').length > 0 ) { if ( !donationForm.isVenmoSupported() || donationForm.country !== 'US' ) { $('.paymentmethod-venmo').remove(); } } // Hide Google Pay if people are coming from iOS app https://phabricator.wikimedia.org/T411504 if ( mw.util.getParamValue('wmf_campaign') === 'iOS' ) { $('.paymentmethod-google').remove(); } } // Links open in new tab $('.links-in-new-tab a').attr('target', '_blank'); // Disable logo link $('#p-logo a').attr( { href: '#', 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 frequency if possible if ( donationForm.noRecurringCountries.indexOf( donationForm.country ) === -1 && 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' ); } } // If we are emailing them and they have a contact_id, then we can assume they have opted in, // unless this is a "Remind Me Later" email, or they are in a stricter country let hasContactId = mw.util.getParamValue( 'contact_id' ) !== null; let isRML = mw.util.getParamValue( 'wmf_campaign' ) && mw.util.getParamValue( 'wmf_campaign' ).includes( 'RMLEmail' ); let isStrictCountry = [ 'AT', 'IT' ].includes( donationForm.country ); if ( document.getElementById('optin-yes') && hasContactId && !isRML && !isStrictCountry ) { document.getElementById('optin-yes').checked = true; document.querySelector('.optin-options').style.display = 'none'; } donationForm.initOptin(); try { adjustHPC(); adjustMinAmounts(); preSelect(); // Make sure to do this *after* other fiddling with values preSelectBox(); donationForm.localizeErrors(); } finally { $('.frb-monthly-pitch, .frb-monthly-pitch-thanks, .frb-recurring-pitch').appendTo('.frequency-options'); $('.ptf').appendTo('.amount-options'); $('.optin-options').insertAfter('.amount-options'); $('.consider-amounts').show(); $('#actual-form').show(); $('#actual-form-loading').hide(); } }); }); qyblhxcpmc5ftd5uqcahtnrslozn5u8 42899 42898 2026-07-10T16:07:47Z Pcoombe 5 split out donationForm.changeAmountOptions function for re-use 42899 javascript text/javascript /* jshint strict:false */ /** MediaWiki:DonationForm.js - loaded on all donation forms * TODO: lots of cleanup */ var donationForm = {}; donationForm.loadedTime = Date.now(); donationForm.extraData = { 'vw' : window.innerWidth, 'vh' : window.innerHeight }; donationForm.country = mw.util.getParamValue('country').toUpperCase(); 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 ); // Don't offer recurring at all in these countries donationForm.noRecurringCountries = [ 'AR', 'IN' ]; donationForm.noRecurringPaypalCountries = [ 'CL', 'CO', 'PE', 'UY', 'BR' ]; donationForm.currencyRates = { // From https://github.com/wikimedia/wikimedia-fundraising-SmashPig/blob/master/PaymentData/ReferenceData/CurrencyRates.php // Updated 2025-11-03 'ADF' : 5.69, 'ADP' : 144, 'AED' : 3.67, 'AFA' : 66, 'AFN' : 66, 'ALL' : 83, 'AMD' : 374, 'ANG' : 1.79, 'AOA' : 912, 'AON' : 912, 'ARS' : 1457, 'ATS' : 12, 'AUD' : 1.53, 'AWG' : 1.79, 'AZM' : 8500, 'AZN' : 1.7, 'BAM' : 1.7, 'BBD' : 2, 'BDT' : 121, 'BEF' : 35, 'BGL' : 1.7, 'BGN' : 1.7, 'BHD' : 0.37401652162054, 'BIF' : 2923, 'BMD' : 1, 'BND' : 1.3, 'BOB' : 6.76, 'BRL' : 5.37, 'BSD' : 1, 'BTN' : 89, 'BWP' : 13, 'BYR' : 34102, 'BZD' : 1.98, 'CAD' : 1.4, 'CDF' : 2224, 'CHF' : 0.80650783228772, 'CLP' : 940, 'CNY' : 7.12, 'COP' : 3853, 'CRC' : 496, 'CUC' : 1, 'CUP' : 25, 'CVE' : 96, 'CYP' : 0.50784522451156, 'CZK' : 21, 'DEM' : 1.7, 'DJF' : 178, 'DKK' : 6.48, 'DOP' : 64, 'DZD' : 130, 'ECS' : 24094, 'EEK' : 14, 'EGP' : 47, 'ESP' : 144, 'ETB' : 153, 'EUR' : 0.86770508259643, 'FIM' : 5.16, 'FJD' : 2.27, 'FKP' : 0.76116218937783, 'FRF' : 5.69, 'GBP' : 0.76116218937783, 'GEL' : 2.68, 'GHC' : 108957, 'GHS' : 11, 'GIP' : 0.76116218937783, 'GMD' : 71, 'GNF' : 8637, 'GRD' : 296, 'GTQ' : 7.55, 'GYD' : 205, 'HKD' : 7.77, 'HNL' : 26, 'HRK' : 6.54, 'HTG' : 130, 'HUF' : 336, 'IDR' : 16671, 'IEP' : 0.68337328567002, 'ILS' : 3.25, 'INR' : 89, 'IQD' : 1292, 'IRR' : 42020, 'ISK' : 126, 'ITL' : 1680, 'JMD' : 159, 'JOD' : 0.70900000000001, 'JPY' : 154, 'KES' : 128, 'KGS' : 87, 'KHR' : 3971, 'KMF' : 427, 'KPW' : 135, 'KRW' : 1429, 'KWD' : 0.30641816376358, 'KYD' : 0.83333299999999, 'KZT' : 526, 'LAK' : 21568, 'LBP' : 89680, 'LKR' : 303, 'LRD' : 182, 'LSL' : 17, 'LTL' : 3, 'LUF' : 35, 'LVL' : 0.60982660286911, 'LYD' : 5.44, 'MAD' : 9.19, 'MDL' : 17, 'MGA' : 4474, 'MGF' : 9150, 'MKD' : 53, 'MMK' : 2093, 'MNT' : 2620, 'MOP' : 8.01, 'MRO' : 395, 'MTL' : 0.37250579195865, 'MUR' : 45, 'MVR' : 15, 'MWK' : 1730, 'MXN' : 19, 'MYR' : 4.2, 'MZM' : 63200, 'MZN' : 63, 'NAD' : 17, 'NGN' : 1446, 'NIO' : 36, 'NLG' : 1.91, 'NOK' : 10, 'NPR' : 141, 'NZD' : 1.75, 'OMR' : 0.38352905117543, 'PAB' : 1, 'PEN' : 3.35, 'PGK' : 4.17, 'PHP' : 59, 'PKR' : 282, 'PLN' : 3.69, 'PTE' : 174, 'PYG' : 6991, 'QAR' : 3.6, 'ROL' : 44083, 'RON' : 4.41, 'RSD' : 101, 'RUB' : 81, 'RWF' : 1446, 'SAR' : 3.75, 'SBD' : 8.21, 'SCR' : 14, 'SDD' : 59715, 'SDG' : 597, 'SDP' : 2261, 'SEK' : 9.49, 'SGD' : 1.3, 'SHP' : 0.76116218937783, 'SIT' : 208, 'SKK' : 26, 'SLL' : 19750, 'SOS' : 550, 'SRD' : 39, 'SRG' : 38521, 'STD' : 21169, 'SVC' : 8.75, 'SYP' : 513, 'SZL' : 17, 'THB' : 32, 'TJS' : 9.15, 'TMM' : 16757, 'TMT' : 3.35, 'TND' : 2.93, 'TOP' : 2.4, 'TRL' : 42048152, 'TRY' : 42, 'TTD' : 6.69, 'TWD' : 31, 'TZS' : 2442, 'UAH' : 42, 'UGX' : 3463, 'USD' : 1, 'UYU' : 40, 'UZS' : 11982, 'VEB' : 22204414173, 'VEF' : 22204414, 'VND' : 26302, 'VUV' : 112, 'WST' : 2.71, 'XAF' : 569, 'XAG' : 0.020582109674161, 'XAU' : 0.000249595454823, 'XCD' : 2.7, 'XEU' : 0.86770508259643, 'XOF' : 569, 'XPD' : 0.00068810810716198, 'XPF' : 104, 'XPT' : 0.00063604563466001, 'YER' : 238, 'YUN' : 101, 'ZAR' : 17, '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 = donationForm.currency; $('.lp-error-smallamount').text( function( index, oldText ) { return oldText.replace( '$1', donationForm.formatAmount( donationForm.minLocal ) + '\xa0' + currency ); }); if ( currency === 'USD' ) { // we don't need to include the conversion $('.lp-error-bigamount').text( function( index, oldText ) { return oldText.replace( '($1 $2) ', '' ) .replace( '($1&nbsp;$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 adjustMinAmounts() { // Amounts spreadsheet https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 // Defining lookup table here. Using mw.loader.getScript was visibly too slow for the user (amounts flashing) const minPlusLookup = { // US - Canada - UK - EUR - Australia - New Zealand // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 USD: { amount1: { from: 2.75, to: 4.50 }, amount2: { from: 5, to: 7 }, }, GBP: { amount1: { from: 2, to: 4 }, amount2: { from: 5, to: 7 }, }, EUR: { amount1: { from: 2.50, to: 4.50 }, amount2: { from: 5, to: 7 }, }, // English Bundle // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=891721479#gid=891721479 HUF: { amount1: { from: 500, to: 750 }, }, MYR: { amount1: { from: 10, to: 20 }, amount2: { from: 30, to: 40 }, }, RON: { amount1: { from: 10, to: 30 }, }, // Other // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1865233115#gid=1865233115 CZK: { amount1: { from: 50, to: 100 }, amount2: { from: 100, to: 150 }, }, DKK: { amount1: { from: 20, to: 40 }, amount2: { from: 75, to: 80 }, }, JPY: { amount1: { from: 500, to: 1000 }, amount2: { from: 1000, to: 2000 }, amount3: { from: 2000, to: 3000 }, amount4: { from: 2500, to: 4000 }, amount5: { from: 4000, to: 5000 }, amount6: { from: 5000, to: 10000 }, amount7: { from: 10000, to: 15000 }, }, ZAR: { amount1: { from: 30, to: 50 }, amount2: { from: 50, to: 75 }, }, NOK: { amount1: { from: 30, to: 50 }, }, SEK: { amount1: { from: 30, to: 50 }, amount2: { from: 50, to: 70 }, }, ILS: { amount1: { from: 10, to: 20 }, }, PLN: { amount1: { from: 10, to: 20 }, amount2: { from: 20, to: 30 }, }, CHF: { amount1: { from: 20, to: 30 }, }, THB: { amount1: { from: 100, to: 150 }, amount2: { from: 200, to: 250 }, }, }; // CAD, AUD, NZD = USD amounts minPlusLookup.CAD = minPlusLookup.USD; minPlusLookup.AUD = minPlusLookup.USD; minPlusLookup.NZD = minPlusLookup.USD; if ( mw.util.getParamValue( 'minPlus' ) === '1' || mw.util.getParamValue( 'minPlus' ) === 'true' ) { const currencyEntry = minPlusLookup[ donationForm.currency ]; // Currency not in lookup table. No swapping. if ( !currencyEntry ) return null; const amountKeys = Object.keys( currencyEntry ); // ["amount1", "amount2"] or however many keys in lookup amountKeys.forEach( (amount, index) => { const $radio = $( `#input_amount_${index}` ); const $label = $( `label[for='input_amount_${index}` ); // If the button's amount is equal to "from" in the lookup, perform the swap. // Guards from hpc adjusted amounts as those values won't be present in the lookup. if ( currencyEntry[amount].from === parseFloat( $radio.val() ) ) { $radio.val( currencyEntry[amount].to ); $label.text( donationForm.formatCurrency( currencyEntry[amount].to ) ); } }); } } 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' 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 = donationForm.currency; // https://phabricator.wikimedia.org/T381437 var hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== currency ) { console.log('Highest previous contribution currency does not match form currency, using default amounts'); return; } // Consult this sheet for amounts: https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 var radioAmountsData = { "USD" : { // also used for CAD, AUD, NZD "default" : [ [ 0, [ 2.75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2.75, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], // Direct Mail - fixed amounts "directmail" : [ [ 0, [ 25, 35, 50, 100, 150, 250, 300 ] ] ], "directmail250" : [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ] }, "EUR" : { "default" : [ [ 0, [ 2.50, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2.50, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], }, "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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], }, "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 ] ], [ 5000, [ 5000, 10000, 15000, 20000, 35000, 50000, 100000 ] ], [ 10000, [ 10000, 25000, 50000, 75000, 100000, 150000, 200000 ] ] ], "SEK" : [ [ 0, [ 30, 50, 100, 150, 200, 300, 500 ] ], [ 50, [ 50, 100, 150, 200, 300, 500, 750 ] ], [ 200, [ 200, 300, 500, 750, 1000, 1500, 2000 ] ] ] }; 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 currencyList = [ 'USD', 'CAD', 'AUD', 'NZD', 'GBP', 'EUR' ]; // close enough for ( let i = 0; i < currencyList.length; i++ ) { // FY2425 hpcSets // Major Gifts hpcSets radioAmountsData[ currencyList[i] ].MG_2024_500 = [ [ 0, [ 500, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2024_650 = [ [ 0, [ 650, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; // FY2526 hpcSets // Direct Mail hpcSets radioAmountsData[ currencyList[i] ].DM_2526_15 = [ [ 0, [ 15, 25, 35, 50, 100, 200, 250 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2526_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2526_5000 = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; // Major Gifts hpcSets radioAmountsData[ currencyList[i] ].MG_2526_500_9999 = [ [ 0, [ 750, 850, 1000, 1250, 1500, 1750, 2000 ] ], [ 1000, [ 1500, 2000, 2500, 3000, 3750, 4500, 5000 ] ], [ 3000, [ 4000, 5000, 6000, 7000, 8000, 9000, 10000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_10K = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_250_399 = [ [ 0, [ 500, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_400_499 = [ [ 0, [ 650, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_HNWI_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_HNWI_350 = [ [ 0, [ 350, 400, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_2500 = [ [ 0, [ 2500, 3000, 5000, 7500, 10000, 15000, 25000 ] ] ]; } var appealAmountsData = { "USD" : [ // also used for CAD, AUD, NZD, GBP, EUR [ 0, [ 5, 10, 20 ] ], [ 10, [ 10, 20, 50 ] ], [ 20, [ 20, 30, 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; // Radio button amounts var radioAmounts = pickAmountArray( radioAmountsData, currency, hpc, hpcSet ); if ( radioAmounts.length ) { donationForm.changeAmountOptions( radioAmounts ); } // Appeal amounts var appealAmounts = pickAmountArray( appealAmountsData, currency, hpc, hpcSet ); if ( appealAmounts.length ) { var appealAmountString = appealAmounts.map( donationForm.formatCurrency ).join( ', '); $('.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') || mw.util.getParamValue('preselect') ); if ( preSelectAmount > 0 ) { let hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== donationForm.currency ) { console.log('Highest previous contribution currency does not match form currency, not doing preselection'); return; } 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 preSelectBox() { /* Check for a 'preSelectBox' url parameter, and select that numbered option. If the value provided is invalid or doesn't exist, exit. Valid choices are 1 to 7 (8 is "Other"). If 'preSelect' exists, ignore this function. */ if(!mw.util.getParamValue('preSelect')){ // Check hpcCurrency first before running preselection. let hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== donationForm.currency ) { console.log('Highest previous contribution currency does not match form currency, not preselecting box.'); return; } // If hpc & hpcCurrency provided are okay OR hpc wasn't provided then continue. var preSelectBoxNumber = parseInt( mw.util.getParamValue('preSelectBox') ); if (preSelectBoxNumber >= 1 && preSelectBoxNumber <= 7) { var $preSelectOption = $('input[id="input_amount_' + (preSelectBoxNumber - 1) + '"]'); if ( $preSelectOption.length ) { $preSelectOption.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' : 'vma', 'IT' : 'vmaj', 'LU' : 'vmaj', 'LV' : 'vma', 'NL' : 'vmaj', 'PT' : 'vmaj', 'SK' : 'vmaj', 'GR' : 'vma', // Others 'CZ' : 'vmad', 'DK' : 'vma', 'HU' : 'vma', 'IL' : 'vmad', // 'JP' : 'vmaj', - use text only as there were complaints about Diners Club not being included 'MY' : 'vmaj', 'NO' : 'vma', 'PL' : 'vma', 'RO' : 'vma', 'SE' : 'vma', 'UA' : 'vma', 'ZA' : 'vm', 'ZZ' : 'vmad' // For testing }; 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(''); } /* -- Moved from Template:2012FR/Form-section/Processing/Default -- */ /** * 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; params.country = donationForm.country; // Overrides for specific gateways if ( paymentMethod === 'cc-adyen' ) { params.payment_method = 'cc'; params.gateway = 'adyen'; } else if ( paymentMethod === 'cc-dlocal' ) { params.payment_method = 'cc'; params.gateway = 'dlocal'; } else if ( paymentMethod === 'trustly' ) { params.payment_method = 'dd'; params.payment_submethod = 'ach'; params.gateway = 'gravy'; } else if ( paymentSubMethod === 'sepadirectdebit' ) { params.payment_method = 'rtbt'; params.payment_submethod = 'sepadirectdebit'; params.gateway = 'gravy'; } else if ( paymentMethod === 'bt' && params.country === 'CZ' ) { params.payment_method = 'bt'; params.gateway = 'gravy'; } else if ( paymentSubMethod === 'vipps' ) { params.payment_method = 'ew'; params.payment_submethod = 'vipps'; params.gateway = 'gravy'; } else { params.payment_method = paymentMethod; } // dlocal let dlocalCountries = [ 'AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY', 'ZA' ], dlocalMethods = [ 'cc', 'bt', 'cash', 'cash_boleto', 'pix' ]; if ( dlocalCountries.includes( params.country ) && dlocalMethods.includes( params.payment_method ) ) { params.gateway = 'gravy'; } if ( params.payment_method === 'cc' && params.gateway === undefined ) { params.gateway = 'gravy'; } if ( params.payment_method === 'paypal' ) { params.gateway = 'gravy'; } if ( params.payment_method === 'rtbt' && paymentSubMethod === 'rtbt_ideal' ) { params.gateway = 'gravy'; } if ( params.payment_method === 'apple' || params.payment_method === 'google' ) { params.gateway = 'gravy'; } if ( paymentSubMethod ) { params.payment_submethod = paymentSubMethod; } let frequency = donationForm.getFrequency(); if ( frequency === 'monthly' ) { 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 if ( params.uselang === 'pt' && params.country === 'BR' ) { params.uselang = 'pt-br'; } if ( params.uselang === 'es' && ( params.country === 'AR' || params.country === 'CL' || params.country === 'CO' || params.country === 'MX' || params.country === 'PE' || params.country === 'UY' || params.country === 'US' ) ) { params.uselang = 'es-419'; } var amount = donationForm.getAmount(); if ( $('#ptf-checkbox').prop('checked') ) { amount = amount + donationForm.calculateFee( amount ); donationForm.extraData.ptf = 1; } params.amount = amount; // Email optin if ( $('input[name="opt_in"]').length > 0 ) { 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' ) ) { params.variant = mw.util.getParamValue( 'pym_variant' ); } if ( params.recurring && params.variant && params.variant.match( /monthlyConvert/ ) ) { // Post-payments monthly convert makes no sense if it's already recurring // Avoid things like T312905 delete params.variant; } if ( mw.util.getParamValue( 'pym_appeal' ) ) { params.appeal = mw.util.getParamValue( 'pym_appeal' ); } // Pass through specified parameters to payments unchanged const passThroughParams = [ 'contact_id', 'contact_hash', // https://phabricator.wikimedia.org/T381405 'checksum', 'contribution_recur_id', // https://phabricator.wikimedia.org/T396271 'recipient_id', // SMS 'app_install_id' // https://phabricator.wikimedia.org/T411535 ]; passThroughParams.forEach( ( param ) => { const value = mw.util.getParamValue( param ); if ( value ) { params[ param ] = value; } } ); // Monthly convert if ( mc ) { // check just in-case this wasn't loaded for some reason mc.main( params, donationForm.finalStep ); } else { donationForm.finalStep( params ); } } 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 final tracking parameters, and submit to payments * @param {Object} params */ donationForm.finalStep = function( params ) { var url = new URL('https://payments.wikimedia.org/index.php/Special:GatewayChooser'); // Skip form chooser for Venmo if ( params.payment_method === 'venmo' ) { url = new URL('https://payments.wikimedia.org/index.php/Special:GravyGateway'); } // Skip form chooser for Pix if ( params.payment_method === 'cash' && params.payment_submethod === 'pix' ) { url = new URL('https://payments.wikimedia.org/index.php/Special:GravyGateway'); } 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 * * @param {Object} params * @return {string} wmf_source */ donationForm.buildTrackingSource = function( params ) { var wmf_source = mw.util.getParamValue( 'wmf_source' ) || mw.util.getParamValue( 'utm_source' ); wmf_source += '.'; var fullDottedPaymentMethod = params.payment_method; if ( params.recurring ) { fullDottedPaymentMethod = 'r' + fullDottedPaymentMethod; } if ( params.payment_submethod ) { fullDottedPaymentMethod = fullDottedPaymentMethod + '.' + params.payment_submethod; } /* Get URL parameter, but remove parts using old format. Allow fallback to a default value */ var getParam = function( param, removeText, dflt ) { if ( mw.util.getParamValue( param ) ) { return mw.util.getParamValue( param ).replace( removeText, '' ); } else { return dflt; } }; /* The landing page info, separated by ~. This mostly exists for legacy reasons */ 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 wmf_key from extra tracking data * * @param {Object} data * @return {string} wmf_key */ donationForm.buildTrackingKey = function(data) { var existingKey = mw.util.getParamValue( 'wmf_key' ) || mw.util.getParamValue( 'utm_key' ), dataArray = []; if ( existingKey ) { dataArray.push( existingKey ); } for (var key in data) { if (data.hasOwnProperty(key)) { dataArray.push( key + '_' + data[key] ); } } return dataArray.join('~'); }; /* Return amount selected or input */ donationForm.getAmount = function() { var form = document.forms.donateForm, 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; }; /** * 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 ) { 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.forms.donateForm; // Reset all errors $('.lp-haserror').removeClass('lp-haserror'); $('.lp-error').hide(); if ( !skipAmountValidation && !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(); } } return !error; }; /** * Check if selected amount is valid i.e. a positive number, between minimum and maximum. * If not, show an error and return false. */ donationForm.validateAmount = function() { var amount = donationForm.getAmount(); if ( amount === null || isNaN(amount) || amount <= 0 || amount < donationForm.minLocal ) { $('.amount-options').addClass('lp-haserror'); $('.lp-error-bigamount').hide(); $('.lp-error-smallamount').show().focus(); return false; } else if ( amount > donationForm.maxLocal ) { $('.amount-options').addClass('lp-haserror'); $('.lp-error-bigamount').show().focus(); return false; } else { $('.amount-options').removeClass('lp-haserror'); $('.lp-error-smallamount, .lp-error-bigamount').hide(); return true; } }; donationForm.getFrequency = function() { return document.forms.donateForm.dataset.frequency || 'onetime'; }; donationForm.setFrequency = function( frequency ) { // 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 selectedAmount = donationForm.getAmount(), feeAmount = donationForm.calculateFee( selectedAmount ), feeText; feeText = donationForm.formatCurrency( feeAmount ); $('.ptf label span').text( feeText ); if ( selectedAmount + feeAmount <= donationForm.maxLocal ) { $('.ptf').slideDown(); } }; /** * Calculate approximate transaction fee on given amount * @param {number} amount * @return {number} Rounded to 2 decimal places */ donationForm.calculateFee = function( amount ) { // Minimum fee/PTF amounts. Default is 0.35. // Updated 2019-05-21 to approx 0.35 USD equivalent var feeMinimums = { 'DKK' : 2, 'HUF' : 100, 'ILS' : 1.2, 'INR' : 4, 'JPY' : 35, 'KHR' : 1000, 'MYR' : 1, 'NOK' : 3, 'PLN' : 1.35, 'CZK' : 7.5, 'RON' : 1.5, 'SEK' : 3, 'UAH' : 10, 'ZAR' : 5, // Latin America // Updated 2025-06-10 to approx 0.35 USD equivalent 'BRL' : 2, 'ARS' : 415, 'CLP' : 325, 'COP' : 1450, 'MXN' : 6.75, 'PEN' : 1.28, 'UYU' : 14.5 }; var feeMultiplier = 0.04, feeMinimum = feeMinimums[ donationForm.currency ] || 0.35, feeAmount = amount * feeMultiplier; 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.screen.width >= 640 && country !== 'JP' ) { // T397002 // On a desktop browser, people can scan with their iphone return true; } else if ( window.ApplePaySession ) { // On mobile, check if Apple Pay is available natively if ( ApplePaySession.canMakePayments() ) { return true; } } return false; }; /** * Determine if the annual option should be shown on the donation form, and show it if so * * @returns {boolean} true if the annual option is enabled */ donationForm.initAnnualRecurring = function() { /* Before adding a language here, please check that we have annual translations in-place for: - the button here on donatewiki ([[MediaWiki:Frequency-Annual]]) - the thank you receipt email - donor relations macros - the thank you page (optional if it has no recurring-specific messaging) */ const annualLanguages = ['%%isolang%%', '%25%25ISOLANG%25%25', '%25%25isolang%25%25', 'el', 'en', 'en-ca', 'en-gb', 'en-us', 'es', 'es-419', 'fr', 'it', 'ja', 'nl', 'pt', 'pt-br'] const annualInput = document.getElementById( 'frequency_annual' ); if ( !annualInput ) { // old form without required input return false; } let annualEnabled = annualLanguages.includes( mw.config.get( 'wgPageContentLanguage' ) ); // Allow overriding with URL params if ( mw.util.getParamValue( 'form-countryspecific' ) === 'Form-countryspecific-annual' // compatibility with old method || mw.util.getParamValue( 'annual_enabled' ) === '1' ) { annualEnabled = true; } if ( mw.util.getParamValue( 'annual_enabled' ) === '0' ) { annualEnabled = false; } annualInput.parentNode.style.display = annualEnabled ? 'block' : 'none'; if ( annualEnabled ) { document.forms.donateForm.classList.add( 'annual-enabled' ); } return annualEnabled; }; /** * Change the amount options on the donation form * @param {array} newAmounts */ donationForm.changeAmountOptions = function( newAmounts ) { for (var j = 0; j < newAmounts.length; j++) { var $radio = $( `#input_amount_${j}` ); var $label = $( `label[for="input_amount_${j}"]` ); $radio.val( newAmounts[j] ); $label.text( donationForm.formatCurrency( newAmounts[j] ) ); } }; /* 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; } }; /* End form functions */ $(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 ) { donationForm.initAnnualRecurring(); // hide frequency options for some countries if ( donationForm.noRecurringCountries.indexOf( donationForm.country ) !== -1 ) { $('#frequency_onetime').prop('checked', true); $('.frequency-options, #cancel-monthly, #donate-recurring-smallprint').hide(); } if ( donationForm.noRecurringPaypalCountries.indexOf( donationForm.country ) !== -1 ) { $( '.paymentmethod-pp, .paymentmethod-pp-usd' ).addClass( 'not-monthly-capable' ); } // Format amounts on buttons $( '.amount-options li' ).each( function( index ) { let amount = this.querySelector( 'input' ).value; if ( amount !== 'Other' ) { this.querySelector( 'label' ).innerText = donationForm.formatCurrency( amount ); } }); addCardTypesClass( donationForm.country ); // Only show Amazon for links from Ways to give if ( mw.util.getParamValue( 'wmf_source' ) === 'Waystogive' || mw.util.getParamValue( 'wmf_source' ) === 'Ways_to_Give' ) { $('.paymentmethod-amazon').show(); } // Only show DAF for certain Major Gifts links if ( mw.util.getParamValue( 'wmf_campaign' ) === 'MG2WIR25' ) { $('.paymentmethod-daf').show(); } else { $('.paymentmethod-daf').hide(); } // Apple Pay if ( $('.paymentmethod-applepay').length > 0 ) { if ( !donationForm.shouldShowApplePay( donationForm.country ) ) { $('.paymentmethod-applepay').remove(); } } // Venmo browser check if ( $('.paymentmethod-venmo').length > 0 ) { if ( !donationForm.isVenmoSupported() || donationForm.country !== 'US' ) { $('.paymentmethod-venmo').remove(); } } // Hide Google Pay if people are coming from iOS app https://phabricator.wikimedia.org/T411504 if ( mw.util.getParamValue('wmf_campaign') === 'iOS' ) { $('.paymentmethod-google').remove(); } } // Links open in new tab $('.links-in-new-tab a').attr('target', '_blank'); // Disable logo link $('#p-logo a').attr( { href: '#', 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 frequency if possible if ( donationForm.noRecurringCountries.indexOf( donationForm.country ) === -1 && 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' ); } } // If we are emailing them and they have a contact_id, then we can assume they have opted in, // unless this is a "Remind Me Later" email, or they are in a stricter country let hasContactId = mw.util.getParamValue( 'contact_id' ) !== null; let isRML = mw.util.getParamValue( 'wmf_campaign' ) && mw.util.getParamValue( 'wmf_campaign' ).includes( 'RMLEmail' ); let isStrictCountry = [ 'AT', 'IT' ].includes( donationForm.country ); if ( document.getElementById('optin-yes') && hasContactId && !isRML && !isStrictCountry ) { document.getElementById('optin-yes').checked = true; document.querySelector('.optin-options').style.display = 'none'; } donationForm.initOptin(); try { adjustHPC(); adjustMinAmounts(); preSelect(); // Make sure to do this *after* other fiddling with values preSelectBox(); donationForm.localizeErrors(); } finally { $('.frb-monthly-pitch, .frb-monthly-pitch-thanks, .frb-recurring-pitch').appendTo('.frequency-options'); $('.ptf').appendTo('.amount-options'); $('.optin-options').insertAfter('.amount-options'); $('.consider-amounts').show(); $('#actual-form').show(); $('#actual-form-loading').hide(); } }); }); srympfmt7uk1b8x4xy2dccjs8jxh6mg 42900 42899 2026-07-10T18:03:51Z Pcoombe 5 make it setAmountOptions since I'll be adding a getAmountOptions function too 42900 javascript text/javascript /* jshint strict:false */ /** MediaWiki:DonationForm.js - loaded on all donation forms * TODO: lots of cleanup */ var donationForm = {}; donationForm.loadedTime = Date.now(); donationForm.extraData = { 'vw' : window.innerWidth, 'vh' : window.innerHeight }; donationForm.country = mw.util.getParamValue('country').toUpperCase(); 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 ); // Don't offer recurring at all in these countries donationForm.noRecurringCountries = [ 'AR', 'IN' ]; donationForm.noRecurringPaypalCountries = [ 'CL', 'CO', 'PE', 'UY', 'BR' ]; donationForm.currencyRates = { // From https://github.com/wikimedia/wikimedia-fundraising-SmashPig/blob/master/PaymentData/ReferenceData/CurrencyRates.php // Updated 2025-11-03 'ADF' : 5.69, 'ADP' : 144, 'AED' : 3.67, 'AFA' : 66, 'AFN' : 66, 'ALL' : 83, 'AMD' : 374, 'ANG' : 1.79, 'AOA' : 912, 'AON' : 912, 'ARS' : 1457, 'ATS' : 12, 'AUD' : 1.53, 'AWG' : 1.79, 'AZM' : 8500, 'AZN' : 1.7, 'BAM' : 1.7, 'BBD' : 2, 'BDT' : 121, 'BEF' : 35, 'BGL' : 1.7, 'BGN' : 1.7, 'BHD' : 0.37401652162054, 'BIF' : 2923, 'BMD' : 1, 'BND' : 1.3, 'BOB' : 6.76, 'BRL' : 5.37, 'BSD' : 1, 'BTN' : 89, 'BWP' : 13, 'BYR' : 34102, 'BZD' : 1.98, 'CAD' : 1.4, 'CDF' : 2224, 'CHF' : 0.80650783228772, 'CLP' : 940, 'CNY' : 7.12, 'COP' : 3853, 'CRC' : 496, 'CUC' : 1, 'CUP' : 25, 'CVE' : 96, 'CYP' : 0.50784522451156, 'CZK' : 21, 'DEM' : 1.7, 'DJF' : 178, 'DKK' : 6.48, 'DOP' : 64, 'DZD' : 130, 'ECS' : 24094, 'EEK' : 14, 'EGP' : 47, 'ESP' : 144, 'ETB' : 153, 'EUR' : 0.86770508259643, 'FIM' : 5.16, 'FJD' : 2.27, 'FKP' : 0.76116218937783, 'FRF' : 5.69, 'GBP' : 0.76116218937783, 'GEL' : 2.68, 'GHC' : 108957, 'GHS' : 11, 'GIP' : 0.76116218937783, 'GMD' : 71, 'GNF' : 8637, 'GRD' : 296, 'GTQ' : 7.55, 'GYD' : 205, 'HKD' : 7.77, 'HNL' : 26, 'HRK' : 6.54, 'HTG' : 130, 'HUF' : 336, 'IDR' : 16671, 'IEP' : 0.68337328567002, 'ILS' : 3.25, 'INR' : 89, 'IQD' : 1292, 'IRR' : 42020, 'ISK' : 126, 'ITL' : 1680, 'JMD' : 159, 'JOD' : 0.70900000000001, 'JPY' : 154, 'KES' : 128, 'KGS' : 87, 'KHR' : 3971, 'KMF' : 427, 'KPW' : 135, 'KRW' : 1429, 'KWD' : 0.30641816376358, 'KYD' : 0.83333299999999, 'KZT' : 526, 'LAK' : 21568, 'LBP' : 89680, 'LKR' : 303, 'LRD' : 182, 'LSL' : 17, 'LTL' : 3, 'LUF' : 35, 'LVL' : 0.60982660286911, 'LYD' : 5.44, 'MAD' : 9.19, 'MDL' : 17, 'MGA' : 4474, 'MGF' : 9150, 'MKD' : 53, 'MMK' : 2093, 'MNT' : 2620, 'MOP' : 8.01, 'MRO' : 395, 'MTL' : 0.37250579195865, 'MUR' : 45, 'MVR' : 15, 'MWK' : 1730, 'MXN' : 19, 'MYR' : 4.2, 'MZM' : 63200, 'MZN' : 63, 'NAD' : 17, 'NGN' : 1446, 'NIO' : 36, 'NLG' : 1.91, 'NOK' : 10, 'NPR' : 141, 'NZD' : 1.75, 'OMR' : 0.38352905117543, 'PAB' : 1, 'PEN' : 3.35, 'PGK' : 4.17, 'PHP' : 59, 'PKR' : 282, 'PLN' : 3.69, 'PTE' : 174, 'PYG' : 6991, 'QAR' : 3.6, 'ROL' : 44083, 'RON' : 4.41, 'RSD' : 101, 'RUB' : 81, 'RWF' : 1446, 'SAR' : 3.75, 'SBD' : 8.21, 'SCR' : 14, 'SDD' : 59715, 'SDG' : 597, 'SDP' : 2261, 'SEK' : 9.49, 'SGD' : 1.3, 'SHP' : 0.76116218937783, 'SIT' : 208, 'SKK' : 26, 'SLL' : 19750, 'SOS' : 550, 'SRD' : 39, 'SRG' : 38521, 'STD' : 21169, 'SVC' : 8.75, 'SYP' : 513, 'SZL' : 17, 'THB' : 32, 'TJS' : 9.15, 'TMM' : 16757, 'TMT' : 3.35, 'TND' : 2.93, 'TOP' : 2.4, 'TRL' : 42048152, 'TRY' : 42, 'TTD' : 6.69, 'TWD' : 31, 'TZS' : 2442, 'UAH' : 42, 'UGX' : 3463, 'USD' : 1, 'UYU' : 40, 'UZS' : 11982, 'VEB' : 22204414173, 'VEF' : 22204414, 'VND' : 26302, 'VUV' : 112, 'WST' : 2.71, 'XAF' : 569, 'XAG' : 0.020582109674161, 'XAU' : 0.000249595454823, 'XCD' : 2.7, 'XEU' : 0.86770508259643, 'XOF' : 569, 'XPD' : 0.00068810810716198, 'XPF' : 104, 'XPT' : 0.00063604563466001, 'YER' : 238, 'YUN' : 101, 'ZAR' : 17, '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 = donationForm.currency; $('.lp-error-smallamount').text( function( index, oldText ) { return oldText.replace( '$1', donationForm.formatAmount( donationForm.minLocal ) + '\xa0' + currency ); }); if ( currency === 'USD' ) { // we don't need to include the conversion $('.lp-error-bigamount').text( function( index, oldText ) { return oldText.replace( '($1 $2) ', '' ) .replace( '($1&nbsp;$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 adjustMinAmounts() { // Amounts spreadsheet https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 // Defining lookup table here. Using mw.loader.getScript was visibly too slow for the user (amounts flashing) const minPlusLookup = { // US - Canada - UK - EUR - Australia - New Zealand // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 USD: { amount1: { from: 2.75, to: 4.50 }, amount2: { from: 5, to: 7 }, }, GBP: { amount1: { from: 2, to: 4 }, amount2: { from: 5, to: 7 }, }, EUR: { amount1: { from: 2.50, to: 4.50 }, amount2: { from: 5, to: 7 }, }, // English Bundle // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=891721479#gid=891721479 HUF: { amount1: { from: 500, to: 750 }, }, MYR: { amount1: { from: 10, to: 20 }, amount2: { from: 30, to: 40 }, }, RON: { amount1: { from: 10, to: 30 }, }, // Other // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1865233115#gid=1865233115 CZK: { amount1: { from: 50, to: 100 }, amount2: { from: 100, to: 150 }, }, DKK: { amount1: { from: 20, to: 40 }, amount2: { from: 75, to: 80 }, }, JPY: { amount1: { from: 500, to: 1000 }, amount2: { from: 1000, to: 2000 }, amount3: { from: 2000, to: 3000 }, amount4: { from: 2500, to: 4000 }, amount5: { from: 4000, to: 5000 }, amount6: { from: 5000, to: 10000 }, amount7: { from: 10000, to: 15000 }, }, ZAR: { amount1: { from: 30, to: 50 }, amount2: { from: 50, to: 75 }, }, NOK: { amount1: { from: 30, to: 50 }, }, SEK: { amount1: { from: 30, to: 50 }, amount2: { from: 50, to: 70 }, }, ILS: { amount1: { from: 10, to: 20 }, }, PLN: { amount1: { from: 10, to: 20 }, amount2: { from: 20, to: 30 }, }, CHF: { amount1: { from: 20, to: 30 }, }, THB: { amount1: { from: 100, to: 150 }, amount2: { from: 200, to: 250 }, }, }; // CAD, AUD, NZD = USD amounts minPlusLookup.CAD = minPlusLookup.USD; minPlusLookup.AUD = minPlusLookup.USD; minPlusLookup.NZD = minPlusLookup.USD; if ( mw.util.getParamValue( 'minPlus' ) === '1' || mw.util.getParamValue( 'minPlus' ) === 'true' ) { const currencyEntry = minPlusLookup[ donationForm.currency ]; // Currency not in lookup table. No swapping. if ( !currencyEntry ) return null; const amountKeys = Object.keys( currencyEntry ); // ["amount1", "amount2"] or however many keys in lookup amountKeys.forEach( (amount, index) => { const $radio = $( `#input_amount_${index}` ); const $label = $( `label[for='input_amount_${index}` ); // If the button's amount is equal to "from" in the lookup, perform the swap. // Guards from hpc adjusted amounts as those values won't be present in the lookup. if ( currencyEntry[amount].from === parseFloat( $radio.val() ) ) { $radio.val( currencyEntry[amount].to ); $label.text( donationForm.formatCurrency( currencyEntry[amount].to ) ); } }); } } 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' 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 = donationForm.currency; // https://phabricator.wikimedia.org/T381437 var hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== currency ) { console.log('Highest previous contribution currency does not match form currency, using default amounts'); return; } // Consult this sheet for amounts: https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 var radioAmountsData = { "USD" : { // also used for CAD, AUD, NZD "default" : [ [ 0, [ 2.75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2.75, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], // Direct Mail - fixed amounts "directmail" : [ [ 0, [ 25, 35, 50, 100, 150, 250, 300 ] ] ], "directmail250" : [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ] }, "EUR" : { "default" : [ [ 0, [ 2.50, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2.50, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], }, "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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], }, "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 ] ], [ 5000, [ 5000, 10000, 15000, 20000, 35000, 50000, 100000 ] ], [ 10000, [ 10000, 25000, 50000, 75000, 100000, 150000, 200000 ] ] ], "SEK" : [ [ 0, [ 30, 50, 100, 150, 200, 300, 500 ] ], [ 50, [ 50, 100, 150, 200, 300, 500, 750 ] ], [ 200, [ 200, 300, 500, 750, 1000, 1500, 2000 ] ] ] }; 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 currencyList = [ 'USD', 'CAD', 'AUD', 'NZD', 'GBP', 'EUR' ]; // close enough for ( let i = 0; i < currencyList.length; i++ ) { // FY2425 hpcSets // Major Gifts hpcSets radioAmountsData[ currencyList[i] ].MG_2024_500 = [ [ 0, [ 500, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2024_650 = [ [ 0, [ 650, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; // FY2526 hpcSets // Direct Mail hpcSets radioAmountsData[ currencyList[i] ].DM_2526_15 = [ [ 0, [ 15, 25, 35, 50, 100, 200, 250 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2526_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2526_5000 = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; // Major Gifts hpcSets radioAmountsData[ currencyList[i] ].MG_2526_500_9999 = [ [ 0, [ 750, 850, 1000, 1250, 1500, 1750, 2000 ] ], [ 1000, [ 1500, 2000, 2500, 3000, 3750, 4500, 5000 ] ], [ 3000, [ 4000, 5000, 6000, 7000, 8000, 9000, 10000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_10K = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_250_399 = [ [ 0, [ 500, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_400_499 = [ [ 0, [ 650, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_HNWI_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_HNWI_350 = [ [ 0, [ 350, 400, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_2500 = [ [ 0, [ 2500, 3000, 5000, 7500, 10000, 15000, 25000 ] ] ]; } var appealAmountsData = { "USD" : [ // also used for CAD, AUD, NZD, GBP, EUR [ 0, [ 5, 10, 20 ] ], [ 10, [ 10, 20, 50 ] ], [ 20, [ 20, 30, 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; // Radio button amounts var radioAmounts = pickAmountArray( radioAmountsData, currency, hpc, hpcSet ); if ( radioAmounts.length ) { donationForm.setAmountOptions( radioAmounts ); } // Appeal amounts var appealAmounts = pickAmountArray( appealAmountsData, currency, hpc, hpcSet ); if ( appealAmounts.length ) { var appealAmountString = appealAmounts.map( donationForm.formatCurrency ).join( ', '); $('.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') || mw.util.getParamValue('preselect') ); if ( preSelectAmount > 0 ) { let hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== donationForm.currency ) { console.log('Highest previous contribution currency does not match form currency, not doing preselection'); return; } 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 preSelectBox() { /* Check for a 'preSelectBox' url parameter, and select that numbered option. If the value provided is invalid or doesn't exist, exit. Valid choices are 1 to 7 (8 is "Other"). If 'preSelect' exists, ignore this function. */ if(!mw.util.getParamValue('preSelect')){ // Check hpcCurrency first before running preselection. let hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== donationForm.currency ) { console.log('Highest previous contribution currency does not match form currency, not preselecting box.'); return; } // If hpc & hpcCurrency provided are okay OR hpc wasn't provided then continue. var preSelectBoxNumber = parseInt( mw.util.getParamValue('preSelectBox') ); if (preSelectBoxNumber >= 1 && preSelectBoxNumber <= 7) { var $preSelectOption = $('input[id="input_amount_' + (preSelectBoxNumber - 1) + '"]'); if ( $preSelectOption.length ) { $preSelectOption.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' : 'vma', 'IT' : 'vmaj', 'LU' : 'vmaj', 'LV' : 'vma', 'NL' : 'vmaj', 'PT' : 'vmaj', 'SK' : 'vmaj', 'GR' : 'vma', // Others 'CZ' : 'vmad', 'DK' : 'vma', 'HU' : 'vma', 'IL' : 'vmad', // 'JP' : 'vmaj', - use text only as there were complaints about Diners Club not being included 'MY' : 'vmaj', 'NO' : 'vma', 'PL' : 'vma', 'RO' : 'vma', 'SE' : 'vma', 'UA' : 'vma', 'ZA' : 'vm', 'ZZ' : 'vmad' // For testing }; 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(''); } /* -- Moved from Template:2012FR/Form-section/Processing/Default -- */ /** * 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; params.country = donationForm.country; // Overrides for specific gateways if ( paymentMethod === 'cc-adyen' ) { params.payment_method = 'cc'; params.gateway = 'adyen'; } else if ( paymentMethod === 'cc-dlocal' ) { params.payment_method = 'cc'; params.gateway = 'dlocal'; } else if ( paymentMethod === 'trustly' ) { params.payment_method = 'dd'; params.payment_submethod = 'ach'; params.gateway = 'gravy'; } else if ( paymentSubMethod === 'sepadirectdebit' ) { params.payment_method = 'rtbt'; params.payment_submethod = 'sepadirectdebit'; params.gateway = 'gravy'; } else if ( paymentMethod === 'bt' && params.country === 'CZ' ) { params.payment_method = 'bt'; params.gateway = 'gravy'; } else if ( paymentSubMethod === 'vipps' ) { params.payment_method = 'ew'; params.payment_submethod = 'vipps'; params.gateway = 'gravy'; } else { params.payment_method = paymentMethod; } // dlocal let dlocalCountries = [ 'AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY', 'ZA' ], dlocalMethods = [ 'cc', 'bt', 'cash', 'cash_boleto', 'pix' ]; if ( dlocalCountries.includes( params.country ) && dlocalMethods.includes( params.payment_method ) ) { params.gateway = 'gravy'; } if ( params.payment_method === 'cc' && params.gateway === undefined ) { params.gateway = 'gravy'; } if ( params.payment_method === 'paypal' ) { params.gateway = 'gravy'; } if ( params.payment_method === 'rtbt' && paymentSubMethod === 'rtbt_ideal' ) { params.gateway = 'gravy'; } if ( params.payment_method === 'apple' || params.payment_method === 'google' ) { params.gateway = 'gravy'; } if ( paymentSubMethod ) { params.payment_submethod = paymentSubMethod; } let frequency = donationForm.getFrequency(); if ( frequency === 'monthly' ) { 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 if ( params.uselang === 'pt' && params.country === 'BR' ) { params.uselang = 'pt-br'; } if ( params.uselang === 'es' && ( params.country === 'AR' || params.country === 'CL' || params.country === 'CO' || params.country === 'MX' || params.country === 'PE' || params.country === 'UY' || params.country === 'US' ) ) { params.uselang = 'es-419'; } var amount = donationForm.getAmount(); if ( $('#ptf-checkbox').prop('checked') ) { amount = amount + donationForm.calculateFee( amount ); donationForm.extraData.ptf = 1; } params.amount = amount; // Email optin if ( $('input[name="opt_in"]').length > 0 ) { 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' ) ) { params.variant = mw.util.getParamValue( 'pym_variant' ); } if ( params.recurring && params.variant && params.variant.match( /monthlyConvert/ ) ) { // Post-payments monthly convert makes no sense if it's already recurring // Avoid things like T312905 delete params.variant; } if ( mw.util.getParamValue( 'pym_appeal' ) ) { params.appeal = mw.util.getParamValue( 'pym_appeal' ); } // Pass through specified parameters to payments unchanged const passThroughParams = [ 'contact_id', 'contact_hash', // https://phabricator.wikimedia.org/T381405 'checksum', 'contribution_recur_id', // https://phabricator.wikimedia.org/T396271 'recipient_id', // SMS 'app_install_id' // https://phabricator.wikimedia.org/T411535 ]; passThroughParams.forEach( ( param ) => { const value = mw.util.getParamValue( param ); if ( value ) { params[ param ] = value; } } ); // Monthly convert if ( mc ) { // check just in-case this wasn't loaded for some reason mc.main( params, donationForm.finalStep ); } else { donationForm.finalStep( params ); } } 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 final tracking parameters, and submit to payments * @param {Object} params */ donationForm.finalStep = function( params ) { var url = new URL('https://payments.wikimedia.org/index.php/Special:GatewayChooser'); // Skip form chooser for Venmo if ( params.payment_method === 'venmo' ) { url = new URL('https://payments.wikimedia.org/index.php/Special:GravyGateway'); } // Skip form chooser for Pix if ( params.payment_method === 'cash' && params.payment_submethod === 'pix' ) { url = new URL('https://payments.wikimedia.org/index.php/Special:GravyGateway'); } 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 * * @param {Object} params * @return {string} wmf_source */ donationForm.buildTrackingSource = function( params ) { var wmf_source = mw.util.getParamValue( 'wmf_source' ) || mw.util.getParamValue( 'utm_source' ); wmf_source += '.'; var fullDottedPaymentMethod = params.payment_method; if ( params.recurring ) { fullDottedPaymentMethod = 'r' + fullDottedPaymentMethod; } if ( params.payment_submethod ) { fullDottedPaymentMethod = fullDottedPaymentMethod + '.' + params.payment_submethod; } /* Get URL parameter, but remove parts using old format. Allow fallback to a default value */ var getParam = function( param, removeText, dflt ) { if ( mw.util.getParamValue( param ) ) { return mw.util.getParamValue( param ).replace( removeText, '' ); } else { return dflt; } }; /* The landing page info, separated by ~. This mostly exists for legacy reasons */ 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 wmf_key from extra tracking data * * @param {Object} data * @return {string} wmf_key */ donationForm.buildTrackingKey = function(data) { var existingKey = mw.util.getParamValue( 'wmf_key' ) || mw.util.getParamValue( 'utm_key' ), dataArray = []; if ( existingKey ) { dataArray.push( existingKey ); } for (var key in data) { if (data.hasOwnProperty(key)) { dataArray.push( key + '_' + data[key] ); } } return dataArray.join('~'); }; /* Return amount selected or input */ donationForm.getAmount = function() { var form = document.forms.donateForm, 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; }; /** * 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 ) { 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.forms.donateForm; // Reset all errors $('.lp-haserror').removeClass('lp-haserror'); $('.lp-error').hide(); if ( !skipAmountValidation && !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(); } } return !error; }; /** * Check if selected amount is valid i.e. a positive number, between minimum and maximum. * If not, show an error and return false. */ donationForm.validateAmount = function() { var amount = donationForm.getAmount(); if ( amount === null || isNaN(amount) || amount <= 0 || amount < donationForm.minLocal ) { $('.amount-options').addClass('lp-haserror'); $('.lp-error-bigamount').hide(); $('.lp-error-smallamount').show().focus(); return false; } else if ( amount > donationForm.maxLocal ) { $('.amount-options').addClass('lp-haserror'); $('.lp-error-bigamount').show().focus(); return false; } else { $('.amount-options').removeClass('lp-haserror'); $('.lp-error-smallamount, .lp-error-bigamount').hide(); return true; } }; donationForm.getFrequency = function() { return document.forms.donateForm.dataset.frequency || 'onetime'; }; donationForm.setFrequency = function( frequency ) { // 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 selectedAmount = donationForm.getAmount(), feeAmount = donationForm.calculateFee( selectedAmount ), feeText; feeText = donationForm.formatCurrency( feeAmount ); $('.ptf label span').text( feeText ); if ( selectedAmount + feeAmount <= donationForm.maxLocal ) { $('.ptf').slideDown(); } }; /** * Calculate approximate transaction fee on given amount * @param {number} amount * @return {number} Rounded to 2 decimal places */ donationForm.calculateFee = function( amount ) { // Minimum fee/PTF amounts. Default is 0.35. // Updated 2019-05-21 to approx 0.35 USD equivalent var feeMinimums = { 'DKK' : 2, 'HUF' : 100, 'ILS' : 1.2, 'INR' : 4, 'JPY' : 35, 'KHR' : 1000, 'MYR' : 1, 'NOK' : 3, 'PLN' : 1.35, 'CZK' : 7.5, 'RON' : 1.5, 'SEK' : 3, 'UAH' : 10, 'ZAR' : 5, // Latin America // Updated 2025-06-10 to approx 0.35 USD equivalent 'BRL' : 2, 'ARS' : 415, 'CLP' : 325, 'COP' : 1450, 'MXN' : 6.75, 'PEN' : 1.28, 'UYU' : 14.5 }; var feeMultiplier = 0.04, feeMinimum = feeMinimums[ donationForm.currency ] || 0.35, feeAmount = amount * feeMultiplier; 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.screen.width >= 640 && country !== 'JP' ) { // T397002 // On a desktop browser, people can scan with their iphone return true; } else if ( window.ApplePaySession ) { // On mobile, check if Apple Pay is available natively if ( ApplePaySession.canMakePayments() ) { return true; } } return false; }; /** * Determine if the annual option should be shown on the donation form, and show it if so * * @returns {boolean} true if the annual option is enabled */ donationForm.initAnnualRecurring = function() { /* Before adding a language here, please check that we have annual translations in-place for: - the button here on donatewiki ([[MediaWiki:Frequency-Annual]]) - the thank you receipt email - donor relations macros - the thank you page (optional if it has no recurring-specific messaging) */ const annualLanguages = ['%%isolang%%', '%25%25ISOLANG%25%25', '%25%25isolang%25%25', 'el', 'en', 'en-ca', 'en-gb', 'en-us', 'es', 'es-419', 'fr', 'it', 'ja', 'nl', 'pt', 'pt-br'] const annualInput = document.getElementById( 'frequency_annual' ); if ( !annualInput ) { // old form without required input return false; } let annualEnabled = annualLanguages.includes( mw.config.get( 'wgPageContentLanguage' ) ); // Allow overriding with URL params if ( mw.util.getParamValue( 'form-countryspecific' ) === 'Form-countryspecific-annual' // compatibility with old method || mw.util.getParamValue( 'annual_enabled' ) === '1' ) { annualEnabled = true; } if ( mw.util.getParamValue( 'annual_enabled' ) === '0' ) { annualEnabled = false; } annualInput.parentNode.style.display = annualEnabled ? 'block' : 'none'; if ( annualEnabled ) { document.forms.donateForm.classList.add( 'annual-enabled' ); } return annualEnabled; }; /** * Change the amount options on the donation form * @param {array} newAmounts */ donationForm.setAmountOptions = function( newAmounts ) { for (var j = 0; j < newAmounts.length; j++) { var $radio = $( `#input_amount_${j}` ); var $label = $( `label[for="input_amount_${j}"]` ); $radio.val( newAmounts[j] ); $label.text( donationForm.formatCurrency( newAmounts[j] ) ); } }; /* 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; } }; /* End form functions */ $(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 ) { donationForm.initAnnualRecurring(); // hide frequency options for some countries if ( donationForm.noRecurringCountries.indexOf( donationForm.country ) !== -1 ) { $('#frequency_onetime').prop('checked', true); $('.frequency-options, #cancel-monthly, #donate-recurring-smallprint').hide(); } if ( donationForm.noRecurringPaypalCountries.indexOf( donationForm.country ) !== -1 ) { $( '.paymentmethod-pp, .paymentmethod-pp-usd' ).addClass( 'not-monthly-capable' ); } // Format amounts on buttons $( '.amount-options li' ).each( function( index ) { let amount = this.querySelector( 'input' ).value; if ( amount !== 'Other' ) { this.querySelector( 'label' ).innerText = donationForm.formatCurrency( amount ); } }); addCardTypesClass( donationForm.country ); // Only show Amazon for links from Ways to give if ( mw.util.getParamValue( 'wmf_source' ) === 'Waystogive' || mw.util.getParamValue( 'wmf_source' ) === 'Ways_to_Give' ) { $('.paymentmethod-amazon').show(); } // Only show DAF for certain Major Gifts links if ( mw.util.getParamValue( 'wmf_campaign' ) === 'MG2WIR25' ) { $('.paymentmethod-daf').show(); } else { $('.paymentmethod-daf').hide(); } // Apple Pay if ( $('.paymentmethod-applepay').length > 0 ) { if ( !donationForm.shouldShowApplePay( donationForm.country ) ) { $('.paymentmethod-applepay').remove(); } } // Venmo browser check if ( $('.paymentmethod-venmo').length > 0 ) { if ( !donationForm.isVenmoSupported() || donationForm.country !== 'US' ) { $('.paymentmethod-venmo').remove(); } } // Hide Google Pay if people are coming from iOS app https://phabricator.wikimedia.org/T411504 if ( mw.util.getParamValue('wmf_campaign') === 'iOS' ) { $('.paymentmethod-google').remove(); } } // Links open in new tab $('.links-in-new-tab a').attr('target', '_blank'); // Disable logo link $('#p-logo a').attr( { href: '#', 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 frequency if possible if ( donationForm.noRecurringCountries.indexOf( donationForm.country ) === -1 && 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' ); } } // If we are emailing them and they have a contact_id, then we can assume they have opted in, // unless this is a "Remind Me Later" email, or they are in a stricter country let hasContactId = mw.util.getParamValue( 'contact_id' ) !== null; let isRML = mw.util.getParamValue( 'wmf_campaign' ) && mw.util.getParamValue( 'wmf_campaign' ).includes( 'RMLEmail' ); let isStrictCountry = [ 'AT', 'IT' ].includes( donationForm.country ); if ( document.getElementById('optin-yes') && hasContactId && !isRML && !isStrictCountry ) { document.getElementById('optin-yes').checked = true; document.querySelector('.optin-options').style.display = 'none'; } donationForm.initOptin(); try { adjustHPC(); adjustMinAmounts(); preSelect(); // Make sure to do this *after* other fiddling with values preSelectBox(); donationForm.localizeErrors(); } finally { $('.frb-monthly-pitch, .frb-monthly-pitch-thanks, .frb-recurring-pitch').appendTo('.frequency-options'); $('.ptf').appendTo('.amount-options'); $('.optin-options').insertAfter('.amount-options'); $('.consider-amounts').show(); $('#actual-form').show(); $('#actual-form-loading').hide(); } }); }); fbc38tspuxn90t0kicrg584gfb11mpi 42901 42900 2026-07-10T18:05:59Z Pcoombe 5 42901 javascript text/javascript /* jshint strict:false */ /** MediaWiki:DonationForm.js - loaded on all donation forms * TODO: lots of cleanup */ var donationForm = {}; donationForm.loadedTime = Date.now(); donationForm.extraData = { 'vw' : window.innerWidth, 'vh' : window.innerHeight }; donationForm.country = mw.util.getParamValue('country').toUpperCase(); 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 ); // Don't offer recurring at all in these countries donationForm.noRecurringCountries = [ 'AR', 'IN' ]; donationForm.noRecurringPaypalCountries = [ 'CL', 'CO', 'PE', 'UY', 'BR' ]; donationForm.currencyRates = { // From https://github.com/wikimedia/wikimedia-fundraising-SmashPig/blob/master/PaymentData/ReferenceData/CurrencyRates.php // Updated 2025-11-03 'ADF' : 5.69, 'ADP' : 144, 'AED' : 3.67, 'AFA' : 66, 'AFN' : 66, 'ALL' : 83, 'AMD' : 374, 'ANG' : 1.79, 'AOA' : 912, 'AON' : 912, 'ARS' : 1457, 'ATS' : 12, 'AUD' : 1.53, 'AWG' : 1.79, 'AZM' : 8500, 'AZN' : 1.7, 'BAM' : 1.7, 'BBD' : 2, 'BDT' : 121, 'BEF' : 35, 'BGL' : 1.7, 'BGN' : 1.7, 'BHD' : 0.37401652162054, 'BIF' : 2923, 'BMD' : 1, 'BND' : 1.3, 'BOB' : 6.76, 'BRL' : 5.37, 'BSD' : 1, 'BTN' : 89, 'BWP' : 13, 'BYR' : 34102, 'BZD' : 1.98, 'CAD' : 1.4, 'CDF' : 2224, 'CHF' : 0.80650783228772, 'CLP' : 940, 'CNY' : 7.12, 'COP' : 3853, 'CRC' : 496, 'CUC' : 1, 'CUP' : 25, 'CVE' : 96, 'CYP' : 0.50784522451156, 'CZK' : 21, 'DEM' : 1.7, 'DJF' : 178, 'DKK' : 6.48, 'DOP' : 64, 'DZD' : 130, 'ECS' : 24094, 'EEK' : 14, 'EGP' : 47, 'ESP' : 144, 'ETB' : 153, 'EUR' : 0.86770508259643, 'FIM' : 5.16, 'FJD' : 2.27, 'FKP' : 0.76116218937783, 'FRF' : 5.69, 'GBP' : 0.76116218937783, 'GEL' : 2.68, 'GHC' : 108957, 'GHS' : 11, 'GIP' : 0.76116218937783, 'GMD' : 71, 'GNF' : 8637, 'GRD' : 296, 'GTQ' : 7.55, 'GYD' : 205, 'HKD' : 7.77, 'HNL' : 26, 'HRK' : 6.54, 'HTG' : 130, 'HUF' : 336, 'IDR' : 16671, 'IEP' : 0.68337328567002, 'ILS' : 3.25, 'INR' : 89, 'IQD' : 1292, 'IRR' : 42020, 'ISK' : 126, 'ITL' : 1680, 'JMD' : 159, 'JOD' : 0.70900000000001, 'JPY' : 154, 'KES' : 128, 'KGS' : 87, 'KHR' : 3971, 'KMF' : 427, 'KPW' : 135, 'KRW' : 1429, 'KWD' : 0.30641816376358, 'KYD' : 0.83333299999999, 'KZT' : 526, 'LAK' : 21568, 'LBP' : 89680, 'LKR' : 303, 'LRD' : 182, 'LSL' : 17, 'LTL' : 3, 'LUF' : 35, 'LVL' : 0.60982660286911, 'LYD' : 5.44, 'MAD' : 9.19, 'MDL' : 17, 'MGA' : 4474, 'MGF' : 9150, 'MKD' : 53, 'MMK' : 2093, 'MNT' : 2620, 'MOP' : 8.01, 'MRO' : 395, 'MTL' : 0.37250579195865, 'MUR' : 45, 'MVR' : 15, 'MWK' : 1730, 'MXN' : 19, 'MYR' : 4.2, 'MZM' : 63200, 'MZN' : 63, 'NAD' : 17, 'NGN' : 1446, 'NIO' : 36, 'NLG' : 1.91, 'NOK' : 10, 'NPR' : 141, 'NZD' : 1.75, 'OMR' : 0.38352905117543, 'PAB' : 1, 'PEN' : 3.35, 'PGK' : 4.17, 'PHP' : 59, 'PKR' : 282, 'PLN' : 3.69, 'PTE' : 174, 'PYG' : 6991, 'QAR' : 3.6, 'ROL' : 44083, 'RON' : 4.41, 'RSD' : 101, 'RUB' : 81, 'RWF' : 1446, 'SAR' : 3.75, 'SBD' : 8.21, 'SCR' : 14, 'SDD' : 59715, 'SDG' : 597, 'SDP' : 2261, 'SEK' : 9.49, 'SGD' : 1.3, 'SHP' : 0.76116218937783, 'SIT' : 208, 'SKK' : 26, 'SLL' : 19750, 'SOS' : 550, 'SRD' : 39, 'SRG' : 38521, 'STD' : 21169, 'SVC' : 8.75, 'SYP' : 513, 'SZL' : 17, 'THB' : 32, 'TJS' : 9.15, 'TMM' : 16757, 'TMT' : 3.35, 'TND' : 2.93, 'TOP' : 2.4, 'TRL' : 42048152, 'TRY' : 42, 'TTD' : 6.69, 'TWD' : 31, 'TZS' : 2442, 'UAH' : 42, 'UGX' : 3463, 'USD' : 1, 'UYU' : 40, 'UZS' : 11982, 'VEB' : 22204414173, 'VEF' : 22204414, 'VND' : 26302, 'VUV' : 112, 'WST' : 2.71, 'XAF' : 569, 'XAG' : 0.020582109674161, 'XAU' : 0.000249595454823, 'XCD' : 2.7, 'XEU' : 0.86770508259643, 'XOF' : 569, 'XPD' : 0.00068810810716198, 'XPF' : 104, 'XPT' : 0.00063604563466001, 'YER' : 238, 'YUN' : 101, 'ZAR' : 17, '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 = donationForm.currency; $('.lp-error-smallamount').text( function( index, oldText ) { return oldText.replace( '$1', donationForm.formatAmount( donationForm.minLocal ) + '\xa0' + currency ); }); if ( currency === 'USD' ) { // we don't need to include the conversion $('.lp-error-bigamount').text( function( index, oldText ) { return oldText.replace( '($1 $2) ', '' ) .replace( '($1&nbsp;$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 adjustMinAmounts() { // Amounts spreadsheet https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 // Defining lookup table here. Using mw.loader.getScript was visibly too slow for the user (amounts flashing) const minPlusLookup = { // US - Canada - UK - EUR - Australia - New Zealand // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 USD: { amount1: { from: 2.75, to: 4.50 }, amount2: { from: 5, to: 7 }, }, GBP: { amount1: { from: 2, to: 4 }, amount2: { from: 5, to: 7 }, }, EUR: { amount1: { from: 2.50, to: 4.50 }, amount2: { from: 5, to: 7 }, }, // English Bundle // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=891721479#gid=891721479 HUF: { amount1: { from: 500, to: 750 }, }, MYR: { amount1: { from: 10, to: 20 }, amount2: { from: 30, to: 40 }, }, RON: { amount1: { from: 10, to: 30 }, }, // Other // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1865233115#gid=1865233115 CZK: { amount1: { from: 50, to: 100 }, amount2: { from: 100, to: 150 }, }, DKK: { amount1: { from: 20, to: 40 }, amount2: { from: 75, to: 80 }, }, JPY: { amount1: { from: 500, to: 1000 }, amount2: { from: 1000, to: 2000 }, amount3: { from: 2000, to: 3000 }, amount4: { from: 2500, to: 4000 }, amount5: { from: 4000, to: 5000 }, amount6: { from: 5000, to: 10000 }, amount7: { from: 10000, to: 15000 }, }, ZAR: { amount1: { from: 30, to: 50 }, amount2: { from: 50, to: 75 }, }, NOK: { amount1: { from: 30, to: 50 }, }, SEK: { amount1: { from: 30, to: 50 }, amount2: { from: 50, to: 70 }, }, ILS: { amount1: { from: 10, to: 20 }, }, PLN: { amount1: { from: 10, to: 20 }, amount2: { from: 20, to: 30 }, }, CHF: { amount1: { from: 20, to: 30 }, }, THB: { amount1: { from: 100, to: 150 }, amount2: { from: 200, to: 250 }, }, }; // CAD, AUD, NZD = USD amounts minPlusLookup.CAD = minPlusLookup.USD; minPlusLookup.AUD = minPlusLookup.USD; minPlusLookup.NZD = minPlusLookup.USD; if ( mw.util.getParamValue( 'minPlus' ) === '1' || mw.util.getParamValue( 'minPlus' ) === 'true' ) { const currencyEntry = minPlusLookup[ donationForm.currency ]; // Currency not in lookup table. No swapping. if ( !currencyEntry ) return null; const amountKeys = Object.keys( currencyEntry ); // ["amount1", "amount2"] or however many keys in lookup amountKeys.forEach( (amount, index) => { const $radio = $( `#input_amount_${index}` ); const $label = $( `label[for='input_amount_${index}` ); // If the button's amount is equal to "from" in the lookup, perform the swap. // Guards from hpc adjusted amounts as those values won't be present in the lookup. if ( currencyEntry[amount].from === parseFloat( $radio.val() ) ) { $radio.val( currencyEntry[amount].to ); $label.text( donationForm.formatCurrency( currencyEntry[amount].to ) ); } }); } } 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' 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 = donationForm.currency; // https://phabricator.wikimedia.org/T381437 var hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== currency ) { console.log('Highest previous contribution currency does not match form currency, using default amounts'); return; } // Consult this sheet for amounts: https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 var radioAmountsData = { "USD" : { // also used for CAD, AUD, NZD "default" : [ [ 0, [ 2.75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2.75, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], // Direct Mail - fixed amounts "directmail" : [ [ 0, [ 25, 35, 50, 100, 150, 250, 300 ] ] ], "directmail250" : [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ] }, "EUR" : { "default" : [ [ 0, [ 2.50, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2.50, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], }, "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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], }, "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 ] ], [ 5000, [ 5000, 10000, 15000, 20000, 35000, 50000, 100000 ] ], [ 10000, [ 10000, 25000, 50000, 75000, 100000, 150000, 200000 ] ] ], "SEK" : [ [ 0, [ 30, 50, 100, 150, 200, 300, 500 ] ], [ 50, [ 50, 100, 150, 200, 300, 500, 750 ] ], [ 200, [ 200, 300, 500, 750, 1000, 1500, 2000 ] ] ] }; 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 currencyList = [ 'USD', 'CAD', 'AUD', 'NZD', 'GBP', 'EUR' ]; // close enough for ( let i = 0; i < currencyList.length; i++ ) { // FY2425 hpcSets // Major Gifts hpcSets radioAmountsData[ currencyList[i] ].MG_2024_500 = [ [ 0, [ 500, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2024_650 = [ [ 0, [ 650, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; // FY2526 hpcSets // Direct Mail hpcSets radioAmountsData[ currencyList[i] ].DM_2526_15 = [ [ 0, [ 15, 25, 35, 50, 100, 200, 250 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2526_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2526_5000 = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; // Major Gifts hpcSets radioAmountsData[ currencyList[i] ].MG_2526_500_9999 = [ [ 0, [ 750, 850, 1000, 1250, 1500, 1750, 2000 ] ], [ 1000, [ 1500, 2000, 2500, 3000, 3750, 4500, 5000 ] ], [ 3000, [ 4000, 5000, 6000, 7000, 8000, 9000, 10000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_10K = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_250_399 = [ [ 0, [ 500, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_400_499 = [ [ 0, [ 650, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_HNWI_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_HNWI_350 = [ [ 0, [ 350, 400, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_2500 = [ [ 0, [ 2500, 3000, 5000, 7500, 10000, 15000, 25000 ] ] ]; } var appealAmountsData = { "USD" : [ // also used for CAD, AUD, NZD, GBP, EUR [ 0, [ 5, 10, 20 ] ], [ 10, [ 10, 20, 50 ] ], [ 20, [ 20, 30, 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; // Radio button amounts var radioAmounts = pickAmountArray( radioAmountsData, currency, hpc, hpcSet ); if ( radioAmounts.length ) { donationForm.setAmountOptions( radioAmounts ); } // Appeal amounts var appealAmounts = pickAmountArray( appealAmountsData, currency, hpc, hpcSet ); if ( appealAmounts.length ) { var appealAmountString = appealAmounts.map( donationForm.formatCurrency ).join( ', '); $('.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') || mw.util.getParamValue('preselect') ); if ( preSelectAmount > 0 ) { let hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== donationForm.currency ) { console.log('Highest previous contribution currency does not match form currency, not doing preselection'); return; } 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 preSelectBox() { /* Check for a 'preSelectBox' url parameter, and select that numbered option. If the value provided is invalid or doesn't exist, exit. Valid choices are 1 to 7 (8 is "Other"). If 'preSelect' exists, ignore this function. */ if(!mw.util.getParamValue('preSelect')){ // Check hpcCurrency first before running preselection. let hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== donationForm.currency ) { console.log('Highest previous contribution currency does not match form currency, not preselecting box.'); return; } // If hpc & hpcCurrency provided are okay OR hpc wasn't provided then continue. var preSelectBoxNumber = parseInt( mw.util.getParamValue('preSelectBox') ); if (preSelectBoxNumber >= 1 && preSelectBoxNumber <= 7) { var $preSelectOption = $('input[id="input_amount_' + (preSelectBoxNumber - 1) + '"]'); if ( $preSelectOption.length ) { $preSelectOption.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' : 'vma', 'IT' : 'vmaj', 'LU' : 'vmaj', 'LV' : 'vma', 'NL' : 'vmaj', 'PT' : 'vmaj', 'SK' : 'vmaj', 'GR' : 'vma', // Others 'CZ' : 'vmad', 'DK' : 'vma', 'HU' : 'vma', 'IL' : 'vmad', // 'JP' : 'vmaj', - use text only as there were complaints about Diners Club not being included 'MY' : 'vmaj', 'NO' : 'vma', 'PL' : 'vma', 'RO' : 'vma', 'SE' : 'vma', 'UA' : 'vma', 'ZA' : 'vm', 'ZZ' : 'vmad' // For testing }; 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(''); } /* -- Moved from Template:2012FR/Form-section/Processing/Default -- */ /** * 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; params.country = donationForm.country; // Overrides for specific gateways if ( paymentMethod === 'cc-adyen' ) { params.payment_method = 'cc'; params.gateway = 'adyen'; } else if ( paymentMethod === 'cc-dlocal' ) { params.payment_method = 'cc'; params.gateway = 'dlocal'; } else if ( paymentMethod === 'trustly' ) { params.payment_method = 'dd'; params.payment_submethod = 'ach'; params.gateway = 'gravy'; } else if ( paymentSubMethod === 'sepadirectdebit' ) { params.payment_method = 'rtbt'; params.payment_submethod = 'sepadirectdebit'; params.gateway = 'gravy'; } else if ( paymentMethod === 'bt' && params.country === 'CZ' ) { params.payment_method = 'bt'; params.gateway = 'gravy'; } else if ( paymentSubMethod === 'vipps' ) { params.payment_method = 'ew'; params.payment_submethod = 'vipps'; params.gateway = 'gravy'; } else { params.payment_method = paymentMethod; } // dlocal let dlocalCountries = [ 'AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY', 'ZA' ], dlocalMethods = [ 'cc', 'bt', 'cash', 'cash_boleto', 'pix' ]; if ( dlocalCountries.includes( params.country ) && dlocalMethods.includes( params.payment_method ) ) { params.gateway = 'gravy'; } if ( params.payment_method === 'cc' && params.gateway === undefined ) { params.gateway = 'gravy'; } if ( params.payment_method === 'paypal' ) { params.gateway = 'gravy'; } if ( params.payment_method === 'rtbt' && paymentSubMethod === 'rtbt_ideal' ) { params.gateway = 'gravy'; } if ( params.payment_method === 'apple' || params.payment_method === 'google' ) { params.gateway = 'gravy'; } if ( paymentSubMethod ) { params.payment_submethod = paymentSubMethod; } let frequency = donationForm.getFrequency(); if ( frequency === 'monthly' ) { 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 if ( params.uselang === 'pt' && params.country === 'BR' ) { params.uselang = 'pt-br'; } if ( params.uselang === 'es' && ( params.country === 'AR' || params.country === 'CL' || params.country === 'CO' || params.country === 'MX' || params.country === 'PE' || params.country === 'UY' || params.country === 'US' ) ) { params.uselang = 'es-419'; } var amount = donationForm.getAmount(); if ( $('#ptf-checkbox').prop('checked') ) { amount = amount + donationForm.calculateFee( amount ); donationForm.extraData.ptf = 1; } params.amount = amount; // Email optin if ( $('input[name="opt_in"]').length > 0 ) { 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' ) ) { params.variant = mw.util.getParamValue( 'pym_variant' ); } if ( params.recurring && params.variant && params.variant.match( /monthlyConvert/ ) ) { // Post-payments monthly convert makes no sense if it's already recurring // Avoid things like T312905 delete params.variant; } if ( mw.util.getParamValue( 'pym_appeal' ) ) { params.appeal = mw.util.getParamValue( 'pym_appeal' ); } // Pass through specified parameters to payments unchanged const passThroughParams = [ 'contact_id', 'contact_hash', // https://phabricator.wikimedia.org/T381405 'checksum', 'contribution_recur_id', // https://phabricator.wikimedia.org/T396271 'recipient_id', // SMS 'app_install_id' // https://phabricator.wikimedia.org/T411535 ]; passThroughParams.forEach( ( param ) => { const value = mw.util.getParamValue( param ); if ( value ) { params[ param ] = value; } } ); // Monthly convert if ( mc ) { // check just in-case this wasn't loaded for some reason mc.main( params, donationForm.finalStep ); } else { donationForm.finalStep( params ); } } 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 final tracking parameters, and submit to payments * @param {Object} params */ donationForm.finalStep = function( params ) { var url = new URL('https://payments.wikimedia.org/index.php/Special:GatewayChooser'); // Skip form chooser for Venmo if ( params.payment_method === 'venmo' ) { url = new URL('https://payments.wikimedia.org/index.php/Special:GravyGateway'); } // Skip form chooser for Pix if ( params.payment_method === 'cash' && params.payment_submethod === 'pix' ) { url = new URL('https://payments.wikimedia.org/index.php/Special:GravyGateway'); } 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 * * @param {Object} params * @return {string} wmf_source */ donationForm.buildTrackingSource = function( params ) { var wmf_source = mw.util.getParamValue( 'wmf_source' ) || mw.util.getParamValue( 'utm_source' ); wmf_source += '.'; var fullDottedPaymentMethod = params.payment_method; if ( params.recurring ) { fullDottedPaymentMethod = 'r' + fullDottedPaymentMethod; } if ( params.payment_submethod ) { fullDottedPaymentMethod = fullDottedPaymentMethod + '.' + params.payment_submethod; } /* Get URL parameter, but remove parts using old format. Allow fallback to a default value */ var getParam = function( param, removeText, dflt ) { if ( mw.util.getParamValue( param ) ) { return mw.util.getParamValue( param ).replace( removeText, '' ); } else { return dflt; } }; /* The landing page info, separated by ~. This mostly exists for legacy reasons */ 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 wmf_key from extra tracking data * * @param {Object} data * @return {string} wmf_key */ donationForm.buildTrackingKey = function(data) { var existingKey = mw.util.getParamValue( 'wmf_key' ) || mw.util.getParamValue( 'utm_key' ), dataArray = []; if ( existingKey ) { dataArray.push( existingKey ); } for (var key in data) { if (data.hasOwnProperty(key)) { dataArray.push( key + '_' + data[key] ); } } return dataArray.join('~'); }; /* Return amount selected or input */ donationForm.getAmount = function() { var form = document.forms.donateForm, 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; }; /** * 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 ) { 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.forms.donateForm; // Reset all errors $('.lp-haserror').removeClass('lp-haserror'); $('.lp-error').hide(); if ( !skipAmountValidation && !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(); } } return !error; }; /** * Check if selected amount is valid i.e. a positive number, between minimum and maximum. * If not, show an error and return false. */ donationForm.validateAmount = function() { var amount = donationForm.getAmount(); if ( amount === null || isNaN(amount) || amount <= 0 || amount < donationForm.minLocal ) { $('.amount-options').addClass('lp-haserror'); $('.lp-error-bigamount').hide(); $('.lp-error-smallamount').show().focus(); return false; } else if ( amount > donationForm.maxLocal ) { $('.amount-options').addClass('lp-haserror'); $('.lp-error-bigamount').show().focus(); return false; } else { $('.amount-options').removeClass('lp-haserror'); $('.lp-error-smallamount, .lp-error-bigamount').hide(); return true; } }; donationForm.getFrequency = function() { return document.forms.donateForm.dataset.frequency || 'onetime'; }; donationForm.setFrequency = function( frequency ) { // 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 selectedAmount = donationForm.getAmount(), feeAmount = donationForm.calculateFee( selectedAmount ), feeText; feeText = donationForm.formatCurrency( feeAmount ); $('.ptf label span').text( feeText ); if ( selectedAmount + feeAmount <= donationForm.maxLocal ) { $('.ptf').slideDown(); } }; /** * Calculate approximate transaction fee on given amount * @param {number} amount * @return {number} Rounded to 2 decimal places */ donationForm.calculateFee = function( amount ) { // Minimum fee/PTF amounts. Default is 0.35. // Updated 2019-05-21 to approx 0.35 USD equivalent var feeMinimums = { 'DKK' : 2, 'HUF' : 100, 'ILS' : 1.2, 'INR' : 4, 'JPY' : 35, 'KHR' : 1000, 'MYR' : 1, 'NOK' : 3, 'PLN' : 1.35, 'CZK' : 7.5, 'RON' : 1.5, 'SEK' : 3, 'UAH' : 10, 'ZAR' : 5, // Latin America // Updated 2025-06-10 to approx 0.35 USD equivalent 'BRL' : 2, 'ARS' : 415, 'CLP' : 325, 'COP' : 1450, 'MXN' : 6.75, 'PEN' : 1.28, 'UYU' : 14.5 }; var feeMultiplier = 0.04, feeMinimum = feeMinimums[ donationForm.currency ] || 0.35, feeAmount = amount * feeMultiplier; 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.screen.width >= 640 && country !== 'JP' ) { // T397002 // On a desktop browser, people can scan with their iphone return true; } else if ( window.ApplePaySession ) { // On mobile, check if Apple Pay is available natively if ( ApplePaySession.canMakePayments() ) { return true; } } return false; }; /** * Determine if the annual option should be shown on the donation form, and show it if so * * @returns {boolean} true if the annual option is enabled */ donationForm.initAnnualRecurring = function() { /* Before adding a language here, please check that we have annual translations in-place for: - the button here on donatewiki ([[MediaWiki:Frequency-Annual]]) - the thank you receipt email - donor relations macros - the thank you page (optional if it has no recurring-specific messaging) */ const annualLanguages = ['%%isolang%%', '%25%25ISOLANG%25%25', '%25%25isolang%25%25', 'el', 'en', 'en-ca', 'en-gb', 'en-us', 'es', 'es-419', 'fr', 'it', 'ja', 'nl', 'pt', 'pt-br'] const annualInput = document.getElementById( 'frequency_annual' ); if ( !annualInput ) { // old form without required input return false; } let annualEnabled = annualLanguages.includes( mw.config.get( 'wgPageContentLanguage' ) ); // Allow overriding with URL params if ( mw.util.getParamValue( 'form-countryspecific' ) === 'Form-countryspecific-annual' // compatibility with old method || mw.util.getParamValue( 'annual_enabled' ) === '1' ) { annualEnabled = true; } if ( mw.util.getParamValue( 'annual_enabled' ) === '0' ) { annualEnabled = false; } annualInput.parentNode.style.display = annualEnabled ? 'block' : 'none'; if ( annualEnabled ) { document.forms.donateForm.classList.add( 'annual-enabled' ); } return annualEnabled; }; /** * Change the amount options on the donation form * @param {array} newAmounts */ donationForm.setAmountOptions = function( newAmounts ) { for (var j = 0; j < newAmounts.length; j++) { var $radio = $( `#input_amount_${j}` ); var $label = $( `label[for="input_amount_${j}"]` ); $radio.val( newAmounts[j] ); $label.text( donationForm.formatCurrency( newAmounts[j] ) ); } }; /** * Get the current amount options e.g. to store original amounts before changing them * @returns {array} Array of amounts as numbers */ donationForm.getAmountOptions = function() { let amounts = []; document.querySelectorAll('input[name="amount"]').forEach( (input) => { let amount = parseFloat( input.value ); if ( !isNaN( amount ) ) { amounts.push( amount ); } } ); return amounts; }; /* 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; } }; /* End form functions */ $(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 ) { donationForm.initAnnualRecurring(); // hide frequency options for some countries if ( donationForm.noRecurringCountries.indexOf( donationForm.country ) !== -1 ) { $('#frequency_onetime').prop('checked', true); $('.frequency-options, #cancel-monthly, #donate-recurring-smallprint').hide(); } if ( donationForm.noRecurringPaypalCountries.indexOf( donationForm.country ) !== -1 ) { $( '.paymentmethod-pp, .paymentmethod-pp-usd' ).addClass( 'not-monthly-capable' ); } // Format amounts on buttons $( '.amount-options li' ).each( function( index ) { let amount = this.querySelector( 'input' ).value; if ( amount !== 'Other' ) { this.querySelector( 'label' ).innerText = donationForm.formatCurrency( amount ); } }); addCardTypesClass( donationForm.country ); // Only show Amazon for links from Ways to give if ( mw.util.getParamValue( 'wmf_source' ) === 'Waystogive' || mw.util.getParamValue( 'wmf_source' ) === 'Ways_to_Give' ) { $('.paymentmethod-amazon').show(); } // Only show DAF for certain Major Gifts links if ( mw.util.getParamValue( 'wmf_campaign' ) === 'MG2WIR25' ) { $('.paymentmethod-daf').show(); } else { $('.paymentmethod-daf').hide(); } // Apple Pay if ( $('.paymentmethod-applepay').length > 0 ) { if ( !donationForm.shouldShowApplePay( donationForm.country ) ) { $('.paymentmethod-applepay').remove(); } } // Venmo browser check if ( $('.paymentmethod-venmo').length > 0 ) { if ( !donationForm.isVenmoSupported() || donationForm.country !== 'US' ) { $('.paymentmethod-venmo').remove(); } } // Hide Google Pay if people are coming from iOS app https://phabricator.wikimedia.org/T411504 if ( mw.util.getParamValue('wmf_campaign') === 'iOS' ) { $('.paymentmethod-google').remove(); } } // Links open in new tab $('.links-in-new-tab a').attr('target', '_blank'); // Disable logo link $('#p-logo a').attr( { href: '#', 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 frequency if possible if ( donationForm.noRecurringCountries.indexOf( donationForm.country ) === -1 && 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' ); } } // If we are emailing them and they have a contact_id, then we can assume they have opted in, // unless this is a "Remind Me Later" email, or they are in a stricter country let hasContactId = mw.util.getParamValue( 'contact_id' ) !== null; let isRML = mw.util.getParamValue( 'wmf_campaign' ) && mw.util.getParamValue( 'wmf_campaign' ).includes( 'RMLEmail' ); let isStrictCountry = [ 'AT', 'IT' ].includes( donationForm.country ); if ( document.getElementById('optin-yes') && hasContactId && !isRML && !isStrictCountry ) { document.getElementById('optin-yes').checked = true; document.querySelector('.optin-options').style.display = 'none'; } donationForm.initOptin(); try { adjustHPC(); adjustMinAmounts(); // Store original amounts to switch back later if needed donationForm.originalAmounts = donationForm.getAmountOptions(); preSelect(); // Make sure to do this *after* other fiddling with values preSelectBox(); donationForm.localizeErrors(); } finally { $('.frb-monthly-pitch, .frb-monthly-pitch-thanks, .frb-recurring-pitch').appendTo('.frequency-options'); $('.ptf').appendTo('.amount-options'); $('.optin-options').insertAfter('.amount-options'); $('.consider-amounts').show(); $('#actual-form').show(); $('#actual-form-loading').hide(); } }); }); 31y0kbivssg8o9i2ze42lc0xq7kdtff File:Jimmy Wales NYC 032023.jpg 6 10414 42897 2026-07-10T12:17:17Z EHughes (WMF) 51 42897 wikitext text/x-wiki phoiac9h4m842xq45sp7s6u21eteeq1 MediaWiki:DonationFormMonthlyAmounts.js 8 10415 42902 2026-07-10T18:21:10Z Pcoombe 5 switch to monthly amounts code 42902 javascript text/javascript /* jshint strict:false */ /** MediaWiki:DonationForm.js - loaded on all donation forms * TODO: lots of cleanup */ var donationForm = {}; donationForm.loadedTime = Date.now(); donationForm.extraData = { 'vw' : window.innerWidth, 'vh' : window.innerHeight }; donationForm.country = mw.util.getParamValue('country').toUpperCase(); 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 ); // Don't offer recurring at all in these countries donationForm.noRecurringCountries = [ 'AR', 'IN' ]; donationForm.noRecurringPaypalCountries = [ 'CL', 'CO', 'PE', 'UY', 'BR' ]; donationForm.currencyRates = { // From https://github.com/wikimedia/wikimedia-fundraising-SmashPig/blob/master/PaymentData/ReferenceData/CurrencyRates.php // Updated 2025-11-03 'ADF' : 5.69, 'ADP' : 144, 'AED' : 3.67, 'AFA' : 66, 'AFN' : 66, 'ALL' : 83, 'AMD' : 374, 'ANG' : 1.79, 'AOA' : 912, 'AON' : 912, 'ARS' : 1457, 'ATS' : 12, 'AUD' : 1.53, 'AWG' : 1.79, 'AZM' : 8500, 'AZN' : 1.7, 'BAM' : 1.7, 'BBD' : 2, 'BDT' : 121, 'BEF' : 35, 'BGL' : 1.7, 'BGN' : 1.7, 'BHD' : 0.37401652162054, 'BIF' : 2923, 'BMD' : 1, 'BND' : 1.3, 'BOB' : 6.76, 'BRL' : 5.37, 'BSD' : 1, 'BTN' : 89, 'BWP' : 13, 'BYR' : 34102, 'BZD' : 1.98, 'CAD' : 1.4, 'CDF' : 2224, 'CHF' : 0.80650783228772, 'CLP' : 940, 'CNY' : 7.12, 'COP' : 3853, 'CRC' : 496, 'CUC' : 1, 'CUP' : 25, 'CVE' : 96, 'CYP' : 0.50784522451156, 'CZK' : 21, 'DEM' : 1.7, 'DJF' : 178, 'DKK' : 6.48, 'DOP' : 64, 'DZD' : 130, 'ECS' : 24094, 'EEK' : 14, 'EGP' : 47, 'ESP' : 144, 'ETB' : 153, 'EUR' : 0.86770508259643, 'FIM' : 5.16, 'FJD' : 2.27, 'FKP' : 0.76116218937783, 'FRF' : 5.69, 'GBP' : 0.76116218937783, 'GEL' : 2.68, 'GHC' : 108957, 'GHS' : 11, 'GIP' : 0.76116218937783, 'GMD' : 71, 'GNF' : 8637, 'GRD' : 296, 'GTQ' : 7.55, 'GYD' : 205, 'HKD' : 7.77, 'HNL' : 26, 'HRK' : 6.54, 'HTG' : 130, 'HUF' : 336, 'IDR' : 16671, 'IEP' : 0.68337328567002, 'ILS' : 3.25, 'INR' : 89, 'IQD' : 1292, 'IRR' : 42020, 'ISK' : 126, 'ITL' : 1680, 'JMD' : 159, 'JOD' : 0.70900000000001, 'JPY' : 154, 'KES' : 128, 'KGS' : 87, 'KHR' : 3971, 'KMF' : 427, 'KPW' : 135, 'KRW' : 1429, 'KWD' : 0.30641816376358, 'KYD' : 0.83333299999999, 'KZT' : 526, 'LAK' : 21568, 'LBP' : 89680, 'LKR' : 303, 'LRD' : 182, 'LSL' : 17, 'LTL' : 3, 'LUF' : 35, 'LVL' : 0.60982660286911, 'LYD' : 5.44, 'MAD' : 9.19, 'MDL' : 17, 'MGA' : 4474, 'MGF' : 9150, 'MKD' : 53, 'MMK' : 2093, 'MNT' : 2620, 'MOP' : 8.01, 'MRO' : 395, 'MTL' : 0.37250579195865, 'MUR' : 45, 'MVR' : 15, 'MWK' : 1730, 'MXN' : 19, 'MYR' : 4.2, 'MZM' : 63200, 'MZN' : 63, 'NAD' : 17, 'NGN' : 1446, 'NIO' : 36, 'NLG' : 1.91, 'NOK' : 10, 'NPR' : 141, 'NZD' : 1.75, 'OMR' : 0.38352905117543, 'PAB' : 1, 'PEN' : 3.35, 'PGK' : 4.17, 'PHP' : 59, 'PKR' : 282, 'PLN' : 3.69, 'PTE' : 174, 'PYG' : 6991, 'QAR' : 3.6, 'ROL' : 44083, 'RON' : 4.41, 'RSD' : 101, 'RUB' : 81, 'RWF' : 1446, 'SAR' : 3.75, 'SBD' : 8.21, 'SCR' : 14, 'SDD' : 59715, 'SDG' : 597, 'SDP' : 2261, 'SEK' : 9.49, 'SGD' : 1.3, 'SHP' : 0.76116218937783, 'SIT' : 208, 'SKK' : 26, 'SLL' : 19750, 'SOS' : 550, 'SRD' : 39, 'SRG' : 38521, 'STD' : 21169, 'SVC' : 8.75, 'SYP' : 513, 'SZL' : 17, 'THB' : 32, 'TJS' : 9.15, 'TMM' : 16757, 'TMT' : 3.35, 'TND' : 2.93, 'TOP' : 2.4, 'TRL' : 42048152, 'TRY' : 42, 'TTD' : 6.69, 'TWD' : 31, 'TZS' : 2442, 'UAH' : 42, 'UGX' : 3463, 'USD' : 1, 'UYU' : 40, 'UZS' : 11982, 'VEB' : 22204414173, 'VEF' : 22204414, 'VND' : 26302, 'VUV' : 112, 'WST' : 2.71, 'XAF' : 569, 'XAG' : 0.020582109674161, 'XAU' : 0.000249595454823, 'XCD' : 2.7, 'XEU' : 0.86770508259643, 'XOF' : 569, 'XPD' : 0.00068810810716198, 'XPF' : 104, 'XPT' : 0.00063604563466001, 'YER' : 238, 'YUN' : 101, 'ZAR' : 17, '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 = donationForm.currency; $('.lp-error-smallamount').text( function( index, oldText ) { return oldText.replace( '$1', donationForm.formatAmount( donationForm.minLocal ) + '\xa0' + currency ); }); if ( currency === 'USD' ) { // we don't need to include the conversion $('.lp-error-bigamount').text( function( index, oldText ) { return oldText.replace( '($1 $2) ', '' ) .replace( '($1&nbsp;$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 adjustMinAmounts() { // Amounts spreadsheet https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 // Defining lookup table here. Using mw.loader.getScript was visibly too slow for the user (amounts flashing) const minPlusLookup = { // US - Canada - UK - EUR - Australia - New Zealand // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 USD: { amount1: { from: 2.75, to: 4.50 }, amount2: { from: 5, to: 7 }, }, GBP: { amount1: { from: 2, to: 4 }, amount2: { from: 5, to: 7 }, }, EUR: { amount1: { from: 2.50, to: 4.50 }, amount2: { from: 5, to: 7 }, }, // English Bundle // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=891721479#gid=891721479 HUF: { amount1: { from: 500, to: 750 }, }, MYR: { amount1: { from: 10, to: 20 }, amount2: { from: 30, to: 40 }, }, RON: { amount1: { from: 10, to: 30 }, }, // Other // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1865233115#gid=1865233115 CZK: { amount1: { from: 50, to: 100 }, amount2: { from: 100, to: 150 }, }, DKK: { amount1: { from: 20, to: 40 }, amount2: { from: 75, to: 80 }, }, JPY: { amount1: { from: 500, to: 1000 }, amount2: { from: 1000, to: 2000 }, amount3: { from: 2000, to: 3000 }, amount4: { from: 2500, to: 4000 }, amount5: { from: 4000, to: 5000 }, amount6: { from: 5000, to: 10000 }, amount7: { from: 10000, to: 15000 }, }, ZAR: { amount1: { from: 30, to: 50 }, amount2: { from: 50, to: 75 }, }, NOK: { amount1: { from: 30, to: 50 }, }, SEK: { amount1: { from: 30, to: 50 }, amount2: { from: 50, to: 70 }, }, ILS: { amount1: { from: 10, to: 20 }, }, PLN: { amount1: { from: 10, to: 20 }, amount2: { from: 20, to: 30 }, }, CHF: { amount1: { from: 20, to: 30 }, }, THB: { amount1: { from: 100, to: 150 }, amount2: { from: 200, to: 250 }, }, }; // CAD, AUD, NZD = USD amounts minPlusLookup.CAD = minPlusLookup.USD; minPlusLookup.AUD = minPlusLookup.USD; minPlusLookup.NZD = minPlusLookup.USD; if ( mw.util.getParamValue( 'minPlus' ) === '1' || mw.util.getParamValue( 'minPlus' ) === 'true' ) { const currencyEntry = minPlusLookup[ donationForm.currency ]; // Currency not in lookup table. No swapping. if ( !currencyEntry ) return null; const amountKeys = Object.keys( currencyEntry ); // ["amount1", "amount2"] or however many keys in lookup amountKeys.forEach( (amount, index) => { const $radio = $( `#input_amount_${index}` ); const $label = $( `label[for='input_amount_${index}` ); // If the button's amount is equal to "from" in the lookup, perform the swap. // Guards from hpc adjusted amounts as those values won't be present in the lookup. if ( currencyEntry[amount].from === parseFloat( $radio.val() ) ) { $radio.val( currencyEntry[amount].to ); $label.text( donationForm.formatCurrency( currencyEntry[amount].to ) ); } }); } } 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' 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 = donationForm.currency; // https://phabricator.wikimedia.org/T381437 var hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== currency ) { console.log('Highest previous contribution currency does not match form currency, using default amounts'); return; } // Consult this sheet for amounts: https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 var radioAmountsData = { "USD" : { // also used for CAD, AUD, NZD "default" : [ [ 0, [ 2.75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2.75, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], // Direct Mail - fixed amounts "directmail" : [ [ 0, [ 25, 35, 50, 100, 150, 250, 300 ] ] ], "directmail250" : [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ] }, "EUR" : { "default" : [ [ 0, [ 2.50, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2.50, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], }, "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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], }, "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 ] ], [ 5000, [ 5000, 10000, 15000, 20000, 35000, 50000, 100000 ] ], [ 10000, [ 10000, 25000, 50000, 75000, 100000, 150000, 200000 ] ] ], "SEK" : [ [ 0, [ 30, 50, 100, 150, 200, 300, 500 ] ], [ 50, [ 50, 100, 150, 200, 300, 500, 750 ] ], [ 200, [ 200, 300, 500, 750, 1000, 1500, 2000 ] ] ] }; 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 currencyList = [ 'USD', 'CAD', 'AUD', 'NZD', 'GBP', 'EUR' ]; // close enough for ( let i = 0; i < currencyList.length; i++ ) { // FY2425 hpcSets // Major Gifts hpcSets radioAmountsData[ currencyList[i] ].MG_2024_500 = [ [ 0, [ 500, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2024_650 = [ [ 0, [ 650, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; // FY2526 hpcSets // Direct Mail hpcSets radioAmountsData[ currencyList[i] ].DM_2526_15 = [ [ 0, [ 15, 25, 35, 50, 100, 200, 250 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2526_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2526_5000 = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; // Major Gifts hpcSets radioAmountsData[ currencyList[i] ].MG_2526_500_9999 = [ [ 0, [ 750, 850, 1000, 1250, 1500, 1750, 2000 ] ], [ 1000, [ 1500, 2000, 2500, 3000, 3750, 4500, 5000 ] ], [ 3000, [ 4000, 5000, 6000, 7000, 8000, 9000, 10000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_10K = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_250_399 = [ [ 0, [ 500, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_400_499 = [ [ 0, [ 650, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_HNWI_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_HNWI_350 = [ [ 0, [ 350, 400, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_2500 = [ [ 0, [ 2500, 3000, 5000, 7500, 10000, 15000, 25000 ] ] ]; } var appealAmountsData = { "USD" : [ // also used for CAD, AUD, NZD, GBP, EUR [ 0, [ 5, 10, 20 ] ], [ 10, [ 10, 20, 50 ] ], [ 20, [ 20, 30, 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; // Radio button amounts var radioAmounts = pickAmountArray( radioAmountsData, currency, hpc, hpcSet ); if ( radioAmounts.length ) { donationForm.setAmountOptions( radioAmounts ); } // Appeal amounts var appealAmounts = pickAmountArray( appealAmountsData, currency, hpc, hpcSet ); if ( appealAmounts.length ) { var appealAmountString = appealAmounts.map( donationForm.formatCurrency ).join( ', '); $('.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') || mw.util.getParamValue('preselect') ); if ( preSelectAmount > 0 ) { let hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== donationForm.currency ) { console.log('Highest previous contribution currency does not match form currency, not doing preselection'); return; } 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 preSelectBox() { /* Check for a 'preSelectBox' url parameter, and select that numbered option. If the value provided is invalid or doesn't exist, exit. Valid choices are 1 to 7 (8 is "Other"). If 'preSelect' exists, ignore this function. */ if(!mw.util.getParamValue('preSelect')){ // Check hpcCurrency first before running preselection. let hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== donationForm.currency ) { console.log('Highest previous contribution currency does not match form currency, not preselecting box.'); return; } // If hpc & hpcCurrency provided are okay OR hpc wasn't provided then continue. var preSelectBoxNumber = parseInt( mw.util.getParamValue('preSelectBox') ); if (preSelectBoxNumber >= 1 && preSelectBoxNumber <= 7) { var $preSelectOption = $('input[id="input_amount_' + (preSelectBoxNumber - 1) + '"]'); if ( $preSelectOption.length ) { $preSelectOption.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' : 'vma', 'IT' : 'vmaj', 'LU' : 'vmaj', 'LV' : 'vma', 'NL' : 'vmaj', 'PT' : 'vmaj', 'SK' : 'vmaj', 'GR' : 'vma', // Others 'CZ' : 'vmad', 'DK' : 'vma', 'HU' : 'vma', 'IL' : 'vmad', // 'JP' : 'vmaj', - use text only as there were complaints about Diners Club not being included 'MY' : 'vmaj', 'NO' : 'vma', 'PL' : 'vma', 'RO' : 'vma', 'SE' : 'vma', 'UA' : 'vma', 'ZA' : 'vm', 'ZZ' : 'vmad' // For testing }; 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(''); } /* -- Moved from Template:2012FR/Form-section/Processing/Default -- */ /** * 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; params.country = donationForm.country; // Overrides for specific gateways if ( paymentMethod === 'cc-adyen' ) { params.payment_method = 'cc'; params.gateway = 'adyen'; } else if ( paymentMethod === 'cc-dlocal' ) { params.payment_method = 'cc'; params.gateway = 'dlocal'; } else if ( paymentMethod === 'trustly' ) { params.payment_method = 'dd'; params.payment_submethod = 'ach'; params.gateway = 'gravy'; } else if ( paymentSubMethod === 'sepadirectdebit' ) { params.payment_method = 'rtbt'; params.payment_submethod = 'sepadirectdebit'; params.gateway = 'gravy'; } else if ( paymentMethod === 'bt' && params.country === 'CZ' ) { params.payment_method = 'bt'; params.gateway = 'gravy'; } else if ( paymentSubMethod === 'vipps' ) { params.payment_method = 'ew'; params.payment_submethod = 'vipps'; params.gateway = 'gravy'; } else { params.payment_method = paymentMethod; } // dlocal let dlocalCountries = [ 'AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY', 'ZA' ], dlocalMethods = [ 'cc', 'bt', 'cash', 'cash_boleto', 'pix' ]; if ( dlocalCountries.includes( params.country ) && dlocalMethods.includes( params.payment_method ) ) { params.gateway = 'gravy'; } if ( params.payment_method === 'cc' && params.gateway === undefined ) { params.gateway = 'gravy'; } if ( params.payment_method === 'paypal' ) { params.gateway = 'gravy'; } if ( params.payment_method === 'rtbt' && paymentSubMethod === 'rtbt_ideal' ) { params.gateway = 'gravy'; } if ( params.payment_method === 'apple' || params.payment_method === 'google' ) { params.gateway = 'gravy'; } if ( paymentSubMethod ) { params.payment_submethod = paymentSubMethod; } let frequency = donationForm.getFrequency(); if ( frequency === 'monthly' ) { 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 if ( params.uselang === 'pt' && params.country === 'BR' ) { params.uselang = 'pt-br'; } if ( params.uselang === 'es' && ( params.country === 'AR' || params.country === 'CL' || params.country === 'CO' || params.country === 'MX' || params.country === 'PE' || params.country === 'UY' || params.country === 'US' ) ) { params.uselang = 'es-419'; } var amount = donationForm.getAmount(); if ( $('#ptf-checkbox').prop('checked') ) { amount = amount + donationForm.calculateFee( amount ); donationForm.extraData.ptf = 1; } params.amount = amount; // Email optin if ( $('input[name="opt_in"]').length > 0 ) { 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' ) ) { params.variant = mw.util.getParamValue( 'pym_variant' ); } if ( params.recurring && params.variant && params.variant.match( /monthlyConvert/ ) ) { // Post-payments monthly convert makes no sense if it's already recurring // Avoid things like T312905 delete params.variant; } if ( mw.util.getParamValue( 'pym_appeal' ) ) { params.appeal = mw.util.getParamValue( 'pym_appeal' ); } // Pass through specified parameters to payments unchanged const passThroughParams = [ 'contact_id', 'contact_hash', // https://phabricator.wikimedia.org/T381405 'checksum', 'contribution_recur_id', // https://phabricator.wikimedia.org/T396271 'recipient_id', // SMS 'app_install_id' // https://phabricator.wikimedia.org/T411535 ]; passThroughParams.forEach( ( param ) => { const value = mw.util.getParamValue( param ); if ( value ) { params[ param ] = value; } } ); // Monthly convert if ( mc ) { // check just in-case this wasn't loaded for some reason mc.main( params, donationForm.finalStep ); } else { donationForm.finalStep( params ); } } 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 final tracking parameters, and submit to payments * @param {Object} params */ donationForm.finalStep = function( params ) { var url = new URL('https://payments.wikimedia.org/index.php/Special:GatewayChooser'); // Skip form chooser for Venmo if ( params.payment_method === 'venmo' ) { url = new URL('https://payments.wikimedia.org/index.php/Special:GravyGateway'); } // Skip form chooser for Pix if ( params.payment_method === 'cash' && params.payment_submethod === 'pix' ) { url = new URL('https://payments.wikimedia.org/index.php/Special:GravyGateway'); } 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 * * @param {Object} params * @return {string} wmf_source */ donationForm.buildTrackingSource = function( params ) { var wmf_source = mw.util.getParamValue( 'wmf_source' ) || mw.util.getParamValue( 'utm_source' ); wmf_source += '.'; var fullDottedPaymentMethod = params.payment_method; if ( params.recurring ) { fullDottedPaymentMethod = 'r' + fullDottedPaymentMethod; } if ( params.payment_submethod ) { fullDottedPaymentMethod = fullDottedPaymentMethod + '.' + params.payment_submethod; } /* Get URL parameter, but remove parts using old format. Allow fallback to a default value */ var getParam = function( param, removeText, dflt ) { if ( mw.util.getParamValue( param ) ) { return mw.util.getParamValue( param ).replace( removeText, '' ); } else { return dflt; } }; /* The landing page info, separated by ~. This mostly exists for legacy reasons */ 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 wmf_key from extra tracking data * * @param {Object} data * @return {string} wmf_key */ donationForm.buildTrackingKey = function(data) { var existingKey = mw.util.getParamValue( 'wmf_key' ) || mw.util.getParamValue( 'utm_key' ), dataArray = []; if ( existingKey ) { dataArray.push( existingKey ); } for (var key in data) { if (data.hasOwnProperty(key)) { dataArray.push( key + '_' + data[key] ); } } return dataArray.join('~'); }; /* Return amount selected or input */ donationForm.getAmount = function() { var form = document.forms.donateForm, 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; }; /** * 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 ) { 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.forms.donateForm; // Reset all errors $('.lp-haserror').removeClass('lp-haserror'); $('.lp-error').hide(); if ( !skipAmountValidation && !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(); } } return !error; }; /** * Check if selected amount is valid i.e. a positive number, between minimum and maximum. * If not, show an error and return false. */ donationForm.validateAmount = function() { var amount = donationForm.getAmount(); if ( amount === null || isNaN(amount) || amount <= 0 || amount < donationForm.minLocal ) { $('.amount-options').addClass('lp-haserror'); $('.lp-error-bigamount').hide(); $('.lp-error-smallamount').show().focus(); return false; } else if ( amount > donationForm.maxLocal ) { $('.amount-options').addClass('lp-haserror'); $('.lp-error-bigamount').show().focus(); return false; } else { $('.amount-options').removeClass('lp-haserror'); $('.lp-error-smallamount, .lp-error-bigamount').hide(); return true; } }; donationForm.getFrequency = function() { return document.forms.donateForm.dataset.frequency || 'onetime'; }; donationForm.setFrequency = function( frequency ) { // TODO: add some validation to reject invalid frequency values let form = document.forms.donateForm; form.frequency.value = frequency; // change input form.dataset.frequency = frequency; if ( frequency === 'monthly' ) { donationForm.switchToMonthlyAmounts(); } else { donationForm.setAmountOptions( donationForm.originalAmounts ); } }; /* Wrapper for compatibility with old forms */ donationForm.toggleMonthly = function( monthly ) { if ( monthly ) { donationForm.setFrequency( 'monthly' ); } else { donationForm.setFrequency( 'onetime' ); } }; donationForm.updateFeeDisplay = function() { var selectedAmount = donationForm.getAmount(), feeAmount = donationForm.calculateFee( selectedAmount ), feeText; feeText = donationForm.formatCurrency( feeAmount ); $('.ptf label span').text( feeText ); if ( selectedAmount + feeAmount <= donationForm.maxLocal ) { $('.ptf').slideDown(); } }; /** * Calculate approximate transaction fee on given amount * @param {number} amount * @return {number} Rounded to 2 decimal places */ donationForm.calculateFee = function( amount ) { // Minimum fee/PTF amounts. Default is 0.35. // Updated 2019-05-21 to approx 0.35 USD equivalent var feeMinimums = { 'DKK' : 2, 'HUF' : 100, 'ILS' : 1.2, 'INR' : 4, 'JPY' : 35, 'KHR' : 1000, 'MYR' : 1, 'NOK' : 3, 'PLN' : 1.35, 'CZK' : 7.5, 'RON' : 1.5, 'SEK' : 3, 'UAH' : 10, 'ZAR' : 5, // Latin America // Updated 2025-06-10 to approx 0.35 USD equivalent 'BRL' : 2, 'ARS' : 415, 'CLP' : 325, 'COP' : 1450, 'MXN' : 6.75, 'PEN' : 1.28, 'UYU' : 14.5 }; var feeMultiplier = 0.04, feeMinimum = feeMinimums[ donationForm.currency ] || 0.35, feeAmount = amount * feeMultiplier; 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.screen.width >= 640 && country !== 'JP' ) { // T397002 // On a desktop browser, people can scan with their iphone return true; } else if ( window.ApplePaySession ) { // On mobile, check if Apple Pay is available natively if ( ApplePaySession.canMakePayments() ) { return true; } } return false; }; /** * Determine if the annual option should be shown on the donation form, and show it if so * * @returns {boolean} true if the annual option is enabled */ donationForm.initAnnualRecurring = function() { /* Before adding a language here, please check that we have annual translations in-place for: - the button here on donatewiki ([[MediaWiki:Frequency-Annual]]) - the thank you receipt email - donor relations macros - the thank you page (optional if it has no recurring-specific messaging) */ const annualLanguages = ['%%isolang%%', '%25%25ISOLANG%25%25', '%25%25isolang%25%25', 'el', 'en', 'en-ca', 'en-gb', 'en-us', 'es', 'es-419', 'fr', 'it', 'ja', 'nl', 'pt', 'pt-br'] const annualInput = document.getElementById( 'frequency_annual' ); if ( !annualInput ) { // old form without required input return false; } let annualEnabled = annualLanguages.includes( mw.config.get( 'wgPageContentLanguage' ) ); // Allow overriding with URL params if ( mw.util.getParamValue( 'form-countryspecific' ) === 'Form-countryspecific-annual' // compatibility with old method || mw.util.getParamValue( 'annual_enabled' ) === '1' ) { annualEnabled = true; } if ( mw.util.getParamValue( 'annual_enabled' ) === '0' ) { annualEnabled = false; } annualInput.parentNode.style.display = annualEnabled ? 'block' : 'none'; if ( annualEnabled ) { document.forms.donateForm.classList.add( 'annual-enabled' ); } return annualEnabled; }; /** * Change the amount options on the donation form * @param {array} newAmounts */ donationForm.setAmountOptions = function( newAmounts ) { for (var j = 0; j < newAmounts.length; j++) { var $radio = $( `#input_amount_${j}` ); var $label = $( `label[for="input_amount_${j}"]` ); $radio.val( newAmounts[j] ); $label.text( donationForm.formatCurrency( newAmounts[j] ) ); } }; /** * Get the current amount options e.g. to store original amounts before changing them * @returns {array} Array of amounts as numbers */ donationForm.getAmountOptions = function() { let amounts = []; document.querySelectorAll('input[name="amount"]').forEach( (input) => { let amount = parseFloat( input.value ); if ( !isNaN( amount ) ) { amounts.push( amount ); } } ); return amounts; }; donationForm.switchToMonthlyAmounts = function() { let currency = donationForm.currency; let hpcSet = mw.util.getParamValue('hpcSet'); let hpc = parseFloat( mw.util.getParamValue('hpc') ); let monthlyAmountsData = { "USD": { "default": [ [ 0, [ 1.50, 1.75, 2, 4, 5, 10, 15 ] ], [ 100, [ 15, 20, 25, 30, 35, 40, 80 ] ] ] } }; monthlyAmountsData.AUD = monthlyAmountsData.USD; monthlyAmountsData.CAD = monthlyAmountsData.USD; monthlyAmountsData.NZD = monthlyAmountsData.USD; let monthlyAmounts = pickAmountArray( monthlyAmountsData, currency, hpc, hpcSet ); if ( monthlyAmounts.length ) { donationForm.setAmountOptions( monthlyAmounts ); } } /* 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; } }; /* End form functions */ $(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 ) { donationForm.initAnnualRecurring(); // hide frequency options for some countries if ( donationForm.noRecurringCountries.indexOf( donationForm.country ) !== -1 ) { $('#frequency_onetime').prop('checked', true); $('.frequency-options, #cancel-monthly, #donate-recurring-smallprint').hide(); } if ( donationForm.noRecurringPaypalCountries.indexOf( donationForm.country ) !== -1 ) { $( '.paymentmethod-pp, .paymentmethod-pp-usd' ).addClass( 'not-monthly-capable' ); } // Format amounts on buttons $( '.amount-options li' ).each( function( index ) { let amount = this.querySelector( 'input' ).value; if ( amount !== 'Other' ) { this.querySelector( 'label' ).innerText = donationForm.formatCurrency( amount ); } }); addCardTypesClass( donationForm.country ); // Only show Amazon for links from Ways to give if ( mw.util.getParamValue( 'wmf_source' ) === 'Waystogive' || mw.util.getParamValue( 'wmf_source' ) === 'Ways_to_Give' ) { $('.paymentmethod-amazon').show(); } // Only show DAF for certain Major Gifts links if ( mw.util.getParamValue( 'wmf_campaign' ) === 'MG2WIR25' ) { $('.paymentmethod-daf').show(); } else { $('.paymentmethod-daf').hide(); } // Apple Pay if ( $('.paymentmethod-applepay').length > 0 ) { if ( !donationForm.shouldShowApplePay( donationForm.country ) ) { $('.paymentmethod-applepay').remove(); } } // Venmo browser check if ( $('.paymentmethod-venmo').length > 0 ) { if ( !donationForm.isVenmoSupported() || donationForm.country !== 'US' ) { $('.paymentmethod-venmo').remove(); } } // Hide Google Pay if people are coming from iOS app https://phabricator.wikimedia.org/T411504 if ( mw.util.getParamValue('wmf_campaign') === 'iOS' ) { $('.paymentmethod-google').remove(); } } // Links open in new tab $('.links-in-new-tab a').attr('target', '_blank'); // Disable logo link $('#p-logo a').attr( { href: '#', 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 frequency if possible if ( donationForm.noRecurringCountries.indexOf( donationForm.country ) === -1 && 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' ); } } // If we are emailing them and they have a contact_id, then we can assume they have opted in, // unless this is a "Remind Me Later" email, or they are in a stricter country let hasContactId = mw.util.getParamValue( 'contact_id' ) !== null; let isRML = mw.util.getParamValue( 'wmf_campaign' ) && mw.util.getParamValue( 'wmf_campaign' ).includes( 'RMLEmail' ); let isStrictCountry = [ 'AT', 'IT' ].includes( donationForm.country ); if ( document.getElementById('optin-yes') && hasContactId && !isRML && !isStrictCountry ) { document.getElementById('optin-yes').checked = true; document.querySelector('.optin-options').style.display = 'none'; } donationForm.initOptin(); try { adjustHPC(); adjustMinAmounts(); // Store original amounts to switch back later if needed donationForm.originalAmounts = donationForm.getAmountOptions(); preSelect(); // Make sure to do this *after* other fiddling with values preSelectBox(); donationForm.localizeErrors(); } finally { $('.frb-monthly-pitch, .frb-monthly-pitch-thanks, .frb-recurring-pitch').appendTo('.frequency-options'); $('.ptf').appendTo('.amount-options'); $('.optin-options').insertAfter('.amount-options'); $('.consider-amounts').show(); $('#actual-form').show(); $('#actual-form-loading').hide(); } }); }); 2zo1v42bc14pi65pjtw4fi80luq9d4o 42903 42902 2026-07-10T18:25:05Z Pcoombe 5 move preSelectFrequency to run after storing original amounts 42903 javascript text/javascript /* jshint strict:false */ /** MediaWiki:DonationForm.js - loaded on all donation forms * TODO: lots of cleanup */ var donationForm = {}; donationForm.loadedTime = Date.now(); donationForm.extraData = { 'vw' : window.innerWidth, 'vh' : window.innerHeight }; donationForm.country = mw.util.getParamValue('country').toUpperCase(); 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 ); // Don't offer recurring at all in these countries donationForm.noRecurringCountries = [ 'AR', 'IN' ]; donationForm.noRecurringPaypalCountries = [ 'CL', 'CO', 'PE', 'UY', 'BR' ]; donationForm.currencyRates = { // From https://github.com/wikimedia/wikimedia-fundraising-SmashPig/blob/master/PaymentData/ReferenceData/CurrencyRates.php // Updated 2025-11-03 'ADF' : 5.69, 'ADP' : 144, 'AED' : 3.67, 'AFA' : 66, 'AFN' : 66, 'ALL' : 83, 'AMD' : 374, 'ANG' : 1.79, 'AOA' : 912, 'AON' : 912, 'ARS' : 1457, 'ATS' : 12, 'AUD' : 1.53, 'AWG' : 1.79, 'AZM' : 8500, 'AZN' : 1.7, 'BAM' : 1.7, 'BBD' : 2, 'BDT' : 121, 'BEF' : 35, 'BGL' : 1.7, 'BGN' : 1.7, 'BHD' : 0.37401652162054, 'BIF' : 2923, 'BMD' : 1, 'BND' : 1.3, 'BOB' : 6.76, 'BRL' : 5.37, 'BSD' : 1, 'BTN' : 89, 'BWP' : 13, 'BYR' : 34102, 'BZD' : 1.98, 'CAD' : 1.4, 'CDF' : 2224, 'CHF' : 0.80650783228772, 'CLP' : 940, 'CNY' : 7.12, 'COP' : 3853, 'CRC' : 496, 'CUC' : 1, 'CUP' : 25, 'CVE' : 96, 'CYP' : 0.50784522451156, 'CZK' : 21, 'DEM' : 1.7, 'DJF' : 178, 'DKK' : 6.48, 'DOP' : 64, 'DZD' : 130, 'ECS' : 24094, 'EEK' : 14, 'EGP' : 47, 'ESP' : 144, 'ETB' : 153, 'EUR' : 0.86770508259643, 'FIM' : 5.16, 'FJD' : 2.27, 'FKP' : 0.76116218937783, 'FRF' : 5.69, 'GBP' : 0.76116218937783, 'GEL' : 2.68, 'GHC' : 108957, 'GHS' : 11, 'GIP' : 0.76116218937783, 'GMD' : 71, 'GNF' : 8637, 'GRD' : 296, 'GTQ' : 7.55, 'GYD' : 205, 'HKD' : 7.77, 'HNL' : 26, 'HRK' : 6.54, 'HTG' : 130, 'HUF' : 336, 'IDR' : 16671, 'IEP' : 0.68337328567002, 'ILS' : 3.25, 'INR' : 89, 'IQD' : 1292, 'IRR' : 42020, 'ISK' : 126, 'ITL' : 1680, 'JMD' : 159, 'JOD' : 0.70900000000001, 'JPY' : 154, 'KES' : 128, 'KGS' : 87, 'KHR' : 3971, 'KMF' : 427, 'KPW' : 135, 'KRW' : 1429, 'KWD' : 0.30641816376358, 'KYD' : 0.83333299999999, 'KZT' : 526, 'LAK' : 21568, 'LBP' : 89680, 'LKR' : 303, 'LRD' : 182, 'LSL' : 17, 'LTL' : 3, 'LUF' : 35, 'LVL' : 0.60982660286911, 'LYD' : 5.44, 'MAD' : 9.19, 'MDL' : 17, 'MGA' : 4474, 'MGF' : 9150, 'MKD' : 53, 'MMK' : 2093, 'MNT' : 2620, 'MOP' : 8.01, 'MRO' : 395, 'MTL' : 0.37250579195865, 'MUR' : 45, 'MVR' : 15, 'MWK' : 1730, 'MXN' : 19, 'MYR' : 4.2, 'MZM' : 63200, 'MZN' : 63, 'NAD' : 17, 'NGN' : 1446, 'NIO' : 36, 'NLG' : 1.91, 'NOK' : 10, 'NPR' : 141, 'NZD' : 1.75, 'OMR' : 0.38352905117543, 'PAB' : 1, 'PEN' : 3.35, 'PGK' : 4.17, 'PHP' : 59, 'PKR' : 282, 'PLN' : 3.69, 'PTE' : 174, 'PYG' : 6991, 'QAR' : 3.6, 'ROL' : 44083, 'RON' : 4.41, 'RSD' : 101, 'RUB' : 81, 'RWF' : 1446, 'SAR' : 3.75, 'SBD' : 8.21, 'SCR' : 14, 'SDD' : 59715, 'SDG' : 597, 'SDP' : 2261, 'SEK' : 9.49, 'SGD' : 1.3, 'SHP' : 0.76116218937783, 'SIT' : 208, 'SKK' : 26, 'SLL' : 19750, 'SOS' : 550, 'SRD' : 39, 'SRG' : 38521, 'STD' : 21169, 'SVC' : 8.75, 'SYP' : 513, 'SZL' : 17, 'THB' : 32, 'TJS' : 9.15, 'TMM' : 16757, 'TMT' : 3.35, 'TND' : 2.93, 'TOP' : 2.4, 'TRL' : 42048152, 'TRY' : 42, 'TTD' : 6.69, 'TWD' : 31, 'TZS' : 2442, 'UAH' : 42, 'UGX' : 3463, 'USD' : 1, 'UYU' : 40, 'UZS' : 11982, 'VEB' : 22204414173, 'VEF' : 22204414, 'VND' : 26302, 'VUV' : 112, 'WST' : 2.71, 'XAF' : 569, 'XAG' : 0.020582109674161, 'XAU' : 0.000249595454823, 'XCD' : 2.7, 'XEU' : 0.86770508259643, 'XOF' : 569, 'XPD' : 0.00068810810716198, 'XPF' : 104, 'XPT' : 0.00063604563466001, 'YER' : 238, 'YUN' : 101, 'ZAR' : 17, '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 = donationForm.currency; $('.lp-error-smallamount').text( function( index, oldText ) { return oldText.replace( '$1', donationForm.formatAmount( donationForm.minLocal ) + '\xa0' + currency ); }); if ( currency === 'USD' ) { // we don't need to include the conversion $('.lp-error-bigamount').text( function( index, oldText ) { return oldText.replace( '($1 $2) ', '' ) .replace( '($1&nbsp;$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 adjustMinAmounts() { // Amounts spreadsheet https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 // Defining lookup table here. Using mw.loader.getScript was visibly too slow for the user (amounts flashing) const minPlusLookup = { // US - Canada - UK - EUR - Australia - New Zealand // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 USD: { amount1: { from: 2.75, to: 4.50 }, amount2: { from: 5, to: 7 }, }, GBP: { amount1: { from: 2, to: 4 }, amount2: { from: 5, to: 7 }, }, EUR: { amount1: { from: 2.50, to: 4.50 }, amount2: { from: 5, to: 7 }, }, // English Bundle // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=891721479#gid=891721479 HUF: { amount1: { from: 500, to: 750 }, }, MYR: { amount1: { from: 10, to: 20 }, amount2: { from: 30, to: 40 }, }, RON: { amount1: { from: 10, to: 30 }, }, // Other // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1865233115#gid=1865233115 CZK: { amount1: { from: 50, to: 100 }, amount2: { from: 100, to: 150 }, }, DKK: { amount1: { from: 20, to: 40 }, amount2: { from: 75, to: 80 }, }, JPY: { amount1: { from: 500, to: 1000 }, amount2: { from: 1000, to: 2000 }, amount3: { from: 2000, to: 3000 }, amount4: { from: 2500, to: 4000 }, amount5: { from: 4000, to: 5000 }, amount6: { from: 5000, to: 10000 }, amount7: { from: 10000, to: 15000 }, }, ZAR: { amount1: { from: 30, to: 50 }, amount2: { from: 50, to: 75 }, }, NOK: { amount1: { from: 30, to: 50 }, }, SEK: { amount1: { from: 30, to: 50 }, amount2: { from: 50, to: 70 }, }, ILS: { amount1: { from: 10, to: 20 }, }, PLN: { amount1: { from: 10, to: 20 }, amount2: { from: 20, to: 30 }, }, CHF: { amount1: { from: 20, to: 30 }, }, THB: { amount1: { from: 100, to: 150 }, amount2: { from: 200, to: 250 }, }, }; // CAD, AUD, NZD = USD amounts minPlusLookup.CAD = minPlusLookup.USD; minPlusLookup.AUD = minPlusLookup.USD; minPlusLookup.NZD = minPlusLookup.USD; if ( mw.util.getParamValue( 'minPlus' ) === '1' || mw.util.getParamValue( 'minPlus' ) === 'true' ) { const currencyEntry = minPlusLookup[ donationForm.currency ]; // Currency not in lookup table. No swapping. if ( !currencyEntry ) return null; const amountKeys = Object.keys( currencyEntry ); // ["amount1", "amount2"] or however many keys in lookup amountKeys.forEach( (amount, index) => { const $radio = $( `#input_amount_${index}` ); const $label = $( `label[for='input_amount_${index}` ); // If the button's amount is equal to "from" in the lookup, perform the swap. // Guards from hpc adjusted amounts as those values won't be present in the lookup. if ( currencyEntry[amount].from === parseFloat( $radio.val() ) ) { $radio.val( currencyEntry[amount].to ); $label.text( donationForm.formatCurrency( currencyEntry[amount].to ) ); } }); } } 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' 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 = donationForm.currency; // https://phabricator.wikimedia.org/T381437 var hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== currency ) { console.log('Highest previous contribution currency does not match form currency, using default amounts'); return; } // Consult this sheet for amounts: https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 var radioAmountsData = { "USD" : { // also used for CAD, AUD, NZD "default" : [ [ 0, [ 2.75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2.75, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], // Direct Mail - fixed amounts "directmail" : [ [ 0, [ 25, 35, 50, 100, 150, 250, 300 ] ] ], "directmail250" : [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ] }, "EUR" : { "default" : [ [ 0, [ 2.50, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2.50, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], }, "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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], }, "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 ] ], [ 5000, [ 5000, 10000, 15000, 20000, 35000, 50000, 100000 ] ], [ 10000, [ 10000, 25000, 50000, 75000, 100000, 150000, 200000 ] ] ], "SEK" : [ [ 0, [ 30, 50, 100, 150, 200, 300, 500 ] ], [ 50, [ 50, 100, 150, 200, 300, 500, 750 ] ], [ 200, [ 200, 300, 500, 750, 1000, 1500, 2000 ] ] ] }; 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 currencyList = [ 'USD', 'CAD', 'AUD', 'NZD', 'GBP', 'EUR' ]; // close enough for ( let i = 0; i < currencyList.length; i++ ) { // FY2425 hpcSets // Major Gifts hpcSets radioAmountsData[ currencyList[i] ].MG_2024_500 = [ [ 0, [ 500, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2024_650 = [ [ 0, [ 650, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; // FY2526 hpcSets // Direct Mail hpcSets radioAmountsData[ currencyList[i] ].DM_2526_15 = [ [ 0, [ 15, 25, 35, 50, 100, 200, 250 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2526_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2526_5000 = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; // Major Gifts hpcSets radioAmountsData[ currencyList[i] ].MG_2526_500_9999 = [ [ 0, [ 750, 850, 1000, 1250, 1500, 1750, 2000 ] ], [ 1000, [ 1500, 2000, 2500, 3000, 3750, 4500, 5000 ] ], [ 3000, [ 4000, 5000, 6000, 7000, 8000, 9000, 10000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_10K = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_250_399 = [ [ 0, [ 500, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_400_499 = [ [ 0, [ 650, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_HNWI_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_HNWI_350 = [ [ 0, [ 350, 400, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_2500 = [ [ 0, [ 2500, 3000, 5000, 7500, 10000, 15000, 25000 ] ] ]; } var appealAmountsData = { "USD" : [ // also used for CAD, AUD, NZD, GBP, EUR [ 0, [ 5, 10, 20 ] ], [ 10, [ 10, 20, 50 ] ], [ 20, [ 20, 30, 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; // Radio button amounts var radioAmounts = pickAmountArray( radioAmountsData, currency, hpc, hpcSet ); if ( radioAmounts.length ) { donationForm.setAmountOptions( radioAmounts ); } // Appeal amounts var appealAmounts = pickAmountArray( appealAmountsData, currency, hpc, hpcSet ); if ( appealAmounts.length ) { var appealAmountString = appealAmounts.map( donationForm.formatCurrency ).join( ', '); $('.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') || mw.util.getParamValue('preselect') ); if ( preSelectAmount > 0 ) { let hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== donationForm.currency ) { console.log('Highest previous contribution currency does not match form currency, not doing preselection'); return; } 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 preSelectBox() { /* Check for a 'preSelectBox' url parameter, and select that numbered option. If the value provided is invalid or doesn't exist, exit. Valid choices are 1 to 7 (8 is "Other"). If 'preSelect' exists, ignore this function. */ if(!mw.util.getParamValue('preSelect')){ // Check hpcCurrency first before running preselection. let hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== donationForm.currency ) { console.log('Highest previous contribution currency does not match form currency, not preselecting box.'); return; } // If hpc & hpcCurrency provided are okay OR hpc wasn't provided then continue. var preSelectBoxNumber = parseInt( mw.util.getParamValue('preSelectBox') ); if (preSelectBoxNumber >= 1 && preSelectBoxNumber <= 7) { var $preSelectOption = $('input[id="input_amount_' + (preSelectBoxNumber - 1) + '"]'); if ( $preSelectOption.length ) { $preSelectOption.prop('checked', true); donationForm.updateFeeDisplay(); } } } } function preSelectFrequency() { if ( donationForm.noRecurringCountries.indexOf( donationForm.country ) === -1 && 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' ); } } } 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' : 'vma', 'IT' : 'vmaj', 'LU' : 'vmaj', 'LV' : 'vma', 'NL' : 'vmaj', 'PT' : 'vmaj', 'SK' : 'vmaj', 'GR' : 'vma', // Others 'CZ' : 'vmad', 'DK' : 'vma', 'HU' : 'vma', 'IL' : 'vmad', // 'JP' : 'vmaj', - use text only as there were complaints about Diners Club not being included 'MY' : 'vmaj', 'NO' : 'vma', 'PL' : 'vma', 'RO' : 'vma', 'SE' : 'vma', 'UA' : 'vma', 'ZA' : 'vm', 'ZZ' : 'vmad' // For testing }; 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(''); } /* -- Moved from Template:2012FR/Form-section/Processing/Default -- */ /** * 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; params.country = donationForm.country; // Overrides for specific gateways if ( paymentMethod === 'cc-adyen' ) { params.payment_method = 'cc'; params.gateway = 'adyen'; } else if ( paymentMethod === 'cc-dlocal' ) { params.payment_method = 'cc'; params.gateway = 'dlocal'; } else if ( paymentMethod === 'trustly' ) { params.payment_method = 'dd'; params.payment_submethod = 'ach'; params.gateway = 'gravy'; } else if ( paymentSubMethod === 'sepadirectdebit' ) { params.payment_method = 'rtbt'; params.payment_submethod = 'sepadirectdebit'; params.gateway = 'gravy'; } else if ( paymentMethod === 'bt' && params.country === 'CZ' ) { params.payment_method = 'bt'; params.gateway = 'gravy'; } else if ( paymentSubMethod === 'vipps' ) { params.payment_method = 'ew'; params.payment_submethod = 'vipps'; params.gateway = 'gravy'; } else { params.payment_method = paymentMethod; } // dlocal let dlocalCountries = [ 'AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY', 'ZA' ], dlocalMethods = [ 'cc', 'bt', 'cash', 'cash_boleto', 'pix' ]; if ( dlocalCountries.includes( params.country ) && dlocalMethods.includes( params.payment_method ) ) { params.gateway = 'gravy'; } if ( params.payment_method === 'cc' && params.gateway === undefined ) { params.gateway = 'gravy'; } if ( params.payment_method === 'paypal' ) { params.gateway = 'gravy'; } if ( params.payment_method === 'rtbt' && paymentSubMethod === 'rtbt_ideal' ) { params.gateway = 'gravy'; } if ( params.payment_method === 'apple' || params.payment_method === 'google' ) { params.gateway = 'gravy'; } if ( paymentSubMethod ) { params.payment_submethod = paymentSubMethod; } let frequency = donationForm.getFrequency(); if ( frequency === 'monthly' ) { 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 if ( params.uselang === 'pt' && params.country === 'BR' ) { params.uselang = 'pt-br'; } if ( params.uselang === 'es' && ( params.country === 'AR' || params.country === 'CL' || params.country === 'CO' || params.country === 'MX' || params.country === 'PE' || params.country === 'UY' || params.country === 'US' ) ) { params.uselang = 'es-419'; } var amount = donationForm.getAmount(); if ( $('#ptf-checkbox').prop('checked') ) { amount = amount + donationForm.calculateFee( amount ); donationForm.extraData.ptf = 1; } params.amount = amount; // Email optin if ( $('input[name="opt_in"]').length > 0 ) { 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' ) ) { params.variant = mw.util.getParamValue( 'pym_variant' ); } if ( params.recurring && params.variant && params.variant.match( /monthlyConvert/ ) ) { // Post-payments monthly convert makes no sense if it's already recurring // Avoid things like T312905 delete params.variant; } if ( mw.util.getParamValue( 'pym_appeal' ) ) { params.appeal = mw.util.getParamValue( 'pym_appeal' ); } // Pass through specified parameters to payments unchanged const passThroughParams = [ 'contact_id', 'contact_hash', // https://phabricator.wikimedia.org/T381405 'checksum', 'contribution_recur_id', // https://phabricator.wikimedia.org/T396271 'recipient_id', // SMS 'app_install_id' // https://phabricator.wikimedia.org/T411535 ]; passThroughParams.forEach( ( param ) => { const value = mw.util.getParamValue( param ); if ( value ) { params[ param ] = value; } } ); // Monthly convert if ( mc ) { // check just in-case this wasn't loaded for some reason mc.main( params, donationForm.finalStep ); } else { donationForm.finalStep( params ); } } 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 final tracking parameters, and submit to payments * @param {Object} params */ donationForm.finalStep = function( params ) { var url = new URL('https://payments.wikimedia.org/index.php/Special:GatewayChooser'); // Skip form chooser for Venmo if ( params.payment_method === 'venmo' ) { url = new URL('https://payments.wikimedia.org/index.php/Special:GravyGateway'); } // Skip form chooser for Pix if ( params.payment_method === 'cash' && params.payment_submethod === 'pix' ) { url = new URL('https://payments.wikimedia.org/index.php/Special:GravyGateway'); } 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 * * @param {Object} params * @return {string} wmf_source */ donationForm.buildTrackingSource = function( params ) { var wmf_source = mw.util.getParamValue( 'wmf_source' ) || mw.util.getParamValue( 'utm_source' ); wmf_source += '.'; var fullDottedPaymentMethod = params.payment_method; if ( params.recurring ) { fullDottedPaymentMethod = 'r' + fullDottedPaymentMethod; } if ( params.payment_submethod ) { fullDottedPaymentMethod = fullDottedPaymentMethod + '.' + params.payment_submethod; } /* Get URL parameter, but remove parts using old format. Allow fallback to a default value */ var getParam = function( param, removeText, dflt ) { if ( mw.util.getParamValue( param ) ) { return mw.util.getParamValue( param ).replace( removeText, '' ); } else { return dflt; } }; /* The landing page info, separated by ~. This mostly exists for legacy reasons */ 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 wmf_key from extra tracking data * * @param {Object} data * @return {string} wmf_key */ donationForm.buildTrackingKey = function(data) { var existingKey = mw.util.getParamValue( 'wmf_key' ) || mw.util.getParamValue( 'utm_key' ), dataArray = []; if ( existingKey ) { dataArray.push( existingKey ); } for (var key in data) { if (data.hasOwnProperty(key)) { dataArray.push( key + '_' + data[key] ); } } return dataArray.join('~'); }; /* Return amount selected or input */ donationForm.getAmount = function() { var form = document.forms.donateForm, 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; }; /** * 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 ) { 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.forms.donateForm; // Reset all errors $('.lp-haserror').removeClass('lp-haserror'); $('.lp-error').hide(); if ( !skipAmountValidation && !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(); } } return !error; }; /** * Check if selected amount is valid i.e. a positive number, between minimum and maximum. * If not, show an error and return false. */ donationForm.validateAmount = function() { var amount = donationForm.getAmount(); if ( amount === null || isNaN(amount) || amount <= 0 || amount < donationForm.minLocal ) { $('.amount-options').addClass('lp-haserror'); $('.lp-error-bigamount').hide(); $('.lp-error-smallamount').show().focus(); return false; } else if ( amount > donationForm.maxLocal ) { $('.amount-options').addClass('lp-haserror'); $('.lp-error-bigamount').show().focus(); return false; } else { $('.amount-options').removeClass('lp-haserror'); $('.lp-error-smallamount, .lp-error-bigamount').hide(); return true; } }; donationForm.getFrequency = function() { return document.forms.donateForm.dataset.frequency || 'onetime'; }; donationForm.setFrequency = function( frequency ) { // TODO: add some validation to reject invalid frequency values let form = document.forms.donateForm; form.frequency.value = frequency; // change input form.dataset.frequency = frequency; if ( frequency === 'monthly' ) { donationForm.switchToMonthlyAmounts(); } else { donationForm.setAmountOptions( donationForm.originalAmounts ); } }; /* Wrapper for compatibility with old forms */ donationForm.toggleMonthly = function( monthly ) { if ( monthly ) { donationForm.setFrequency( 'monthly' ); } else { donationForm.setFrequency( 'onetime' ); } }; donationForm.updateFeeDisplay = function() { var selectedAmount = donationForm.getAmount(), feeAmount = donationForm.calculateFee( selectedAmount ), feeText; feeText = donationForm.formatCurrency( feeAmount ); $('.ptf label span').text( feeText ); if ( selectedAmount + feeAmount <= donationForm.maxLocal ) { $('.ptf').slideDown(); } }; /** * Calculate approximate transaction fee on given amount * @param {number} amount * @return {number} Rounded to 2 decimal places */ donationForm.calculateFee = function( amount ) { // Minimum fee/PTF amounts. Default is 0.35. // Updated 2019-05-21 to approx 0.35 USD equivalent var feeMinimums = { 'DKK' : 2, 'HUF' : 100, 'ILS' : 1.2, 'INR' : 4, 'JPY' : 35, 'KHR' : 1000, 'MYR' : 1, 'NOK' : 3, 'PLN' : 1.35, 'CZK' : 7.5, 'RON' : 1.5, 'SEK' : 3, 'UAH' : 10, 'ZAR' : 5, // Latin America // Updated 2025-06-10 to approx 0.35 USD equivalent 'BRL' : 2, 'ARS' : 415, 'CLP' : 325, 'COP' : 1450, 'MXN' : 6.75, 'PEN' : 1.28, 'UYU' : 14.5 }; var feeMultiplier = 0.04, feeMinimum = feeMinimums[ donationForm.currency ] || 0.35, feeAmount = amount * feeMultiplier; 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.screen.width >= 640 && country !== 'JP' ) { // T397002 // On a desktop browser, people can scan with their iphone return true; } else if ( window.ApplePaySession ) { // On mobile, check if Apple Pay is available natively if ( ApplePaySession.canMakePayments() ) { return true; } } return false; }; /** * Determine if the annual option should be shown on the donation form, and show it if so * * @returns {boolean} true if the annual option is enabled */ donationForm.initAnnualRecurring = function() { /* Before adding a language here, please check that we have annual translations in-place for: - the button here on donatewiki ([[MediaWiki:Frequency-Annual]]) - the thank you receipt email - donor relations macros - the thank you page (optional if it has no recurring-specific messaging) */ const annualLanguages = ['%%isolang%%', '%25%25ISOLANG%25%25', '%25%25isolang%25%25', 'el', 'en', 'en-ca', 'en-gb', 'en-us', 'es', 'es-419', 'fr', 'it', 'ja', 'nl', 'pt', 'pt-br'] const annualInput = document.getElementById( 'frequency_annual' ); if ( !annualInput ) { // old form without required input return false; } let annualEnabled = annualLanguages.includes( mw.config.get( 'wgPageContentLanguage' ) ); // Allow overriding with URL params if ( mw.util.getParamValue( 'form-countryspecific' ) === 'Form-countryspecific-annual' // compatibility with old method || mw.util.getParamValue( 'annual_enabled' ) === '1' ) { annualEnabled = true; } if ( mw.util.getParamValue( 'annual_enabled' ) === '0' ) { annualEnabled = false; } annualInput.parentNode.style.display = annualEnabled ? 'block' : 'none'; if ( annualEnabled ) { document.forms.donateForm.classList.add( 'annual-enabled' ); } return annualEnabled; }; /** * Change the amount options on the donation form * @param {array} newAmounts */ donationForm.setAmountOptions = function( newAmounts ) { for (var j = 0; j < newAmounts.length; j++) { var $radio = $( `#input_amount_${j}` ); var $label = $( `label[for="input_amount_${j}"]` ); $radio.val( newAmounts[j] ); $label.text( donationForm.formatCurrency( newAmounts[j] ) ); } }; /** * Get the current amount options e.g. to store original amounts before changing them * @returns {array} Array of amounts as numbers */ donationForm.getAmountOptions = function() { let amounts = []; document.querySelectorAll('input[name="amount"]').forEach( (input) => { let amount = parseFloat( input.value ); if ( !isNaN( amount ) ) { amounts.push( amount ); } } ); return amounts; }; donationForm.switchToMonthlyAmounts = function() { let currency = donationForm.currency; let hpcSet = mw.util.getParamValue('hpcSet'); let hpc = parseFloat( mw.util.getParamValue('hpc') ); let monthlyAmountsData = { "USD": { "default": [ [ 0, [ 1.50, 1.75, 2, 4, 5, 10, 15 ] ], [ 100, [ 15, 20, 25, 30, 35, 40, 80 ] ] ] } }; monthlyAmountsData.AUD = monthlyAmountsData.USD; monthlyAmountsData.CAD = monthlyAmountsData.USD; monthlyAmountsData.NZD = monthlyAmountsData.USD; let monthlyAmounts = pickAmountArray( monthlyAmountsData, currency, hpc, hpcSet ); if ( monthlyAmounts.length ) { donationForm.setAmountOptions( monthlyAmounts ); } } /* 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; } }; /* End form functions */ $(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 ) { donationForm.initAnnualRecurring(); // hide frequency options for some countries if ( donationForm.noRecurringCountries.indexOf( donationForm.country ) !== -1 ) { $('#frequency_onetime').prop('checked', true); $('.frequency-options, #cancel-monthly, #donate-recurring-smallprint').hide(); } if ( donationForm.noRecurringPaypalCountries.indexOf( donationForm.country ) !== -1 ) { $( '.paymentmethod-pp, .paymentmethod-pp-usd' ).addClass( 'not-monthly-capable' ); } // Format amounts on buttons $( '.amount-options li' ).each( function( index ) { let amount = this.querySelector( 'input' ).value; if ( amount !== 'Other' ) { this.querySelector( 'label' ).innerText = donationForm.formatCurrency( amount ); } }); addCardTypesClass( donationForm.country ); // Only show Amazon for links from Ways to give if ( mw.util.getParamValue( 'wmf_source' ) === 'Waystogive' || mw.util.getParamValue( 'wmf_source' ) === 'Ways_to_Give' ) { $('.paymentmethod-amazon').show(); } // Only show DAF for certain Major Gifts links if ( mw.util.getParamValue( 'wmf_campaign' ) === 'MG2WIR25' ) { $('.paymentmethod-daf').show(); } else { $('.paymentmethod-daf').hide(); } // Apple Pay if ( $('.paymentmethod-applepay').length > 0 ) { if ( !donationForm.shouldShowApplePay( donationForm.country ) ) { $('.paymentmethod-applepay').remove(); } } // Venmo browser check if ( $('.paymentmethod-venmo').length > 0 ) { if ( !donationForm.isVenmoSupported() || donationForm.country !== 'US' ) { $('.paymentmethod-venmo').remove(); } } // Hide Google Pay if people are coming from iOS app https://phabricator.wikimedia.org/T411504 if ( mw.util.getParamValue('wmf_campaign') === 'iOS' ) { $('.paymentmethod-google').remove(); } } // Links open in new tab $('.links-in-new-tab a').attr('target', '_blank'); // Disable logo link $('#p-logo a').attr( { href: '#', 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(); }); // If we are emailing them and they have a contact_id, then we can assume they have opted in, // unless this is a "Remind Me Later" email, or they are in a stricter country let hasContactId = mw.util.getParamValue( 'contact_id' ) !== null; let isRML = mw.util.getParamValue( 'wmf_campaign' ) && mw.util.getParamValue( 'wmf_campaign' ).includes( 'RMLEmail' ); let isStrictCountry = [ 'AT', 'IT' ].includes( donationForm.country ); if ( document.getElementById('optin-yes') && hasContactId && !isRML && !isStrictCountry ) { document.getElementById('optin-yes').checked = true; document.querySelector('.optin-options').style.display = 'none'; } donationForm.initOptin(); try { adjustHPC(); adjustMinAmounts(); // Store original amounts to switch back later if needed donationForm.originalAmounts = donationForm.getAmountOptions(); preSelectFrequency(); preSelect(); // Make sure to do this *after* other fiddling with values preSelectBox(); donationForm.localizeErrors(); } finally { $('.frb-monthly-pitch, .frb-monthly-pitch-thanks, .frb-recurring-pitch').appendTo('.frequency-options'); $('.ptf').appendTo('.amount-options'); $('.optin-options').insertAfter('.amount-options'); $('.consider-amounts').show(); $('#actual-form').show(); $('#actual-form-loading').hide(); } }); }); lec18btg3mxv6tqpenuxp4h6oa4k6gn 42904 42903 2026-07-10T18:27:47Z Pcoombe 5 42904 javascript text/javascript /* jshint strict:false */ /** MediaWiki:DonationForm.js - loaded on all donation forms * TODO: lots of cleanup */ var donationForm = {}; donationForm.loadedTime = Date.now(); donationForm.extraData = { 'vw' : window.innerWidth, 'vh' : window.innerHeight }; donationForm.country = mw.util.getParamValue('country').toUpperCase(); 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 ); // Don't offer recurring at all in these countries donationForm.noRecurringCountries = [ 'AR', 'IN' ]; donationForm.noRecurringPaypalCountries = [ 'CL', 'CO', 'PE', 'UY', 'BR' ]; donationForm.currencyRates = { // From https://github.com/wikimedia/wikimedia-fundraising-SmashPig/blob/master/PaymentData/ReferenceData/CurrencyRates.php // Updated 2025-11-03 'ADF' : 5.69, 'ADP' : 144, 'AED' : 3.67, 'AFA' : 66, 'AFN' : 66, 'ALL' : 83, 'AMD' : 374, 'ANG' : 1.79, 'AOA' : 912, 'AON' : 912, 'ARS' : 1457, 'ATS' : 12, 'AUD' : 1.53, 'AWG' : 1.79, 'AZM' : 8500, 'AZN' : 1.7, 'BAM' : 1.7, 'BBD' : 2, 'BDT' : 121, 'BEF' : 35, 'BGL' : 1.7, 'BGN' : 1.7, 'BHD' : 0.37401652162054, 'BIF' : 2923, 'BMD' : 1, 'BND' : 1.3, 'BOB' : 6.76, 'BRL' : 5.37, 'BSD' : 1, 'BTN' : 89, 'BWP' : 13, 'BYR' : 34102, 'BZD' : 1.98, 'CAD' : 1.4, 'CDF' : 2224, 'CHF' : 0.80650783228772, 'CLP' : 940, 'CNY' : 7.12, 'COP' : 3853, 'CRC' : 496, 'CUC' : 1, 'CUP' : 25, 'CVE' : 96, 'CYP' : 0.50784522451156, 'CZK' : 21, 'DEM' : 1.7, 'DJF' : 178, 'DKK' : 6.48, 'DOP' : 64, 'DZD' : 130, 'ECS' : 24094, 'EEK' : 14, 'EGP' : 47, 'ESP' : 144, 'ETB' : 153, 'EUR' : 0.86770508259643, 'FIM' : 5.16, 'FJD' : 2.27, 'FKP' : 0.76116218937783, 'FRF' : 5.69, 'GBP' : 0.76116218937783, 'GEL' : 2.68, 'GHC' : 108957, 'GHS' : 11, 'GIP' : 0.76116218937783, 'GMD' : 71, 'GNF' : 8637, 'GRD' : 296, 'GTQ' : 7.55, 'GYD' : 205, 'HKD' : 7.77, 'HNL' : 26, 'HRK' : 6.54, 'HTG' : 130, 'HUF' : 336, 'IDR' : 16671, 'IEP' : 0.68337328567002, 'ILS' : 3.25, 'INR' : 89, 'IQD' : 1292, 'IRR' : 42020, 'ISK' : 126, 'ITL' : 1680, 'JMD' : 159, 'JOD' : 0.70900000000001, 'JPY' : 154, 'KES' : 128, 'KGS' : 87, 'KHR' : 3971, 'KMF' : 427, 'KPW' : 135, 'KRW' : 1429, 'KWD' : 0.30641816376358, 'KYD' : 0.83333299999999, 'KZT' : 526, 'LAK' : 21568, 'LBP' : 89680, 'LKR' : 303, 'LRD' : 182, 'LSL' : 17, 'LTL' : 3, 'LUF' : 35, 'LVL' : 0.60982660286911, 'LYD' : 5.44, 'MAD' : 9.19, 'MDL' : 17, 'MGA' : 4474, 'MGF' : 9150, 'MKD' : 53, 'MMK' : 2093, 'MNT' : 2620, 'MOP' : 8.01, 'MRO' : 395, 'MTL' : 0.37250579195865, 'MUR' : 45, 'MVR' : 15, 'MWK' : 1730, 'MXN' : 19, 'MYR' : 4.2, 'MZM' : 63200, 'MZN' : 63, 'NAD' : 17, 'NGN' : 1446, 'NIO' : 36, 'NLG' : 1.91, 'NOK' : 10, 'NPR' : 141, 'NZD' : 1.75, 'OMR' : 0.38352905117543, 'PAB' : 1, 'PEN' : 3.35, 'PGK' : 4.17, 'PHP' : 59, 'PKR' : 282, 'PLN' : 3.69, 'PTE' : 174, 'PYG' : 6991, 'QAR' : 3.6, 'ROL' : 44083, 'RON' : 4.41, 'RSD' : 101, 'RUB' : 81, 'RWF' : 1446, 'SAR' : 3.75, 'SBD' : 8.21, 'SCR' : 14, 'SDD' : 59715, 'SDG' : 597, 'SDP' : 2261, 'SEK' : 9.49, 'SGD' : 1.3, 'SHP' : 0.76116218937783, 'SIT' : 208, 'SKK' : 26, 'SLL' : 19750, 'SOS' : 550, 'SRD' : 39, 'SRG' : 38521, 'STD' : 21169, 'SVC' : 8.75, 'SYP' : 513, 'SZL' : 17, 'THB' : 32, 'TJS' : 9.15, 'TMM' : 16757, 'TMT' : 3.35, 'TND' : 2.93, 'TOP' : 2.4, 'TRL' : 42048152, 'TRY' : 42, 'TTD' : 6.69, 'TWD' : 31, 'TZS' : 2442, 'UAH' : 42, 'UGX' : 3463, 'USD' : 1, 'UYU' : 40, 'UZS' : 11982, 'VEB' : 22204414173, 'VEF' : 22204414, 'VND' : 26302, 'VUV' : 112, 'WST' : 2.71, 'XAF' : 569, 'XAG' : 0.020582109674161, 'XAU' : 0.000249595454823, 'XCD' : 2.7, 'XEU' : 0.86770508259643, 'XOF' : 569, 'XPD' : 0.00068810810716198, 'XPF' : 104, 'XPT' : 0.00063604563466001, 'YER' : 238, 'YUN' : 101, 'ZAR' : 17, '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 = donationForm.currency; $('.lp-error-smallamount').text( function( index, oldText ) { return oldText.replace( '$1', donationForm.formatAmount( donationForm.minLocal ) + '\xa0' + currency ); }); if ( currency === 'USD' ) { // we don't need to include the conversion $('.lp-error-bigamount').text( function( index, oldText ) { return oldText.replace( '($1 $2) ', '' ) .replace( '($1&nbsp;$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 adjustMinAmounts() { // Amounts spreadsheet https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 // Defining lookup table here. Using mw.loader.getScript was visibly too slow for the user (amounts flashing) const minPlusLookup = { // US - Canada - UK - EUR - Australia - New Zealand // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 USD: { amount1: { from: 2.75, to: 4.50 }, amount2: { from: 5, to: 7 }, }, GBP: { amount1: { from: 2, to: 4 }, amount2: { from: 5, to: 7 }, }, EUR: { amount1: { from: 2.50, to: 4.50 }, amount2: { from: 5, to: 7 }, }, // English Bundle // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=891721479#gid=891721479 HUF: { amount1: { from: 500, to: 750 }, }, MYR: { amount1: { from: 10, to: 20 }, amount2: { from: 30, to: 40 }, }, RON: { amount1: { from: 10, to: 30 }, }, // Other // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1865233115#gid=1865233115 CZK: { amount1: { from: 50, to: 100 }, amount2: { from: 100, to: 150 }, }, DKK: { amount1: { from: 20, to: 40 }, amount2: { from: 75, to: 80 }, }, JPY: { amount1: { from: 500, to: 1000 }, amount2: { from: 1000, to: 2000 }, amount3: { from: 2000, to: 3000 }, amount4: { from: 2500, to: 4000 }, amount5: { from: 4000, to: 5000 }, amount6: { from: 5000, to: 10000 }, amount7: { from: 10000, to: 15000 }, }, ZAR: { amount1: { from: 30, to: 50 }, amount2: { from: 50, to: 75 }, }, NOK: { amount1: { from: 30, to: 50 }, }, SEK: { amount1: { from: 30, to: 50 }, amount2: { from: 50, to: 70 }, }, ILS: { amount1: { from: 10, to: 20 }, }, PLN: { amount1: { from: 10, to: 20 }, amount2: { from: 20, to: 30 }, }, CHF: { amount1: { from: 20, to: 30 }, }, THB: { amount1: { from: 100, to: 150 }, amount2: { from: 200, to: 250 }, }, }; // CAD, AUD, NZD = USD amounts minPlusLookup.CAD = minPlusLookup.USD; minPlusLookup.AUD = minPlusLookup.USD; minPlusLookup.NZD = minPlusLookup.USD; if ( mw.util.getParamValue( 'minPlus' ) === '1' || mw.util.getParamValue( 'minPlus' ) === 'true' ) { const currencyEntry = minPlusLookup[ donationForm.currency ]; // Currency not in lookup table. No swapping. if ( !currencyEntry ) return null; const amountKeys = Object.keys( currencyEntry ); // ["amount1", "amount2"] or however many keys in lookup amountKeys.forEach( (amount, index) => { const $radio = $( `#input_amount_${index}` ); const $label = $( `label[for='input_amount_${index}` ); // If the button's amount is equal to "from" in the lookup, perform the swap. // Guards from hpc adjusted amounts as those values won't be present in the lookup. if ( currencyEntry[amount].from === parseFloat( $radio.val() ) ) { $radio.val( currencyEntry[amount].to ); $label.text( donationForm.formatCurrency( currencyEntry[amount].to ) ); } }); } } 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' 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 = donationForm.currency; // https://phabricator.wikimedia.org/T381437 var hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== currency ) { console.log('Highest previous contribution currency does not match form currency, using default amounts'); return; } // Consult this sheet for amounts: https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 var radioAmountsData = { "USD" : { // also used for CAD, AUD, NZD "default" : [ [ 0, [ 2.75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2.75, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], // Direct Mail - fixed amounts "directmail" : [ [ 0, [ 25, 35, 50, 100, 150, 250, 300 ] ] ], "directmail250" : [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ] }, "EUR" : { "default" : [ [ 0, [ 2.50, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2.50, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], }, "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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], }, "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 ] ], [ 5000, [ 5000, 10000, 15000, 20000, 35000, 50000, 100000 ] ], [ 10000, [ 10000, 25000, 50000, 75000, 100000, 150000, 200000 ] ] ], "SEK" : [ [ 0, [ 30, 50, 100, 150, 200, 300, 500 ] ], [ 50, [ 50, 100, 150, 200, 300, 500, 750 ] ], [ 200, [ 200, 300, 500, 750, 1000, 1500, 2000 ] ] ] }; 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 currencyList = [ 'USD', 'CAD', 'AUD', 'NZD', 'GBP', 'EUR' ]; // close enough for ( let i = 0; i < currencyList.length; i++ ) { // FY2425 hpcSets // Major Gifts hpcSets radioAmountsData[ currencyList[i] ].MG_2024_500 = [ [ 0, [ 500, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2024_650 = [ [ 0, [ 650, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; // FY2526 hpcSets // Direct Mail hpcSets radioAmountsData[ currencyList[i] ].DM_2526_15 = [ [ 0, [ 15, 25, 35, 50, 100, 200, 250 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2526_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2526_5000 = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; // Major Gifts hpcSets radioAmountsData[ currencyList[i] ].MG_2526_500_9999 = [ [ 0, [ 750, 850, 1000, 1250, 1500, 1750, 2000 ] ], [ 1000, [ 1500, 2000, 2500, 3000, 3750, 4500, 5000 ] ], [ 3000, [ 4000, 5000, 6000, 7000, 8000, 9000, 10000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_10K = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_250_399 = [ [ 0, [ 500, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_400_499 = [ [ 0, [ 650, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_HNWI_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_HNWI_350 = [ [ 0, [ 350, 400, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_2500 = [ [ 0, [ 2500, 3000, 5000, 7500, 10000, 15000, 25000 ] ] ]; } var appealAmountsData = { "USD" : [ // also used for CAD, AUD, NZD, GBP, EUR [ 0, [ 5, 10, 20 ] ], [ 10, [ 10, 20, 50 ] ], [ 20, [ 20, 30, 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; // Radio button amounts var radioAmounts = pickAmountArray( radioAmountsData, currency, hpc, hpcSet ); if ( radioAmounts.length ) { donationForm.setAmountOptions( radioAmounts ); } // Appeal amounts var appealAmounts = pickAmountArray( appealAmountsData, currency, hpc, hpcSet ); if ( appealAmounts.length ) { var appealAmountString = appealAmounts.map( donationForm.formatCurrency ).join( ', '); $('.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') || mw.util.getParamValue('preselect') ); if ( preSelectAmount > 0 ) { let hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== donationForm.currency ) { console.log('Highest previous contribution currency does not match form currency, not doing preselection'); return; } 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 preSelectBox() { /* Check for a 'preSelectBox' url parameter, and select that numbered option. If the value provided is invalid or doesn't exist, exit. Valid choices are 1 to 7 (8 is "Other"). If 'preSelect' exists, ignore this function. */ if(!mw.util.getParamValue('preSelect')){ // Check hpcCurrency first before running preselection. let hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== donationForm.currency ) { console.log('Highest previous contribution currency does not match form currency, not preselecting box.'); return; } // If hpc & hpcCurrency provided are okay OR hpc wasn't provided then continue. var preSelectBoxNumber = parseInt( mw.util.getParamValue('preSelectBox') ); if (preSelectBoxNumber >= 1 && preSelectBoxNumber <= 7) { var $preSelectOption = $('input[id="input_amount_' + (preSelectBoxNumber - 1) + '"]'); if ( $preSelectOption.length ) { $preSelectOption.prop('checked', true); donationForm.updateFeeDisplay(); } } } } function preSelectFrequency() { if ( donationForm.noRecurringCountries.indexOf( donationForm.country ) === -1 && 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' ); } } } 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' : 'vma', 'IT' : 'vmaj', 'LU' : 'vmaj', 'LV' : 'vma', 'NL' : 'vmaj', 'PT' : 'vmaj', 'SK' : 'vmaj', 'GR' : 'vma', // Others 'CZ' : 'vmad', 'DK' : 'vma', 'HU' : 'vma', 'IL' : 'vmad', // 'JP' : 'vmaj', - use text only as there were complaints about Diners Club not being included 'MY' : 'vmaj', 'NO' : 'vma', 'PL' : 'vma', 'RO' : 'vma', 'SE' : 'vma', 'UA' : 'vma', 'ZA' : 'vm', 'ZZ' : 'vmad' // For testing }; 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(''); } /* -- Moved from Template:2012FR/Form-section/Processing/Default -- */ /** * 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; params.country = donationForm.country; // Overrides for specific gateways if ( paymentMethod === 'cc-adyen' ) { params.payment_method = 'cc'; params.gateway = 'adyen'; } else if ( paymentMethod === 'cc-dlocal' ) { params.payment_method = 'cc'; params.gateway = 'dlocal'; } else if ( paymentMethod === 'trustly' ) { params.payment_method = 'dd'; params.payment_submethod = 'ach'; params.gateway = 'gravy'; } else if ( paymentSubMethod === 'sepadirectdebit' ) { params.payment_method = 'rtbt'; params.payment_submethod = 'sepadirectdebit'; params.gateway = 'gravy'; } else if ( paymentMethod === 'bt' && params.country === 'CZ' ) { params.payment_method = 'bt'; params.gateway = 'gravy'; } else if ( paymentSubMethod === 'vipps' ) { params.payment_method = 'ew'; params.payment_submethod = 'vipps'; params.gateway = 'gravy'; } else { params.payment_method = paymentMethod; } // dlocal let dlocalCountries = [ 'AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY', 'ZA' ], dlocalMethods = [ 'cc', 'bt', 'cash', 'cash_boleto', 'pix' ]; if ( dlocalCountries.includes( params.country ) && dlocalMethods.includes( params.payment_method ) ) { params.gateway = 'gravy'; } if ( params.payment_method === 'cc' && params.gateway === undefined ) { params.gateway = 'gravy'; } if ( params.payment_method === 'paypal' ) { params.gateway = 'gravy'; } if ( params.payment_method === 'rtbt' && paymentSubMethod === 'rtbt_ideal' ) { params.gateway = 'gravy'; } if ( params.payment_method === 'apple' || params.payment_method === 'google' ) { params.gateway = 'gravy'; } if ( paymentSubMethod ) { params.payment_submethod = paymentSubMethod; } let frequency = donationForm.getFrequency(); if ( frequency === 'monthly' ) { 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 if ( params.uselang === 'pt' && params.country === 'BR' ) { params.uselang = 'pt-br'; } if ( params.uselang === 'es' && ( params.country === 'AR' || params.country === 'CL' || params.country === 'CO' || params.country === 'MX' || params.country === 'PE' || params.country === 'UY' || params.country === 'US' ) ) { params.uselang = 'es-419'; } var amount = donationForm.getAmount(); if ( $('#ptf-checkbox').prop('checked') ) { amount = amount + donationForm.calculateFee( amount ); donationForm.extraData.ptf = 1; } params.amount = amount; // Email optin if ( $('input[name="opt_in"]').length > 0 ) { 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' ) ) { params.variant = mw.util.getParamValue( 'pym_variant' ); } if ( params.recurring && params.variant && params.variant.match( /monthlyConvert/ ) ) { // Post-payments monthly convert makes no sense if it's already recurring // Avoid things like T312905 delete params.variant; } if ( mw.util.getParamValue( 'pym_appeal' ) ) { params.appeal = mw.util.getParamValue( 'pym_appeal' ); } // Pass through specified parameters to payments unchanged const passThroughParams = [ 'contact_id', 'contact_hash', // https://phabricator.wikimedia.org/T381405 'checksum', 'contribution_recur_id', // https://phabricator.wikimedia.org/T396271 'recipient_id', // SMS 'app_install_id' // https://phabricator.wikimedia.org/T411535 ]; passThroughParams.forEach( ( param ) => { const value = mw.util.getParamValue( param ); if ( value ) { params[ param ] = value; } } ); // Monthly convert if ( mc ) { // check just in-case this wasn't loaded for some reason mc.main( params, donationForm.finalStep ); } else { donationForm.finalStep( params ); } } 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 final tracking parameters, and submit to payments * @param {Object} params */ donationForm.finalStep = function( params ) { var url = new URL('https://payments.wikimedia.org/index.php/Special:GatewayChooser'); // Skip form chooser for Venmo if ( params.payment_method === 'venmo' ) { url = new URL('https://payments.wikimedia.org/index.php/Special:GravyGateway'); } // Skip form chooser for Pix if ( params.payment_method === 'cash' && params.payment_submethod === 'pix' ) { url = new URL('https://payments.wikimedia.org/index.php/Special:GravyGateway'); } 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 * * @param {Object} params * @return {string} wmf_source */ donationForm.buildTrackingSource = function( params ) { var wmf_source = mw.util.getParamValue( 'wmf_source' ) || mw.util.getParamValue( 'utm_source' ); wmf_source += '.'; var fullDottedPaymentMethod = params.payment_method; if ( params.recurring ) { fullDottedPaymentMethod = 'r' + fullDottedPaymentMethod; } if ( params.payment_submethod ) { fullDottedPaymentMethod = fullDottedPaymentMethod + '.' + params.payment_submethod; } /* Get URL parameter, but remove parts using old format. Allow fallback to a default value */ var getParam = function( param, removeText, dflt ) { if ( mw.util.getParamValue( param ) ) { return mw.util.getParamValue( param ).replace( removeText, '' ); } else { return dflt; } }; /* The landing page info, separated by ~. This mostly exists for legacy reasons */ 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 wmf_key from extra tracking data * * @param {Object} data * @return {string} wmf_key */ donationForm.buildTrackingKey = function(data) { var existingKey = mw.util.getParamValue( 'wmf_key' ) || mw.util.getParamValue( 'utm_key' ), dataArray = []; if ( existingKey ) { dataArray.push( existingKey ); } for (var key in data) { if (data.hasOwnProperty(key)) { dataArray.push( key + '_' + data[key] ); } } return dataArray.join('~'); }; /* Return amount selected or input */ donationForm.getAmount = function() { var form = document.forms.donateForm, 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; }; /** * 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 ) { 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.forms.donateForm; // Reset all errors $('.lp-haserror').removeClass('lp-haserror'); $('.lp-error').hide(); if ( !skipAmountValidation && !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(); } } return !error; }; /** * Check if selected amount is valid i.e. a positive number, between minimum and maximum. * If not, show an error and return false. */ donationForm.validateAmount = function() { var amount = donationForm.getAmount(); if ( amount === null || isNaN(amount) || amount <= 0 || amount < donationForm.minLocal ) { $('.amount-options').addClass('lp-haserror'); $('.lp-error-bigamount').hide(); $('.lp-error-smallamount').show().focus(); return false; } else if ( amount > donationForm.maxLocal ) { $('.amount-options').addClass('lp-haserror'); $('.lp-error-bigamount').show().focus(); return false; } else { $('.amount-options').removeClass('lp-haserror'); $('.lp-error-smallamount, .lp-error-bigamount').hide(); return true; } }; donationForm.getFrequency = function() { return document.forms.donateForm.dataset.frequency || 'onetime'; }; donationForm.setFrequency = function( frequency ) { // TODO: add some validation to reject invalid frequency values let form = document.forms.donateForm; form.frequency.value = frequency; // change input form.dataset.frequency = frequency; if ( frequency === 'monthly' ) { donationForm.switchToMonthlyAmounts(); } else { donationForm.setAmountOptions( donationForm.originalAmounts ); } }; /* Wrapper for compatibility with old forms */ donationForm.toggleMonthly = function( monthly ) { if ( monthly ) { donationForm.setFrequency( 'monthly' ); } else { donationForm.setFrequency( 'onetime' ); } }; donationForm.updateFeeDisplay = function() { var selectedAmount = donationForm.getAmount(), feeAmount = donationForm.calculateFee( selectedAmount ), feeText; feeText = donationForm.formatCurrency( feeAmount ); $('.ptf label span').text( feeText ); if ( selectedAmount + feeAmount <= donationForm.maxLocal ) { $('.ptf').slideDown(); } }; /** * Calculate approximate transaction fee on given amount * @param {number} amount * @return {number} Rounded to 2 decimal places */ donationForm.calculateFee = function( amount ) { // Minimum fee/PTF amounts. Default is 0.35. // Updated 2019-05-21 to approx 0.35 USD equivalent var feeMinimums = { 'DKK' : 2, 'HUF' : 100, 'ILS' : 1.2, 'INR' : 4, 'JPY' : 35, 'KHR' : 1000, 'MYR' : 1, 'NOK' : 3, 'PLN' : 1.35, 'CZK' : 7.5, 'RON' : 1.5, 'SEK' : 3, 'UAH' : 10, 'ZAR' : 5, // Latin America // Updated 2025-06-10 to approx 0.35 USD equivalent 'BRL' : 2, 'ARS' : 415, 'CLP' : 325, 'COP' : 1450, 'MXN' : 6.75, 'PEN' : 1.28, 'UYU' : 14.5 }; var feeMultiplier = 0.04, feeMinimum = feeMinimums[ donationForm.currency ] || 0.35, feeAmount = amount * feeMultiplier; 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.screen.width >= 640 && country !== 'JP' ) { // T397002 // On a desktop browser, people can scan with their iphone return true; } else if ( window.ApplePaySession ) { // On mobile, check if Apple Pay is available natively if ( ApplePaySession.canMakePayments() ) { return true; } } return false; }; /** * Determine if the annual option should be shown on the donation form, and show it if so * * @returns {boolean} true if the annual option is enabled */ donationForm.initAnnualRecurring = function() { /* Before adding a language here, please check that we have annual translations in-place for: - the button here on donatewiki ([[MediaWiki:Frequency-Annual]]) - the thank you receipt email - donor relations macros - the thank you page (optional if it has no recurring-specific messaging) */ const annualLanguages = ['%%isolang%%', '%25%25ISOLANG%25%25', '%25%25isolang%25%25', 'el', 'en', 'en-ca', 'en-gb', 'en-us', 'es', 'es-419', 'fr', 'it', 'ja', 'nl', 'pt', 'pt-br'] const annualInput = document.getElementById( 'frequency_annual' ); if ( !annualInput ) { // old form without required input return false; } let annualEnabled = annualLanguages.includes( mw.config.get( 'wgPageContentLanguage' ) ); // Allow overriding with URL params if ( mw.util.getParamValue( 'form-countryspecific' ) === 'Form-countryspecific-annual' // compatibility with old method || mw.util.getParamValue( 'annual_enabled' ) === '1' ) { annualEnabled = true; } if ( mw.util.getParamValue( 'annual_enabled' ) === '0' ) { annualEnabled = false; } annualInput.parentNode.style.display = annualEnabled ? 'block' : 'none'; if ( annualEnabled ) { document.forms.donateForm.classList.add( 'annual-enabled' ); } return annualEnabled; }; /** * Change the amount options on the donation form * @param {array} newAmounts */ donationForm.setAmountOptions = function( newAmounts ) { for (var j = 0; j < newAmounts.length; j++) { var $radio = $( `#input_amount_${j}` ); var $label = $( `label[for="input_amount_${j}"]` ); $radio.val( newAmounts[j] ); $label.text( donationForm.formatCurrency( newAmounts[j] ) ); } }; /** * Get the current amount options e.g. to store original amounts before changing them * @returns {array} Array of amounts as numbers */ donationForm.getAmountOptions = function() { let amounts = []; document.querySelectorAll('input[name="amount"]').forEach( (input) => { let amount = parseFloat( input.value ); if ( !isNaN( amount ) ) { amounts.push( amount ); } } ); return amounts; }; donationForm.switchToMonthlyAmounts = function() { let currency = donationForm.currency; let hpcSet = mw.util.getParamValue('hpcSet'); let hpc = parseFloat( mw.util.getParamValue('hpc') ); if( isNaN(hpc) ) { hpc = parseFloat( mw.util.getParamValue('mrc') ); if( isNaN(hpc) ) { return; } } let monthlyAmountsData = { "USD": { "default": [ [ 0, [ 1.50, 1.75, 2, 4, 5, 10, 15 ] ], [ 100, [ 15, 20, 25, 30, 35, 40, 80 ] ] ] } }; monthlyAmountsData.AUD = monthlyAmountsData.USD; monthlyAmountsData.CAD = monthlyAmountsData.USD; monthlyAmountsData.NZD = monthlyAmountsData.USD; let monthlyAmounts = pickAmountArray( monthlyAmountsData, currency, hpc, hpcSet ); if ( monthlyAmounts.length ) { donationForm.setAmountOptions( monthlyAmounts ); } } /* 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; } }; /* End form functions */ $(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 ) { donationForm.initAnnualRecurring(); // hide frequency options for some countries if ( donationForm.noRecurringCountries.indexOf( donationForm.country ) !== -1 ) { $('#frequency_onetime').prop('checked', true); $('.frequency-options, #cancel-monthly, #donate-recurring-smallprint').hide(); } if ( donationForm.noRecurringPaypalCountries.indexOf( donationForm.country ) !== -1 ) { $( '.paymentmethod-pp, .paymentmethod-pp-usd' ).addClass( 'not-monthly-capable' ); } // Format amounts on buttons $( '.amount-options li' ).each( function( index ) { let amount = this.querySelector( 'input' ).value; if ( amount !== 'Other' ) { this.querySelector( 'label' ).innerText = donationForm.formatCurrency( amount ); } }); addCardTypesClass( donationForm.country ); // Only show Amazon for links from Ways to give if ( mw.util.getParamValue( 'wmf_source' ) === 'Waystogive' || mw.util.getParamValue( 'wmf_source' ) === 'Ways_to_Give' ) { $('.paymentmethod-amazon').show(); } // Only show DAF for certain Major Gifts links if ( mw.util.getParamValue( 'wmf_campaign' ) === 'MG2WIR25' ) { $('.paymentmethod-daf').show(); } else { $('.paymentmethod-daf').hide(); } // Apple Pay if ( $('.paymentmethod-applepay').length > 0 ) { if ( !donationForm.shouldShowApplePay( donationForm.country ) ) { $('.paymentmethod-applepay').remove(); } } // Venmo browser check if ( $('.paymentmethod-venmo').length > 0 ) { if ( !donationForm.isVenmoSupported() || donationForm.country !== 'US' ) { $('.paymentmethod-venmo').remove(); } } // Hide Google Pay if people are coming from iOS app https://phabricator.wikimedia.org/T411504 if ( mw.util.getParamValue('wmf_campaign') === 'iOS' ) { $('.paymentmethod-google').remove(); } } // Links open in new tab $('.links-in-new-tab a').attr('target', '_blank'); // Disable logo link $('#p-logo a').attr( { href: '#', 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(); }); // If we are emailing them and they have a contact_id, then we can assume they have opted in, // unless this is a "Remind Me Later" email, or they are in a stricter country let hasContactId = mw.util.getParamValue( 'contact_id' ) !== null; let isRML = mw.util.getParamValue( 'wmf_campaign' ) && mw.util.getParamValue( 'wmf_campaign' ).includes( 'RMLEmail' ); let isStrictCountry = [ 'AT', 'IT' ].includes( donationForm.country ); if ( document.getElementById('optin-yes') && hasContactId && !isRML && !isStrictCountry ) { document.getElementById('optin-yes').checked = true; document.querySelector('.optin-options').style.display = 'none'; } donationForm.initOptin(); try { adjustHPC(); adjustMinAmounts(); // Store original amounts to switch back later if needed donationForm.originalAmounts = donationForm.getAmountOptions(); preSelectFrequency(); preSelect(); // Make sure to do this *after* other fiddling with values preSelectBox(); donationForm.localizeErrors(); } finally { $('.frb-monthly-pitch, .frb-monthly-pitch-thanks, .frb-recurring-pitch').appendTo('.frequency-options'); $('.ptf').appendTo('.amount-options'); $('.optin-options').insertAfter('.amount-options'); $('.consider-amounts').show(); $('#actual-form').show(); $('#actual-form-loading').hide(); } }); }); gcf7bx214j03sdsfpakin27aa230bqn 42905 42904 2026-07-10T18:28:34Z Pcoombe 5 42905 javascript text/javascript /* jshint strict:false */ /** MediaWiki:DonationForm.js - loaded on all donation forms * TODO: lots of cleanup */ var donationForm = {}; donationForm.loadedTime = Date.now(); donationForm.extraData = { 'vw' : window.innerWidth, 'vh' : window.innerHeight }; donationForm.country = mw.util.getParamValue('country').toUpperCase(); 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 ); // Don't offer recurring at all in these countries donationForm.noRecurringCountries = [ 'AR', 'IN' ]; donationForm.noRecurringPaypalCountries = [ 'CL', 'CO', 'PE', 'UY', 'BR' ]; donationForm.currencyRates = { // From https://github.com/wikimedia/wikimedia-fundraising-SmashPig/blob/master/PaymentData/ReferenceData/CurrencyRates.php // Updated 2025-11-03 'ADF' : 5.69, 'ADP' : 144, 'AED' : 3.67, 'AFA' : 66, 'AFN' : 66, 'ALL' : 83, 'AMD' : 374, 'ANG' : 1.79, 'AOA' : 912, 'AON' : 912, 'ARS' : 1457, 'ATS' : 12, 'AUD' : 1.53, 'AWG' : 1.79, 'AZM' : 8500, 'AZN' : 1.7, 'BAM' : 1.7, 'BBD' : 2, 'BDT' : 121, 'BEF' : 35, 'BGL' : 1.7, 'BGN' : 1.7, 'BHD' : 0.37401652162054, 'BIF' : 2923, 'BMD' : 1, 'BND' : 1.3, 'BOB' : 6.76, 'BRL' : 5.37, 'BSD' : 1, 'BTN' : 89, 'BWP' : 13, 'BYR' : 34102, 'BZD' : 1.98, 'CAD' : 1.4, 'CDF' : 2224, 'CHF' : 0.80650783228772, 'CLP' : 940, 'CNY' : 7.12, 'COP' : 3853, 'CRC' : 496, 'CUC' : 1, 'CUP' : 25, 'CVE' : 96, 'CYP' : 0.50784522451156, 'CZK' : 21, 'DEM' : 1.7, 'DJF' : 178, 'DKK' : 6.48, 'DOP' : 64, 'DZD' : 130, 'ECS' : 24094, 'EEK' : 14, 'EGP' : 47, 'ESP' : 144, 'ETB' : 153, 'EUR' : 0.86770508259643, 'FIM' : 5.16, 'FJD' : 2.27, 'FKP' : 0.76116218937783, 'FRF' : 5.69, 'GBP' : 0.76116218937783, 'GEL' : 2.68, 'GHC' : 108957, 'GHS' : 11, 'GIP' : 0.76116218937783, 'GMD' : 71, 'GNF' : 8637, 'GRD' : 296, 'GTQ' : 7.55, 'GYD' : 205, 'HKD' : 7.77, 'HNL' : 26, 'HRK' : 6.54, 'HTG' : 130, 'HUF' : 336, 'IDR' : 16671, 'IEP' : 0.68337328567002, 'ILS' : 3.25, 'INR' : 89, 'IQD' : 1292, 'IRR' : 42020, 'ISK' : 126, 'ITL' : 1680, 'JMD' : 159, 'JOD' : 0.70900000000001, 'JPY' : 154, 'KES' : 128, 'KGS' : 87, 'KHR' : 3971, 'KMF' : 427, 'KPW' : 135, 'KRW' : 1429, 'KWD' : 0.30641816376358, 'KYD' : 0.83333299999999, 'KZT' : 526, 'LAK' : 21568, 'LBP' : 89680, 'LKR' : 303, 'LRD' : 182, 'LSL' : 17, 'LTL' : 3, 'LUF' : 35, 'LVL' : 0.60982660286911, 'LYD' : 5.44, 'MAD' : 9.19, 'MDL' : 17, 'MGA' : 4474, 'MGF' : 9150, 'MKD' : 53, 'MMK' : 2093, 'MNT' : 2620, 'MOP' : 8.01, 'MRO' : 395, 'MTL' : 0.37250579195865, 'MUR' : 45, 'MVR' : 15, 'MWK' : 1730, 'MXN' : 19, 'MYR' : 4.2, 'MZM' : 63200, 'MZN' : 63, 'NAD' : 17, 'NGN' : 1446, 'NIO' : 36, 'NLG' : 1.91, 'NOK' : 10, 'NPR' : 141, 'NZD' : 1.75, 'OMR' : 0.38352905117543, 'PAB' : 1, 'PEN' : 3.35, 'PGK' : 4.17, 'PHP' : 59, 'PKR' : 282, 'PLN' : 3.69, 'PTE' : 174, 'PYG' : 6991, 'QAR' : 3.6, 'ROL' : 44083, 'RON' : 4.41, 'RSD' : 101, 'RUB' : 81, 'RWF' : 1446, 'SAR' : 3.75, 'SBD' : 8.21, 'SCR' : 14, 'SDD' : 59715, 'SDG' : 597, 'SDP' : 2261, 'SEK' : 9.49, 'SGD' : 1.3, 'SHP' : 0.76116218937783, 'SIT' : 208, 'SKK' : 26, 'SLL' : 19750, 'SOS' : 550, 'SRD' : 39, 'SRG' : 38521, 'STD' : 21169, 'SVC' : 8.75, 'SYP' : 513, 'SZL' : 17, 'THB' : 32, 'TJS' : 9.15, 'TMM' : 16757, 'TMT' : 3.35, 'TND' : 2.93, 'TOP' : 2.4, 'TRL' : 42048152, 'TRY' : 42, 'TTD' : 6.69, 'TWD' : 31, 'TZS' : 2442, 'UAH' : 42, 'UGX' : 3463, 'USD' : 1, 'UYU' : 40, 'UZS' : 11982, 'VEB' : 22204414173, 'VEF' : 22204414, 'VND' : 26302, 'VUV' : 112, 'WST' : 2.71, 'XAF' : 569, 'XAG' : 0.020582109674161, 'XAU' : 0.000249595454823, 'XCD' : 2.7, 'XEU' : 0.86770508259643, 'XOF' : 569, 'XPD' : 0.00068810810716198, 'XPF' : 104, 'XPT' : 0.00063604563466001, 'YER' : 238, 'YUN' : 101, 'ZAR' : 17, '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 = donationForm.currency; $('.lp-error-smallamount').text( function( index, oldText ) { return oldText.replace( '$1', donationForm.formatAmount( donationForm.minLocal ) + '\xa0' + currency ); }); if ( currency === 'USD' ) { // we don't need to include the conversion $('.lp-error-bigamount').text( function( index, oldText ) { return oldText.replace( '($1 $2) ', '' ) .replace( '($1&nbsp;$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 adjustMinAmounts() { // Amounts spreadsheet https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 // Defining lookup table here. Using mw.loader.getScript was visibly too slow for the user (amounts flashing) const minPlusLookup = { // US - Canada - UK - EUR - Australia - New Zealand // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 USD: { amount1: { from: 2.75, to: 4.50 }, amount2: { from: 5, to: 7 }, }, GBP: { amount1: { from: 2, to: 4 }, amount2: { from: 5, to: 7 }, }, EUR: { amount1: { from: 2.50, to: 4.50 }, amount2: { from: 5, to: 7 }, }, // English Bundle // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=891721479#gid=891721479 HUF: { amount1: { from: 500, to: 750 }, }, MYR: { amount1: { from: 10, to: 20 }, amount2: { from: 30, to: 40 }, }, RON: { amount1: { from: 10, to: 30 }, }, // Other // https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1865233115#gid=1865233115 CZK: { amount1: { from: 50, to: 100 }, amount2: { from: 100, to: 150 }, }, DKK: { amount1: { from: 20, to: 40 }, amount2: { from: 75, to: 80 }, }, JPY: { amount1: { from: 500, to: 1000 }, amount2: { from: 1000, to: 2000 }, amount3: { from: 2000, to: 3000 }, amount4: { from: 2500, to: 4000 }, amount5: { from: 4000, to: 5000 }, amount6: { from: 5000, to: 10000 }, amount7: { from: 10000, to: 15000 }, }, ZAR: { amount1: { from: 30, to: 50 }, amount2: { from: 50, to: 75 }, }, NOK: { amount1: { from: 30, to: 50 }, }, SEK: { amount1: { from: 30, to: 50 }, amount2: { from: 50, to: 70 }, }, ILS: { amount1: { from: 10, to: 20 }, }, PLN: { amount1: { from: 10, to: 20 }, amount2: { from: 20, to: 30 }, }, CHF: { amount1: { from: 20, to: 30 }, }, THB: { amount1: { from: 100, to: 150 }, amount2: { from: 200, to: 250 }, }, }; // CAD, AUD, NZD = USD amounts minPlusLookup.CAD = minPlusLookup.USD; minPlusLookup.AUD = minPlusLookup.USD; minPlusLookup.NZD = minPlusLookup.USD; if ( mw.util.getParamValue( 'minPlus' ) === '1' || mw.util.getParamValue( 'minPlus' ) === 'true' ) { const currencyEntry = minPlusLookup[ donationForm.currency ]; // Currency not in lookup table. No swapping. if ( !currencyEntry ) return null; const amountKeys = Object.keys( currencyEntry ); // ["amount1", "amount2"] or however many keys in lookup amountKeys.forEach( (amount, index) => { const $radio = $( `#input_amount_${index}` ); const $label = $( `label[for='input_amount_${index}` ); // If the button's amount is equal to "from" in the lookup, perform the swap. // Guards from hpc adjusted amounts as those values won't be present in the lookup. if ( currencyEntry[amount].from === parseFloat( $radio.val() ) ) { $radio.val( currencyEntry[amount].to ); $label.text( donationForm.formatCurrency( currencyEntry[amount].to ) ); } }); } } 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' 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 = donationForm.currency; // https://phabricator.wikimedia.org/T381437 var hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== currency ) { console.log('Highest previous contribution currency does not match form currency, using default amounts'); return; } // Consult this sheet for amounts: https://docs.google.com/spreadsheets/d/1oJGy5ZxBL0HYl5pwbEORkl_VXy3SEjmT7ZOVYQdBsXQ/edit?gid=1360915542#gid=1360915542 var radioAmountsData = { "USD" : { // also used for CAD, AUD, NZD "default" : [ [ 0, [ 2.75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2.75, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], // Direct Mail - fixed amounts "directmail" : [ [ 0, [ 25, 35, 50, 100, 150, 250, 300 ] ] ], "directmail250" : [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ] }, "EUR" : { "default" : [ [ 0, [ 2.50, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5.50, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2.50, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], }, "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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_Annual" : [ [ 0, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 5, [ 15, 20, 25, 35, 50, 75, 100 ] ], [ 10, [ 15, 20, 25, 35, 50, 75, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus" : [ [ 0, [ 4, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus5-50" : [ [ 0, [ 5, 7, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_MinPlus6" : [ [ 0, [ 6, 10, 15, 20, 25, 35, 50 ] ], [ 5, [ 8, 12, 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, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], "FY2526_AvgGiftPlus" : [ [ 0, [ 2, 5, 10, 15, 20, 35, 50 ] ], [ 5, [ 5, 10, 20, 25, 35, 50, 100 ] ], [ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ], [ 15, [ 15, 20, 35, 40, 50, 75, 100 ] ], [ 20, [ 20, 25, 35, 40, 50, 100, 150 ] ], [ 25, [ 25, 35, 50, 60, 75, 100, 150 ] ], [ 35, [ 35, 50, 75, 100, 125, 150, 250 ] ], [ 50, [ 50, 75, 85, 100, 125, 150, 250 ] ], [ 75, [ 75, 100, 115, 125, 150, 200, 250 ] ], [ 100, [ 100, 125, 150, 175, 200, 250, 500 ] ], [ 125, [ 125, 150, 175, 200, 250, 300, 500 ] ], [ 150, [ 150, 175, 200, 225, 275, 500, 750 ] ], [ 175, [ 175, 200, 225, 250, 350, 500, 750 ] ], [ 200, [ 200, 225, 250, 275, 350, 500, 750 ] ], [ 225, [ 225, 250, 275, 300, 400, 500, 750 ] ], [ 250, [ 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 ] ] ], }, "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 ] ], [ 5000, [ 5000, 10000, 15000, 20000, 35000, 50000, 100000 ] ], [ 10000, [ 10000, 25000, 50000, 75000, 100000, 150000, 200000 ] ] ], "SEK" : [ [ 0, [ 30, 50, 100, 150, 200, 300, 500 ] ], [ 50, [ 50, 100, 150, 200, 300, 500, 750 ] ], [ 200, [ 200, 300, 500, 750, 1000, 1500, 2000 ] ] ] }; 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 currencyList = [ 'USD', 'CAD', 'AUD', 'NZD', 'GBP', 'EUR' ]; // close enough for ( let i = 0; i < currencyList.length; i++ ) { // FY2425 hpcSets // Major Gifts hpcSets radioAmountsData[ currencyList[i] ].MG_2024_500 = [ [ 0, [ 500, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2024_650 = [ [ 0, [ 650, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; // FY2526 hpcSets // Direct Mail hpcSets radioAmountsData[ currencyList[i] ].DM_2526_15 = [ [ 0, [ 15, 25, 35, 50, 100, 200, 250 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2526_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2526_5000 = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; // Major Gifts hpcSets radioAmountsData[ currencyList[i] ].MG_2526_500_9999 = [ [ 0, [ 750, 850, 1000, 1250, 1500, 1750, 2000 ] ], [ 1000, [ 1500, 2000, 2500, 3000, 3750, 4500, 5000 ] ], [ 3000, [ 4000, 5000, 6000, 7000, 8000, 9000, 10000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_10K = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_250_399 = [ [ 0, [ 500, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_400_499 = [ [ 0, [ 650, 750, 1000, 1250, 1500, 1750, 2000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_HNWI_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_HNWI_350 = [ [ 0, [ 350, 400, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].MG_2526_2500 = [ [ 0, [ 2500, 3000, 5000, 7500, 10000, 15000, 25000 ] ] ]; } var appealAmountsData = { "USD" : [ // also used for CAD, AUD, NZD, GBP, EUR [ 0, [ 5, 10, 20 ] ], [ 10, [ 10, 20, 50 ] ], [ 20, [ 20, 30, 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; // Radio button amounts var radioAmounts = pickAmountArray( radioAmountsData, currency, hpc, hpcSet ); if ( radioAmounts.length ) { donationForm.setAmountOptions( radioAmounts ); } // Appeal amounts var appealAmounts = pickAmountArray( appealAmountsData, currency, hpc, hpcSet ); if ( appealAmounts.length ) { var appealAmountString = appealAmounts.map( donationForm.formatCurrency ).join( ', '); $('.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') || mw.util.getParamValue('preselect') ); if ( preSelectAmount > 0 ) { let hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== donationForm.currency ) { console.log('Highest previous contribution currency does not match form currency, not doing preselection'); return; } 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 preSelectBox() { /* Check for a 'preSelectBox' url parameter, and select that numbered option. If the value provided is invalid or doesn't exist, exit. Valid choices are 1 to 7 (8 is "Other"). If 'preSelect' exists, ignore this function. */ if(!mw.util.getParamValue('preSelect')){ // Check hpcCurrency first before running preselection. let hpcCurrency = mw.util.getParamValue('hpcCurrency'); if ( hpcCurrency && hpcCurrency !== donationForm.currency ) { console.log('Highest previous contribution currency does not match form currency, not preselecting box.'); return; } // If hpc & hpcCurrency provided are okay OR hpc wasn't provided then continue. var preSelectBoxNumber = parseInt( mw.util.getParamValue('preSelectBox') ); if (preSelectBoxNumber >= 1 && preSelectBoxNumber <= 7) { var $preSelectOption = $('input[id="input_amount_' + (preSelectBoxNumber - 1) + '"]'); if ( $preSelectOption.length ) { $preSelectOption.prop('checked', true); donationForm.updateFeeDisplay(); } } } } function preSelectFrequency() { if ( donationForm.noRecurringCountries.indexOf( donationForm.country ) === -1 && 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' ); } } } 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' : 'vma', 'IT' : 'vmaj', 'LU' : 'vmaj', 'LV' : 'vma', 'NL' : 'vmaj', 'PT' : 'vmaj', 'SK' : 'vmaj', 'GR' : 'vma', // Others 'CZ' : 'vmad', 'DK' : 'vma', 'HU' : 'vma', 'IL' : 'vmad', // 'JP' : 'vmaj', - use text only as there were complaints about Diners Club not being included 'MY' : 'vmaj', 'NO' : 'vma', 'PL' : 'vma', 'RO' : 'vma', 'SE' : 'vma', 'UA' : 'vma', 'ZA' : 'vm', 'ZZ' : 'vmad' // For testing }; 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(''); } /* -- Moved from Template:2012FR/Form-section/Processing/Default -- */ /** * 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; params.country = donationForm.country; // Overrides for specific gateways if ( paymentMethod === 'cc-adyen' ) { params.payment_method = 'cc'; params.gateway = 'adyen'; } else if ( paymentMethod === 'cc-dlocal' ) { params.payment_method = 'cc'; params.gateway = 'dlocal'; } else if ( paymentMethod === 'trustly' ) { params.payment_method = 'dd'; params.payment_submethod = 'ach'; params.gateway = 'gravy'; } else if ( paymentSubMethod === 'sepadirectdebit' ) { params.payment_method = 'rtbt'; params.payment_submethod = 'sepadirectdebit'; params.gateway = 'gravy'; } else if ( paymentMethod === 'bt' && params.country === 'CZ' ) { params.payment_method = 'bt'; params.gateway = 'gravy'; } else if ( paymentSubMethod === 'vipps' ) { params.payment_method = 'ew'; params.payment_submethod = 'vipps'; params.gateway = 'gravy'; } else { params.payment_method = paymentMethod; } // dlocal let dlocalCountries = [ 'AR', 'BR', 'CL', 'CO', 'MX', 'PE', 'UY', 'ZA' ], dlocalMethods = [ 'cc', 'bt', 'cash', 'cash_boleto', 'pix' ]; if ( dlocalCountries.includes( params.country ) && dlocalMethods.includes( params.payment_method ) ) { params.gateway = 'gravy'; } if ( params.payment_method === 'cc' && params.gateway === undefined ) { params.gateway = 'gravy'; } if ( params.payment_method === 'paypal' ) { params.gateway = 'gravy'; } if ( params.payment_method === 'rtbt' && paymentSubMethod === 'rtbt_ideal' ) { params.gateway = 'gravy'; } if ( params.payment_method === 'apple' || params.payment_method === 'google' ) { params.gateway = 'gravy'; } if ( paymentSubMethod ) { params.payment_submethod = paymentSubMethod; } let frequency = donationForm.getFrequency(); if ( frequency === 'monthly' ) { 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 if ( params.uselang === 'pt' && params.country === 'BR' ) { params.uselang = 'pt-br'; } if ( params.uselang === 'es' && ( params.country === 'AR' || params.country === 'CL' || params.country === 'CO' || params.country === 'MX' || params.country === 'PE' || params.country === 'UY' || params.country === 'US' ) ) { params.uselang = 'es-419'; } var amount = donationForm.getAmount(); if ( $('#ptf-checkbox').prop('checked') ) { amount = amount + donationForm.calculateFee( amount ); donationForm.extraData.ptf = 1; } params.amount = amount; // Email optin if ( $('input[name="opt_in"]').length > 0 ) { 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' ) ) { params.variant = mw.util.getParamValue( 'pym_variant' ); } if ( params.recurring && params.variant && params.variant.match( /monthlyConvert/ ) ) { // Post-payments monthly convert makes no sense if it's already recurring // Avoid things like T312905 delete params.variant; } if ( mw.util.getParamValue( 'pym_appeal' ) ) { params.appeal = mw.util.getParamValue( 'pym_appeal' ); } // Pass through specified parameters to payments unchanged const passThroughParams = [ 'contact_id', 'contact_hash', // https://phabricator.wikimedia.org/T381405 'checksum', 'contribution_recur_id', // https://phabricator.wikimedia.org/T396271 'recipient_id', // SMS 'app_install_id' // https://phabricator.wikimedia.org/T411535 ]; passThroughParams.forEach( ( param ) => { const value = mw.util.getParamValue( param ); if ( value ) { params[ param ] = value; } } ); // Monthly convert if ( mc ) { // check just in-case this wasn't loaded for some reason mc.main( params, donationForm.finalStep ); } else { donationForm.finalStep( params ); } } 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 final tracking parameters, and submit to payments * @param {Object} params */ donationForm.finalStep = function( params ) { var url = new URL('https://payments.wikimedia.org/index.php/Special:GatewayChooser'); // Skip form chooser for Venmo if ( params.payment_method === 'venmo' ) { url = new URL('https://payments.wikimedia.org/index.php/Special:GravyGateway'); } // Skip form chooser for Pix if ( params.payment_method === 'cash' && params.payment_submethod === 'pix' ) { url = new URL('https://payments.wikimedia.org/index.php/Special:GravyGateway'); } 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 * * @param {Object} params * @return {string} wmf_source */ donationForm.buildTrackingSource = function( params ) { var wmf_source = mw.util.getParamValue( 'wmf_source' ) || mw.util.getParamValue( 'utm_source' ); wmf_source += '.'; var fullDottedPaymentMethod = params.payment_method; if ( params.recurring ) { fullDottedPaymentMethod = 'r' + fullDottedPaymentMethod; } if ( params.payment_submethod ) { fullDottedPaymentMethod = fullDottedPaymentMethod + '.' + params.payment_submethod; } /* Get URL parameter, but remove parts using old format. Allow fallback to a default value */ var getParam = function( param, removeText, dflt ) { if ( mw.util.getParamValue( param ) ) { return mw.util.getParamValue( param ).replace( removeText, '' ); } else { return dflt; } }; /* The landing page info, separated by ~. This mostly exists for legacy reasons */ 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 wmf_key from extra tracking data * * @param {Object} data * @return {string} wmf_key */ donationForm.buildTrackingKey = function(data) { var existingKey = mw.util.getParamValue( 'wmf_key' ) || mw.util.getParamValue( 'utm_key' ), dataArray = []; if ( existingKey ) { dataArray.push( existingKey ); } for (var key in data) { if (data.hasOwnProperty(key)) { dataArray.push( key + '_' + data[key] ); } } return dataArray.join('~'); }; /* Return amount selected or input */ donationForm.getAmount = function() { var form = document.forms.donateForm, 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; }; /** * 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 ) { 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.forms.donateForm; // Reset all errors $('.lp-haserror').removeClass('lp-haserror'); $('.lp-error').hide(); if ( !skipAmountValidation && !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(); } } return !error; }; /** * Check if selected amount is valid i.e. a positive number, between minimum and maximum. * If not, show an error and return false. */ donationForm.validateAmount = function() { var amount = donationForm.getAmount(); if ( amount === null || isNaN(amount) || amount <= 0 || amount < donationForm.minLocal ) { $('.amount-options').addClass('lp-haserror'); $('.lp-error-bigamount').hide(); $('.lp-error-smallamount').show().focus(); return false; } else if ( amount > donationForm.maxLocal ) { $('.amount-options').addClass('lp-haserror'); $('.lp-error-bigamount').show().focus(); return false; } else { $('.amount-options').removeClass('lp-haserror'); $('.lp-error-smallamount, .lp-error-bigamount').hide(); return true; } }; donationForm.getFrequency = function() { return document.forms.donateForm.dataset.frequency || 'onetime'; }; donationForm.setFrequency = function( frequency ) { // TODO: add some validation to reject invalid frequency values let form = document.forms.donateForm; form.frequency.value = frequency; // change input form.dataset.frequency = frequency; if ( frequency === 'monthly' ) { donationForm.switchToMonthlyAmounts(); } else { donationForm.setAmountOptions( donationForm.originalAmounts ); } }; /* Wrapper for compatibility with old forms */ donationForm.toggleMonthly = function( monthly ) { if ( monthly ) { donationForm.setFrequency( 'monthly' ); } else { donationForm.setFrequency( 'onetime' ); } }; donationForm.updateFeeDisplay = function() { var selectedAmount = donationForm.getAmount(), feeAmount = donationForm.calculateFee( selectedAmount ), feeText; feeText = donationForm.formatCurrency( feeAmount ); $('.ptf label span').text( feeText ); if ( selectedAmount + feeAmount <= donationForm.maxLocal ) { $('.ptf').slideDown(); } }; /** * Calculate approximate transaction fee on given amount * @param {number} amount * @return {number} Rounded to 2 decimal places */ donationForm.calculateFee = function( amount ) { // Minimum fee/PTF amounts. Default is 0.35. // Updated 2019-05-21 to approx 0.35 USD equivalent var feeMinimums = { 'DKK' : 2, 'HUF' : 100, 'ILS' : 1.2, 'INR' : 4, 'JPY' : 35, 'KHR' : 1000, 'MYR' : 1, 'NOK' : 3, 'PLN' : 1.35, 'CZK' : 7.5, 'RON' : 1.5, 'SEK' : 3, 'UAH' : 10, 'ZAR' : 5, // Latin America // Updated 2025-06-10 to approx 0.35 USD equivalent 'BRL' : 2, 'ARS' : 415, 'CLP' : 325, 'COP' : 1450, 'MXN' : 6.75, 'PEN' : 1.28, 'UYU' : 14.5 }; var feeMultiplier = 0.04, feeMinimum = feeMinimums[ donationForm.currency ] || 0.35, feeAmount = amount * feeMultiplier; 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.screen.width >= 640 && country !== 'JP' ) { // T397002 // On a desktop browser, people can scan with their iphone return true; } else if ( window.ApplePaySession ) { // On mobile, check if Apple Pay is available natively if ( ApplePaySession.canMakePayments() ) { return true; } } return false; }; /** * Determine if the annual option should be shown on the donation form, and show it if so * * @returns {boolean} true if the annual option is enabled */ donationForm.initAnnualRecurring = function() { /* Before adding a language here, please check that we have annual translations in-place for: - the button here on donatewiki ([[MediaWiki:Frequency-Annual]]) - the thank you receipt email - donor relations macros - the thank you page (optional if it has no recurring-specific messaging) */ const annualLanguages = ['%%isolang%%', '%25%25ISOLANG%25%25', '%25%25isolang%25%25', 'el', 'en', 'en-ca', 'en-gb', 'en-us', 'es', 'es-419', 'fr', 'it', 'ja', 'nl', 'pt', 'pt-br'] const annualInput = document.getElementById( 'frequency_annual' ); if ( !annualInput ) { // old form without required input return false; } let annualEnabled = annualLanguages.includes( mw.config.get( 'wgPageContentLanguage' ) ); // Allow overriding with URL params if ( mw.util.getParamValue( 'form-countryspecific' ) === 'Form-countryspecific-annual' // compatibility with old method || mw.util.getParamValue( 'annual_enabled' ) === '1' ) { annualEnabled = true; } if ( mw.util.getParamValue( 'annual_enabled' ) === '0' ) { annualEnabled = false; } annualInput.parentNode.style.display = annualEnabled ? 'block' : 'none'; if ( annualEnabled ) { document.forms.donateForm.classList.add( 'annual-enabled' ); } return annualEnabled; }; /** * Change the amount options on the donation form * @param {array} newAmounts */ donationForm.setAmountOptions = function( newAmounts ) { for (var j = 0; j < newAmounts.length; j++) { var $radio = $( `#input_amount_${j}` ); var $label = $( `label[for="input_amount_${j}"]` ); $radio.val( newAmounts[j] ); $label.text( donationForm.formatCurrency( newAmounts[j] ) ); } }; /** * Get the current amount options e.g. to store original amounts before changing them * @returns {array} Array of amounts as numbers */ donationForm.getAmountOptions = function() { let amounts = []; document.querySelectorAll('input[name="amount"]').forEach( (input) => { let amount = parseFloat( input.value ); if ( !isNaN( amount ) ) { amounts.push( amount ); } } ); return amounts; }; donationForm.switchToMonthlyAmounts = function() { let currency = donationForm.currency; let hpcSet = mw.util.getParamValue('hpcSet'); let hpc = parseFloat( mw.util.getParamValue('hpc') ); if( isNaN(hpc) ) { hpc = parseFloat( mw.util.getParamValue('mrc') ); if( isNaN(hpc) ) { hpc = 0; } } let monthlyAmountsData = { "USD": { "default": [ [ 0, [ 1.50, 1.75, 2, 4, 5, 10, 15 ] ], [ 100, [ 15, 20, 25, 30, 35, 40, 80 ] ] ] } }; monthlyAmountsData.AUD = monthlyAmountsData.USD; monthlyAmountsData.CAD = monthlyAmountsData.USD; monthlyAmountsData.NZD = monthlyAmountsData.USD; let monthlyAmounts = pickAmountArray( monthlyAmountsData, currency, hpc, hpcSet ); if ( monthlyAmounts.length ) { donationForm.setAmountOptions( monthlyAmounts ); } } /* 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; } }; /* End form functions */ $(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 ) { donationForm.initAnnualRecurring(); // hide frequency options for some countries if ( donationForm.noRecurringCountries.indexOf( donationForm.country ) !== -1 ) { $('#frequency_onetime').prop('checked', true); $('.frequency-options, #cancel-monthly, #donate-recurring-smallprint').hide(); } if ( donationForm.noRecurringPaypalCountries.indexOf( donationForm.country ) !== -1 ) { $( '.paymentmethod-pp, .paymentmethod-pp-usd' ).addClass( 'not-monthly-capable' ); } // Format amounts on buttons $( '.amount-options li' ).each( function( index ) { let amount = this.querySelector( 'input' ).value; if ( amount !== 'Other' ) { this.querySelector( 'label' ).innerText = donationForm.formatCurrency( amount ); } }); addCardTypesClass( donationForm.country ); // Only show Amazon for links from Ways to give if ( mw.util.getParamValue( 'wmf_source' ) === 'Waystogive' || mw.util.getParamValue( 'wmf_source' ) === 'Ways_to_Give' ) { $('.paymentmethod-amazon').show(); } // Only show DAF for certain Major Gifts links if ( mw.util.getParamValue( 'wmf_campaign' ) === 'MG2WIR25' ) { $('.paymentmethod-daf').show(); } else { $('.paymentmethod-daf').hide(); } // Apple Pay if ( $('.paymentmethod-applepay').length > 0 ) { if ( !donationForm.shouldShowApplePay( donationForm.country ) ) { $('.paymentmethod-applepay').remove(); } } // Venmo browser check if ( $('.paymentmethod-venmo').length > 0 ) { if ( !donationForm.isVenmoSupported() || donationForm.country !== 'US' ) { $('.paymentmethod-venmo').remove(); } } // Hide Google Pay if people are coming from iOS app https://phabricator.wikimedia.org/T411504 if ( mw.util.getParamValue('wmf_campaign') === 'iOS' ) { $('.paymentmethod-google').remove(); } } // Links open in new tab $('.links-in-new-tab a').attr('target', '_blank'); // Disable logo link $('#p-logo a').attr( { href: '#', 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(); }); // If we are emailing them and they have a contact_id, then we can assume they have opted in, // unless this is a "Remind Me Later" email, or they are in a stricter country let hasContactId = mw.util.getParamValue( 'contact_id' ) !== null; let isRML = mw.util.getParamValue( 'wmf_campaign' ) && mw.util.getParamValue( 'wmf_campaign' ).includes( 'RMLEmail' ); let isStrictCountry = [ 'AT', 'IT' ].includes( donationForm.country ); if ( document.getElementById('optin-yes') && hasContactId && !isRML && !isStrictCountry ) { document.getElementById('optin-yes').checked = true; document.querySelector('.optin-options').style.display = 'none'; } donationForm.initOptin(); try { adjustHPC(); adjustMinAmounts(); // Store original amounts to switch back later if needed donationForm.originalAmounts = donationForm.getAmountOptions(); preSelectFrequency(); preSelect(); // Make sure to do this *after* other fiddling with values preSelectBox(); donationForm.localizeErrors(); } finally { $('.frb-monthly-pitch, .frb-monthly-pitch-thanks, .frb-recurring-pitch').appendTo('.frequency-options'); $('.ptf').appendTo('.amount-options'); $('.optin-options').insertAfter('.amount-options'); $('.consider-amounts').show(); $('#actual-form').show(); $('#actual-form-loading').hide(); } }); }); fa6vb7lczcgyaf0nspx1oppd3bghe1f