MediaWiki:DonationForm.js: Difference between revisions

Content deleted Content added
re-add Amex in Japan
Tag: Reverted
m Reverted edit by PPenloglou-WMF (talk) to last revision by Pcoombe
Tag: Rollback
 
(95 intermediate revisions by 2 users not shown)
Line 7:
 
donationForm.loadedTime = Date.now();
donationForm.extraData = {};
'vw' : window.innerWidth,
'vh' : window.innerHeight
};
 
donationForm.country = mw.util.getParamValue('country').toUpperCase();
if ( navigator.brave !== undefined ) { // T283367
try {
donationForm.extraData.brave = '1';
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', 'CL', 'CO', 'MX', 'PE', 'UY', 'BR', 'IN' ];
 
donationForm.noRecurringPaypalCountries = [ 'CL', 'CO', 'PE', 'UY', 'BR' ];
 
donationForm.maxUSDcurrencyRates = 12000;{
// From https://github.com/wikimedia/wikimedia-fundraising-SmashPig/blob/master/PaymentData/ReferenceData/CurrencyRates.php
donationForm.minimums = {
// Updated 2024-07-31
/* From https://github.com/wikimedia/wikimedia-fundraising-SmashPig/blob/master/PaymentData/ReferenceData/CurrencyRates.php */
'ADF' : 56.4504,
'ADP' : 138153,
'AED' : 3.67,
'AFA' : 7770,
'AFN' : 7770,
'ALL' : 10290,
'AMD' : 522368,
'ANG' : 1.79,
'AOA' : 622844,
'AON' : 622844,
'ARS' : 90887,
'ATS' : 1113,
'AUD' : 1.295,
'AWG' : 1.79,
'AZM' : 8500,
'AZN' : 1.7,
'BAM' : 1.638,
'BBD' : 2,
'BDT' : 83116,
'BEF' : 3437,
'BGL' : 1.638,
'BGN' : 1.638,
'BHD' : 0.3750371223512937355757356689,
'BIF' : 19272842,
'BMD' : 1,
'BND' : 1.3335,
'BOB' : 6.7471,
'BRL' : 5.621,
'BSD' : 1,
'BTN' : 7383,
'BWP' : 1113,
'BYR' : 2606532642,
'BZD' : 1.9798,
'CAD' : 1.2636,
'CDF' : 19752786,
'CHF' : 0.923736276431919094629289448,
'CLP' : 729890,
'CNY' : 67.4723,
'COP' : 36603803,
'CRC' : 601498,
'CUC' : 1,
'CUP' : 25,
'CVE' : 92101,
'CYP' : 0.486622099303153848627984321,
'CZK' : 2223,
'DEM' : 1.638,
'DJF' : 178,
'DKK' : 6.1886,
'DOP' : 5758,
'DZD' : 133,
'ECS' : 24094,
'EEK' : 1314,
'EGP' : 1647,
'ESP' : 138153,
'ETB' : 4057,
'EUR' : 0.8314432202747892005843390143,
'FIM' : 45.9447,
'FJD' : 2.0223,
'FKP' : 0.7174344223174578703952551207,
'FRF' : 56.4504,
'GBP' : 0.7174344223174578703952551207,
'GEL' : 32.371,
'GHC' : 57159143125,
'GHS' : 5.7214,
'GIP' : 0.7174344223174578703952551207,
'GMD' : 5168,
'GNF' : 100418493,
'GRD' : 283314,
'GTQ' : 7.5357,
'GYD' : 201200,
'HKD' : 7.768,
'HNL' : 24,
'HRK' : 6.393,
'HTG' : 76132,
'HUF' : 303355,
'IDR' : 1427915986,
'IEP' : 0.6548147483324872460490043714,
'ILS' : 3.369,
'INR' : 7383,
'IQD' : 14421290,
'IRR' : 4201042009,
'ISK' : 127138,
'ITL' : 16101781,
'JMD' : 149154,
'JOD' : 0.70900000000001,
'JPY' : 107156,
'KES' : 109130,
'KGS' : 8588,
'KHR' : 40193993,
'KMF' : 409453,
'KPW' : 135,
'KRW' : 11261358,
'KWD' : 0.3019115390725730629670764681,
'KYD' : 0.83333299999999,
'KZT' : 418442,
'LAK' : 917021103,
'LBP' : 150889393,
'LKR' : 194298,
'LRD' : 173193,
'LSL' : 1518,
'LTL' : 23.8718,
'LUF' : 3437,
'LVL' : 0.5843416209819864662074757963,
'LYD' : 4.428,
'MAD' : 89.8279,
'MDL' : 17,
'MGA' : 37164379,
'MGF' : 9150,
'MKD' : 5156,
'MMK' : 13922075,
'MNT' : 2620,
'MOP' : 78.9903,
'MRO' : 357391,
'MTL' : 0.3569385744639639498108567387,
'MUR' : 3945,
'MVR' : 15,
'MWK' : 7701720,
'MXN' : 2117,
'MYR' : 4.0568,
'MZM' : 7388063200,
'MZN' : 7463,
'NAD' : 1518,
'NGN' : 3801505,
'NIO' : 3536,
'NLG' : 12.8303,
'NOK' : 8.5211,
'NPR' : 115131,
'NZD' : 1.3863,
'OMR' : 0.3838395736509838377594841305,
'PAB' : 1,
'PEN' : 3.6367,
'PGK' : 3.4376,
'PHP' : 4958,
'PKR' : 157277,
'PLN' : 3.7891,
'PTE' : 167184,
'PYG' : 65417355,
'QAR' : 3.6156,
'ROL' : 4051745713,
'RON' : 4.0557,
'RSD' : 97108,
'RUB' : 7491,
'RWF' : 9731277,
'SAR' : 3.75,
'SBD' : 78.8937,
'SCR' : 2013,
'SDD' : 3446759800,
'SDG' : 345598,
'SDP' : 2261,
'SEK' : 8.4511,
'SGD' : 1.3335,
'SHP' : 0.7174344223174578703952551207,
'SIT' : 199220,
'SKK' : 2528,
'SLL' : 1010519750,
'SOS' : 558549,
'SRD' : 1433,
'SRG' : 1401833320,
'STD' : 2030422477,
'SVC' : 8.75,
'SYP' : 513,
'SZL' : 1518,
'THB' : 3036,
'TJS' : 11,
'TMM' : 1677016750,
'TMT' : 3.35,
'TND' : 23.6911,
'TOP' : 2.2232,
'TRL' : 745695132168418,
'TRY' : 7.4632,
'TTD' : 6.6664,
'TWD' : 2832,
'TZS' : 23092587,
'UAH' : 2839,
'UGX' : 36413760,
'USD' : 1,
'UYU' : 4338,
'UZS' : 1042712662,
'VEB' : 1.86275657102E+143651907631,
'VEF' : 1862756571023651908,
'VND' : 2294025451,
'VUV' : 112,
'WST' : 2.4367,
'XAF' : 545604,
'XAG' : 0.038609238198237031347411860134,
'XAU' : 0.00058453703815200041128929241299,
'XCD' : 2.7,
'XEU' : 0.8314432202747892005843390143,
'XOF' : 545604,
'XPD' : 0.00042350786636400098009826645798,
'XPF' : 99110,
'XPT' : 0.0008536716746060300093444018680404,
'YER' : 250249,
'YUN' : 97108,
'ZAR' : 1518,
'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;
var minAmount = donationForm.minimums[ currency ];
/* T287706 - round to 2 decimal places (rounding up) */
var numFormat = function( amount ) {
return Math.ceil( amount * 100 ) / 100;
};
 
$('.lp-error-smallamount').text( function( index, oldText ) {
return oldText.replace( '$1', numFormatdonationForm.formatAmount( minAmountdonationForm.minLocal ) + ' \xa0' + currency );
});
 
Line 243 ⟶ 309:
 
$('.lp-error-bigamount').text( function( index, oldText ) {
return oldText.replace( '$1', numFormatdonationForm.formatAmount( donationForm.maxUSD * minAmountmaxLocal ) )
.replace( '$2', currency )
.replace( '$3', 'benefactors@wikimedia.org' )
.replace( '$4', donationForm.formatAmount( donationForm.maxUSD ) );
});
};
Line 256 ⟶ 322:
TODO: split data out? */
 
var hpcSet = mw.util.getParamValue('hpcSet');
// Look for 'hpc' parameter, then 'mrc'. If neither, then bail out.
 
// 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) ) {
return;if ( hpcSet ) {
// Allow using hpcSet even without hpc, for MG appeals
hpc = 0;
} else {
return;
}
}
}
 
var hpcSet = mw.util.getParamValue('hpcSet');
 
var currency = donationForm.currency;
var language = mw.config.get('wgPageContentLanguage');
 
// If changing, please update https://docs.google.com/spreadsheets/d/1e02TsZ_bKDAS1BMVBCdyo9D7RGln_wCGnkg7IF5kU5s/edit
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, 200, 300, 500 ] ],
[ 7550, [ 50, 75, 100, 150 200, 250 300, 500, 750, 1000 ] ],
[ 100 75, [ 75, 100, 150, 250, 500, 750, 1000, 2500 ] ],
[ 150100, [ 150100, 200 150, 300 250, 500, 750, 1000, 20002500 ] ],
[ 200150, [ 150, 200, 300, 500, 750, 1000, 25001000, 50002000 ] ],
[ 500200, [ 500200, 750 300, 1000 500, 2500 750, 5000 1000, 75002500, 10000 5000 ] ],
[ 1000 500, [ 1000 500, 2000 750, 3000 1000, 4000 2500, 5000, 7500, 10000 ] ],
[ 30001000, [ 1000, 2000, 3000, 4000, 5000, 6000, 7500, 10000, 12000 ] ],
[ 3000, [ 3000, 4000, 5000, 6000, 7500, 10000, 12000 ] ]
],
'2incvar'"FY2425_E1_T11_USD" : [ // Upgrade recurring +1 for lowest ask
[ 0, [ 13.75, 5, 10, 15 20, 20 25, 30 35, 50 ] ],
[ 35, [ 35, 510, 10 15, 20, 35, 50, 75100 ] ],
[ 610, [ 610, 10 15, 20, 35 25, 50 35, 75 50, 100 ] ],
[ 1015, [ 1015, 15 20, 25, 50 35, 75 50, 100 75, 125 100 ] ],
[ 1320, [ 1320, 20 25, 35, 50, 75, 100, 125 150 ] ],
[ 1625, [ 1625, 25 30, 40, 50, 75, 100, 150, 200 ] ],
[ 2035, [ 2035, 35 50, 50 75, 75100, 125 200, 150 300, 200 500 ] ],
[ 2350, [ 2350, 35 75, 50100, 75200, 125 300, 175 500, 250 750 ] ],
[ 2675, [ 2675, 35100, 50150, 75250, 125 500, 175 750, 2501000 ] ],
[ 30100, [ 30100, 40150, 50250, 75500, 125 750, 1751000, 2502500 ] ],
[ 35150, [ 35150, 45200, 50300, 100 500, 125 750, 1751000, 2502000 ] ],
[ 40200, [ 40200, 50300, 75500, 100 750, 1501000, 2502500, 3005000 ] ],
[ 45500, [ 45500, 50750, 751000, 1002500, 1505000, 2507500, 50010000 ] ],
[ 501000, [ 501000, 602000, 1003000, 1254000, 1755000, 2507500, 50010000 ] ],
[ 603000, [ 603000, 754000, 1005000, 1256000, 1757500, 25010000, 50012000 ] ],
[ 70, [ 70, 85, 100, 125, 175, 250, 500 ] ],
[ 80, [ 80, 100, 125, 150, 200, 300, 500 ] ],
[ 90, [ 90, 100, 125, 150, 200, 300, 500 ] ],
[ 100, [ 100, 125, 175, 250, 350, 500, 750 ] ],
[ 125, [ 125, 150, 200, 300, 500, 750, 1000 ] ],
[ 150, [ 150, 175, 250, 400, 500, 750, 1000 ] ],
[ 175, [ 175, 200, 300, 400, 500, 750, 1000 ] ],
[ 200, [ 200, 250, 300, 400, 500, 750, 1000 ] ],
],
'3incvarsv'"FY2425_E1_T14_USD" : [ // Upgrade recurring amount dynamically
[ 0, [ 12.75, 5, 7.50, 10, 15 20, 20 25, 30 35, 50 ] ],
[ 35, [ 32.75, 5, 10, 15 20, 20 25, 25 35, 40 50 ] ],
[ 610, [ 62.75, 10, 15, 20, 30 25, 40 35, 50 ] ],
[ 1015, [ 103.50, 1510, 20, 25 30, 30 50, 40 75, 50100 ] ],
[ 1320, [ 133.75, 2010, 25, 35, 45 50, 55 75, 75100 ] ],
[ 1625, [ 164.50, 2010, 25, 35, 45 50, 55 75, 75100 ] ],
[ 2035, [ 206.75, 2515, 35 30, 45 50, 55 75, 75100, 100 150 ] ],
[ 2375, [ 2315.75, 3050, 37 75, 45100, 55200, 75300, 100 500 ] ],
[ 26100, [ 2624.75, 3050, 37 75, 45100, 55200, 75300, 100 500 ] ],
[ 30150, [ 3044.75, 35100, 40150, 45250, 55500, 75750, 1001000 ] ],
[ 35200, [ 35 50, 40100, 45150, 50250, 65500, 75750, 1001000 ] ],
[ 40500, [ 40150, 45250, 50300, 65500, 75750, 1001000, 1252000 ] ],
[ 451000, [ 45250, 50500, 55750, 651000, 752500, 1005000, 12510000 ] ],
[ 503000, [ 50500, 601000, 752000, 1003500, 1255000, 1507500, 20010000 ] ],
[ 60, [ 60, 70, 80, 100, 125, 150, 200 ] ],
[ 70, [ 70, 80, 100, 125, 150, 200, 250 ] ],
[ 80, [ 80, 90, 100, 125, 150, 200, 250 ] ],
[ 90, [ 90, 100, 125, 150, 200, 250, 300 ] ],
[ 100, [ 100, 110, 150, 200, 250, 300, 350 ] ],
[ 125, [ 125, 150, 200, 250, 300, 400, 500 ] ],
[ 150, [ 150, 175, 200, 250, 300, 400, 500 ] ],
[ 175, [ 175, 200, 250, 300, 400, 500, 750 ] ],
[ 200, [ 200, 250, 300, 350, 400, 500, 750 ] ],
],
'4HA7'"FY2425_E1_T21_USD" : [ // Give less reactivation amount
[ 0, [ 2.75, 5, 10, 20, 25, 35, 100 50 ] ],
[ 5, [ 2.75, 5, 10, 15 20, 20 25, 35, 50, 20050 ] ],
[ 10, [ 10 5, 15 10, 20 15, 25 20, 35, 50, 250 100 ] ],
[ 15, [ 10, 15, 20, 25, 35, 50, 75, 300100 ] ],
[ 20, [ 15, 20, 25, 35, 50, 75, 10075, 500 100 ] ],
[ 25, [ 25 20, 30 25, 40 35, 50, 75, 100, 500 150 ] ],
[ 35, [ 35 25, 50 30, 75 40, 100 50, 200 75, 300 100, 1000 150 ] ],
[ 75, [ 75 35, 100 50, 150 75, 250 100, 500 200, 750 300, 2000 500 ] ],
[ 100, [ 75, 100, 150, 250, 500, 750, 1000, 5000 ] ],
[ 150, [ 150100, 200 150, 300 250, 500, 750, 1000, 7500 2500 ] ],
[ 200, [ 150, 200, 300, 500, 750, 1000, 2500, 100002000 ] ],
[ 500, [ 200, 300, 500, 750, 1000, 2500, 5000, 7500, 120005000 ] ],
[ 1000, [ 1000 500, 2000 750, 3000 1000, 4000 2500, 5000, 7500, 1200010000 ] ],
[ 3000, [ 1000, 2000, 3000, 4000, 5000, 7500, 10000 ] ]
],
'5LA1'// :Direct [Mail - fixed amounts
"directmail" : [
[ 0, [ 1, 5, 10, 15, 20, 30, 50 ] ],
[ 30, [ 325, 535, 10 50, 20 100, 35150, 50250, 75300 ] ],
[ 6, [ 5, 10, 20, 35, 50, 75, 100 ] ],
[ 10, [ 10, 15, 25, 50, 75, 100, 125 ] ],
[ 13, [ 10, 20, 35, 50, 75, 100, 125 ] ],
[ 16, [ 15, 25, 50, 75, 100, 150, 200 ] ],
[ 20, [ 20, 35, 50, 75, 125, 150, 200 ] ],
[ 23, [ 20, 35, 50, 75, 125, 175, 250 ] ],
[ 26, [ 25, 35, 50, 75, 125, 175, 250 ] ],
[ 30, [ 30, 40, 50, 75, 125, 175, 250 ] ],
[ 35, [ 35, 45, 50, 100, 125, 175, 300 ] ],
[ 40, [ 40, 50, 75, 100, 150, 200, 300 ] ],
[ 45, [ 45, 50, 75, 100, 150, 250, 500 ] ],
[ 50, [ 50, 75, 100, 125, 175, 250, 500 ] ],
[ 60, [ 60, 75, 100, 125, 175, 250, 500 ] ],
[ 70, [ 70, 85, 100, 125, 175, 250, 500 ] ],
[ 80, [ 80, 100, 125, 150, 200, 300, 500 ] ],
[ 90, [ 90, 100, 125, 150, 200, 300, 500 ] ],
[ 100, [ 100, 125, 175, 250, 350, 500, 750 ] ],
[ 125, [ 125, 150, 200, 300, 500, 750, 1000 ] ],
[ 150, [ 150, 200, 300, 400, 500, 750, 1000 ] ],
[ 175, [ 175, 200, 300, 400, 500, 750, 1000 ] ],
[ 200, [ 200, 225, 300, 400, 500, 750, 1000 ] ],
],
'2018control'"directmail250" : [
[ 0, [ 5250, 10300, 20500, 25 750, 351000, 502500, 1005000 ] ],
]
[ 5, [ 10, 15, 20, 35, 50, 100, 150 ] ],
},
[ 10, [ 15, 20, 25, 35, 50, 100, 150 ] ],
"EUR" : {
[ 15, [ 20, 25, 35, 50, 75, 100, 250 ] ],
"default" : [ 20, [ 25, 35, 50, 75, 100, 150, 250 ] ],
[ 25 0, [ 302.50, 40 5, 50 10, 75 20, 100 25, 150 35, 250 50 ] ],
[ 35 5, [ 25 5, 50 10, 75 15, 100 20, 200 35, 250 50, 300 100 ] ],
[ 7510, [ 25 10, 50 15, 75 20, 100 25, 200 35, 300 50, 500 100 ] ],
[ 100 15, [ 25 15, 50 20, 100 25, 150 35, 250 50, 500 75, 1000 100 ] ],
[ 150 20, [ 50 20, 100 25, 150 35, 200 50, 350 75, 500 100, 1000 150 ] ],
[ 200 25, [ 100 25, 150 30, 200 40, 300 50, 400 75, 500 100, 1000 150 ] ],
[ 500 35, [ 100 35, 250 50, 500 75, 750 100, 1000 200, 1500 300, 2000 500 ] ],
[ 1000 50, [ 500 50, 1000 75, 2000 100, 2500 200, 3000 300, 4000 500, 5000 750 ] ],
[ 75, [ 75, 100, 150, 250, 500, 750, 1000 ] ],
[ 100, [ 100, 150, 250, 500, 750, 1000, 2500 ] ],
[ 150, [ 150, 200, 300, 500, 750, 1000, 2000 ] ],
[ 200, [ 200, 300, 500, 750, 1000, 2500, 5000 ] ],
[ 500, [ 500, 750, 1000, 2500, 5000, 7500, 10000 ] ],
[ 1000, [ 1000, 2000, 3000, 4000, 5000, 7500, 10000 ] ],
[ 3000, [ 3000, 4000, 5000, 6000, 7500, 10000, 12000 ] ]
],
'LTLA'"FY2425_E1_T11_EUR" : [ // Upgrade recurring +1 for lowest ask
[ 0, [ 3.50, 10 5, 15 10, 20, 35 25, 50 35, 100 50 ] ],
[ 5, [ 5, 10, 15, 20, 35, 50, 100, 150100 ] ],
[ 10, [ 10, 20 15, 35 20, 50 25, 75 35, 100 50, 150 100 ] ],
[ 15, [ 15, 20, 25, 35, 50, 75, 100, 250100 ] ],
[ 20, [ 20, 30 25, 35, 50, 75, 100, 150, 250150 ] ],
[ 25, [ 25, 35 30, 40, 50, 75, 100, 150, 250150 ] ],
[ 35, [ 25 35, 50, 75, 100, 200, 250 300, 300 500 ] ],
[ 7550, [ 25, 50, 75, 100, 200, 300, 500, 750 ] ],
[ 100 75, [ 25, 5075, 100, 150, 250, 500, 750, 1000 ] ],
[ 150100, [ 50, 100, 150, 200 250, 350 500, 500 750, 1000, 2500 ] ],
[ 200150, [ 100, 150, 200, 300, 400 500, 500 750, 1000, 2000 ] ],
[ 500200, [ 100 200, 250 300, 500, 750, 1000, 1500 2500, 2000 5000 ] ],
[ 1000 500, [ 500, 1000 750, 2000 1000, 2500, 3000 5000, 4000 7500, 500010000 ] ],
[ 1000, [ 1000, 2000, 3000, 4000, 5000, 7500, 10000 ] ],
[ 3000, [ 3000, 4000, 5000, 6000, 7500, 10000, 12000 ] ]
],
'midtier2018'"FY2425_E1_T14_EUR" : [ // Upgrade recurring amount dynamically
[ 0, [ 32.50, 5, 10, 20, 30 25, 50 35, 100 50 ] ],
[ 5, [ 2.50, 5, 10, 20, 35 25, 50, 10035, 150 50 ] ],
[ 10, [ 2.50, 10, 15, 20, 35 25, 50, 10035, 150 50 ] ],
[ 15, [ 152.50, 20 10, 25 20, 35 30, 50, 100 75, 150100 ] ],
[ 20, [ 3.50, 2010, 25, 35, 50, 75, 100, 150100 ] ],
[ 25, [ 4.25, 35 10, 50 25, 75 35, 100, 15050, 250 75, 500100 ] ],
[ 35, [ 6.25, 50 15, 75 30, 100, 15050, 250 75, 350 100, 500150 ] ],
[ 5075, [ 7515, 100 50, 150 75, 200 100, 250 200, 350 300, 500 ] ],
[ 75100, [ 100 25, 150 50, 200 75, 300 100, 400 200, 500 300, 1000 500 ] ],
[ 100150, [ 150 45, 200 100, 250 150, 300 250, 400 500, 500 750, 1000 ] ],
[ 150200, [ 200 50, 250 100, 300 150, 400 250, 500, 1000 750, 25001000 ] ],
[ 200500, [ 500150, 750 250, 1000 300, 2000 500, 3500 750, 5000 1000, 75002000 ] ],
[ 1000, [ 250, 500, [ 750, 1000, 1500, 2500, 5000, 75005000, 10000 ] ],
[ 10003000, [ 500, 1000, 2000, 3000, 40003500, 5000, 7500, 10000 ] ]
],
'LT2018'"FY2425_E1_T21_EUR" : [ // Give less reactivation amount
[ 0, [ 2.50, 5, 10, 20.18, 25, 35, 50, 100 ] ],
[ 5, [ 2.50, 10 5, 15 10, 20.18, 35 25, 50 35, 100, 15050 ] ],
[ 10, [ 15 5, 20.18 10, 25 15, 35 20, 50 35, 100 50, 150 100 ] ],
[ 15, [ 20.18 10, 25 15, 35 20, 50 25, 75 35, 100 50, 250 100 ] ],
[ 20, [ 25 15, 35 20, 50 25, 75 35, 100 50, 150 75, 250 100 ] ],
[ 25, [ 30 20, 40 25, 35, 50, 75, 100, 150, 250150 ] ],
[ 35, [ 25, 50 30, 75 40, 100 50, 200 75, 250 100, 300 150 ] ],
[ 75, [ 25 35, 50, 75, 100, 200, 300, 500 ] ],
[ 100, [ 25, 5075, 100, 150, 250, 500, 750, 1000 ] ],
[ 150, [ 50, 100, 150, 200 250, 350 500, 500 750, 1000, 2500 ] ],
[ 200, [ 100, 150, 200, 300, 400 500, 500 750, 1000, 2000 ] ],
[ 500, [ 100 200, 250 300, 500, 750, 1000, 1500 2500, 2018 5000 ] ],
[ 1000, [ 500, 1000 750, 2018 1000, 2500, 3000 5000, 4000 7500, 500010000 ] ],
[ 3000, [ 1000, 2000, 3000, 4000, 5000, 7500, 10000 ] ]
]
},
'JPY'"GBP" : [{
"default" : [
[ 0, [ 2, 5, 10, 20, 25, 35, 50 ] ],
[ 5, [ 5, 10, 15, 20, 35, 50, 100 ] ],
[ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ],
[ 15, [ 15, 20, 25, 35, 50, 75, 100 ] ],
[ 20, [ 20, 25, 35, 50, 75, 100, 150 ] ],
[ 25, [ 25, 30, 40, 50, 75, 100, 150 ] ],
[ 35, [ 35, 50, 75, 100, 200, 300, 500 ] ],
[ 50, [ 50, 75, 100, 200, 300, 500, 750 ] ],
[ 75, [ 75, 100, 150, 250, 500, 750, 1000 ] ],
[ 100, [ 100, 150, 250, 500, 750, 1000, 2500 ] ],
[ 150, [ 150, 200, 300, 500, 750, 1000, 2000 ] ],
[ 200, [ 200, 300, 500, 750, 1000, 2500, 5000 ] ],
[ 500, [ 500, 750, 1000, 2500, 5000, 7500, 10000 ] ],
[ 1000, [ 1000, 2000, 3000, 4000, 5000, 7500, 10000 ] ],
[ 3000, [ 3000, 4000, 5000, 6000, 7500, 10000, 12000 ] ]
],
"FY2425_E1_T11_GBP" : [ // Upgrade recurring +1 for lowest ask
[ 0, [ 3, 5, 10, 20, 25, 35, 50 ] ],
[ 5, [ 5, 10, 15, 20, 35, 50, 100 ] ],
[ 10, [ 10, 15, 20, 25, 35, 50, 100 ] ],
[ 15, [ 15, 20, 25, 35, 50, 75, 100 ] ],
[ 20, [ 20, 25, 35, 50, 75, 100, 150 ] ],
[ 25, [ 25, 30, 40, 50, 75, 100, 150 ] ],
[ 35, [ 35, 50, 75, 100, 200, 300, 500 ] ],
[ 50, [ 50, 75, 100, 200, 300, 500, 750 ] ],
[ 75, [ 75, 100, 150, 250, 500, 750, 1000 ] ],
[ 100, [ 100, 150, 250, 500, 750, 1000, 2500 ] ],
[ 150, [ 150, 200, 300, 500, 750, 1000, 2000 ] ],
[ 200, [ 200, 300, 500, 750, 1000, 2500, 5000 ] ],
[ 500, [ 500, 750, 1000, 2500, 5000, 7500, 10000 ] ],
[ 1000, [ 1000, 2000, 3000, 4000, 5000, 7500, 10000 ] ],
[ 3000, [ 3000, 4000, 5000, 6000, 7500, 10000, 12000 ] ]
],
"FY2425_E1_T14_GBP" : [ // Upgrade recurring amount dynamically
[ 0, [ 2, 5, 10, 20, 25, 35, 50 ] ],
[ 5, [ 2, 5, 10, 20, 25, 35, 50 ] ],
[ 10, [ 2, 10, 15, 20, 25, 35, 50 ] ],
[ 15, [ 2, 10, 20, 30, 50, 75, 100 ] ],
[ 20, [ 3, 10, 25, 35, 50, 75, 100 ] ],
[ 25, [ 4, 10, 25, 35, 50, 75, 100 ] ],
[ 35, [ 6, 15, 30, 50, 75, 100, 150 ] ],
[ 75, [ 15, 50, 75, 100, 200, 300, 500 ] ],
[ 100, [ 20, 50, 75, 100, 200, 300, 500 ] ],
[ 150, [ 40, 100, 150, 250, 500, 750, 1000 ] ],
[ 200, [ 45, 100, 150, 250, 500, 750, 1000 ] ],
[ 500, [ 125, 250, 300, 500, 750, 1000, 2000 ] ],
[ 1000, [ 200, 500, 750, 1000, 2500, 5000, 10000 ] ],
[ 3000, [ 400, 1000, 2000, 3500, 5000, 7500, 10000 ] ]
],
"FY2425_E1_T21_GBP" : [ // Give less reactivation amount
[ 0, [ 2, 5, 10, 20, 25, 35, 50 ] ],
[ 5, [ 2, 5, 10, 20, 25, 35, 50 ] ],
[ 10, [ 5, 10, 15, 20, 35, 50, 100 ] ],
[ 15, [ 10, 15, 20, 25, 35, 50, 100 ] ],
[ 20, [ 15, 20, 25, 35, 50, 75, 100 ] ],
[ 25, [ 20, 25, 35, 50, 75, 100, 150 ] ],
[ 35, [ 25, 30, 40, 50, 75, 100, 150 ] ],
[ 75, [ 35, 50, 75, 100, 200, 300, 500 ] ],
[ 100, [ 75, 100, 150, 250, 500, 750, 1000 ] ],
[ 150, [ 100, 150, 250, 500, 750, 1000, 2500 ] ],
[ 200, [ 150, 200, 300, 500, 750, 1000, 2000 ] ],
[ 500, [ 200, 300, 500, 750, 1000, 2500, 5000 ] ],
[ 1000, [ 500, 750, 1000, 2500, 5000, 7500, 10000 ] ],
[ 3000, [ 1000, 2000, 3000, 4000, 5000, 7500, 10000 ] ]
]
},
"JPY" : [
[ 0, [ 500, 1000, 2000, 2500, 4000, 5000, 10000 ] ],
[ 1000, [ 1000, 1500, 2500, 4000, 5000, 10000, 15000 ] ],
Line 453 ⟶ 565:
[ 10000, [ 10000, 25000, 50000, 75000, 100000, 150000, 200000 ] ]
],
'"SEK'" : [
[ 0, [ 2030, 50100, 100150, 200, 300500, 500750, 1000 ] ],
[ 3050, [ 30, 50, 100, 150, 200, 300, 500750, 1000 ] ],
[ 50, [ 50, 100, 150, 200, 300, 500, 1000 ] ],
[ 200, [ 50, 100, 200, 300, 500, 750, 1000 ] ]
]
Line 462 ⟶ 573:
radioAmountsData.AUD = radioAmountsData.USD;
radioAmountsData.CAD = radioAmountsData.USD;
radioAmountsData.GBP = radioAmountsData.USD;
radioAmountsData.NZD = radioAmountsData.USD;
 
radioAmountsData.EUR = 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++ ) {
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 ] ] ];
}
 
var appealAmountsData = {
'"USD'" : [ // also used for CAD, AUD, NZD, GBP, EUR
[ 0, [ 5, 10, 20 ] ],
[ 10, [ 10, 20, 50 ] ],
Line 478 ⟶ 594:
[ 200, [ 100, 200, 300 ] ]
],
'"JPY'" : [
[ 0, [ 300, 500, 1000 ] ],
[ 3, [ 500, 1000, 1500 ] ],
Line 487 ⟶ 603:
[ 100, [ 5000, 10000, 15000 ] ]
],
'"SEK'" : [
[ 0, [ 20, 50, 100 ] ],
[ 3, [ 30, 50, 100 ] ],
Line 503 ⟶ 619:
appealAmountsData.NZD = appealAmountsData.USD;
appealAmountsData.EUR = appealAmountsData.USD;
 
var formats = {
"USD" : "$\t",
"EUR" : {
"en" : "€\t",
"cy" : "€\t",
"ga" : "€\t",
"mt" : "€\t",
"nl" : "€ \t",
"lv" : "€ \t",
"tr" : "€ \t",
"default" : "\t €"
},
"AUD" : "$\t",
"CAD" : {
"fr" : "\t $",
"default" : "$\t"
},
"GBP" : "£\t",
"NZD" : "$\t",
"JPY" : "¥\t",
"SEK" : "\t kr",
"BRL" : "R$\t"
};
 
var format = formats[currency][language] || formats[currency]['default'] || formats[currency] || '\t';
 
// Radio button amounts
Line 538 ⟶ 628:
var $label = $("label[for='input_amount_" + j + "']");
$radio.val( radioAmounts[j] );
$label.text( formatdonationForm.replaceformatCurrency('\t', radioAmounts[j] ) );
}
}
Line 545 ⟶ 635:
var appealAmounts = pickAmountArray( appealAmountsData, currency, hpc, hpcSet );
if ( appealAmounts.length ) {
var appealAmountString = appealAmounts.map( donationForm.formatCurrency ).join( ', ');
// Build string
var appealAmountString = '';
for( var k = 0; k < appealAmounts.length; k++ ) {
appealAmountString += format.replace('\t', appealAmounts[k]) + ', ';
}
appealAmountString = appealAmountString.trim();
 
$('.consider-amounts').html(appealAmountString);
}
Line 600 ⟶ 684:
/* Check for a 'preSelect' url parameter, and select that option.
If there isn't an option, add it to the "Other" box and select that */
var preSelectAmount = parseFloat( mw.util.getParamValue('preSelect') );
if ( preSelectAmount > 0 ) {
var $preSelectOption = $('input[name="amount"][value="' + preSelectAmount + '"]');
Line 639 ⟶ 723:
'PT' : 'vmaj',
'SK' : 'vmaj',
'GR' : 'vma',
// Others
'CZ' : 'vmad',
'DK' : 'vma',
'HU' : 'vma',
Line 650 ⟶ 736:
'SE' : 'vma',
'UA' : 'vma', // Adyen
'ZA' : 'vm',
'ZZ' : 'vmad' // For testing
};
if ( cardTypes[country] ) {
$('.paymentmethod-cc').addClass('cctypes-' + cardTypes[country] );
$('.cc-text-label').addClass('sr-only');
}
}
Line 684 ⟶ 772:
 
var params = {};
 
params.currency = donationForm.currency;
params.country = donationForm.country;
 
// Overrides for specific cc gateways
Line 689 ⟶ 780:
params.payment_method = 'cc';
params.gateway = 'adyen';
params.ffname = 'adyen';
} else if ( paymentMethod === 'cc-dlocal' ) {
params.payment_method = 'cc';
Line 695 ⟶ 785:
} else {
params.payment_method = paymentMethod;
}
 
if ( params.payment_method === 'cc' && params.country === 'ZA' ) {
params.gateway = 'astropay';
}
 
Line 708 ⟶ 802:
}
 
params.currency_code = donationForm.currency;
params.country = donationForm.country;
params.uselang = mw.config.get('wgPageContentLanguage'); // see T281285 for why not wgUserLanguage
 
Line 735 ⟶ 827:
var opt_inValue = $('input[name="opt_in"]:checked').val();
params.opt_in = opt_inValue; // donationForm.validate() already checked it's 1 or 0
}
 
// Default to variant = panExplain for India
// TODO: make this default payments side - https://phabricator.wikimedia.org/T259146
if ( donationForm.country === 'IN' ) {
params.variant = 'panExplain';
}
 
Line 746 ⟶ 832:
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' );
}
 
// Check for monthlyMonthly convert. TODO: make it possible to test JS variants
if ( mc ) { // check just in-case this wasn't loaded for some reason
if ( mw.util.getParamValue( 'monthlyconvert' ) ) {
mc.main( params, donationForm.finalStep );
} else {
Line 770 ⟶ 862:
donationForm.finalStep = function( params ) {
 
var uri = new mw.Uri('https://payments.wikimedia.org/index.php/Special:GatewayFormChooserGatewayChooser');
 
// Skip form chooser for Apple Pay / Google Pay
if ( params.payment_method === 'apple' || params.payment_method === 'google' ) {
uri = new mw.Uri('https://payments.wikimedia.org/index.php/Special:AdyenCheckoutGateway');
}
 
// Skip form chooser for Venmo
if ( params.payment_method === 'venmo' ) {
uri = new mw.Uri('https://payments.wikimedia.org/index.php/Special:BraintreeGateway');
}
 
donationForm.extraData.time = Math.round( (Date.now() - donationForm.loadedTime)/1000 );
 
// Tracking data
params.utm_mediumwmf_medium = mw.util.getParamValue( 'wmf_medium' ) || mw.util.getParamValue( 'utm_medium' );
params.utm_campaignwmf_campaign = mw.util.getParamValue( 'wmf_campaign' ) || mw.util.getParamValue( 'utm_campaign' );
params.utm_sourcewmf_source = donationForm.buildUtmSourcebuildTrackingSource( params );
params.utm_keywmf_key = donationForm.buildUtmKeybuildTrackingKey( donationForm.extraData );
if ( document.referrer ) { // TODO: do we need this?
// Strip protocol to stop firewall complaining
Line 795 ⟶ 897:
 
/**
* Build a utm_sourcewmf_source value, including the landing page info.
*
* Own function so it can be overriden for weird tests
*
* @param {Object} params
* @return {string} utm_sourcewmf_source
*/
donationForm.buildUtmSourcebuildTrackingSource = function( params ) {
 
var utm_sourcewmf_source = mw.util.getParamValue( 'utm_sourcewmf_source' ) +|| 'mw.util.getParamValue( 'utm_source' );
wmf_source += '.';
 
var fullDottedPaymentMethod = params.payment_method;
Line 824 ⟶ 927:
 
/* The landing page info, separated by ~. This mostly exists for legacy reasons */
utm_sourcewmf_source += getParam( 'template' , 'Lp-layout' , 'default' ) + '~';
utm_sourcewmf_source += getParam( 'appeal-template' , 'Appeal-template-' , 'default' ) + '~';
utm_sourcewmf_source += getParam( 'appeal' , 'Appeal-' , 'default' ) + '~';
utm_sourcewmf_source += getParam( 'form-template' , 'Form-template-' , 'default' ) + '~';
utm_sourcewmf_source += getParam( 'form-countryspecific', 'Form-countryspecific-', 'control' );
 
utm_sourcewmf_source += '.' + fullDottedPaymentMethod;
 
return utm_sourcewmf_source;
 
};
 
/**
* Build a string for utm_keywmf_key from extra tracking data
*
* @param {Object} data
* @return {string} utm_keywmf_key
*/
donationForm.buildUtmKeybuildTrackingKey = function(data) {
var existingUtmKeyexistingKey = mw.util.getParamValue( 'wmf_key' ) || mw.util.getParamValue( 'utm_key' ),
dataArray = [];
 
if ( existingUtmKeyexistingKey ) {
dataArray.push( existingUtmKeyexistingKey );
}
for (var key in data) {
Line 859 ⟶ 962:
/* Return amount selected or input */
donationForm.getAmount = function() {
var form = document.forms['.donateForm'],
amount = null;
donationForm.extraData.otherAmt = 0;
Line 912 ⟶ 1,015:
 
var error = false;
var form = document.forms['.donateForm'];
 
// Reset all errors
Line 941 ⟶ 1,044:
 
var amount = donationForm.getAmount();
var minAmount = donationForm.minimums[ donationForm.currency ] || 1;
 
if ( amount === null || isNaN(amount) || amount <= 0 || amount < minAmountdonationForm.minLocal ) {
$('.amount-options').addClass('lp-haserror');
$('.lp-error-bigamount').hide();
$('.lp-error-smallamount').show();
return false;
} else if ( amount > donationForm.maxUSD * minAmountmaxLocal ) {
$('.amount-options').addClass('lp-haserror');
$('.lp-error-bigamount').show();
Line 971 ⟶ 1,073:
var selectedAmount = donationForm.getAmount(),
feeAmount = donationForm.calculateFee( selectedAmount ),
minAmount = donationForm.minimums[ donationForm.currency ] || 1,
maxAmount = donationForm.maxUSD * minAmount,
feeText;
 
iffeeText = donationForm.formatCurrency( feeAmount % 1 !== 0 ) { // Not a whole number;
feeText = feeAmount.toFixed(2);
} else {
feeText = feeAmount.toString();
}
 
$('.ptf label span').text( feeText );
if ( selectedAmount + feeAmount <= maxAmountdonationForm.maxLocal ) {
$('.ptf').slideDown();
}
Line 1,000 ⟶ 1,096:
'HUF' : 100,
'ILS' : 1.2,
'INR' : 254,
'JPY' : 35,
'MYR' : 1,
'NOK' : 3,
'PLN' : 1.35,
'CZK' : 7.5,
'RON' : 1.5,
'SEK' : 3,
'UAH' : 10,
'ZAR' : 5,
// Latin America // Updated 2024-08-22 to approx 0.35 USD equivalent
'BRL' : 21.75,
'ARS' : 32300,
'CLP' : 255300,
'COP' : 13001400,
'MXN' : 7.46,
'PEN' : 1.32,
'UYU' : 15.514
};
 
Line 1,075 ⟶ 1,172:
 
/**
* Should we show Apple Pay?
* Make language and country into a standard javascript Intl locale identifier
*
* Note there is a ~500ms delay in Safari when checking, so only call this if needed
*
* Currently only used in monthlyconvert, but this could be useful
*
* @param {string} language
* @param {string} country
* @return {stringboolean} locale identifier
*/
donationForm.getLocaleshouldShowApplePay = function( language,( country ) {
if ( language === location.search.match('en-gbforceApplePay') ) {
languagereturn = 'en'true;
}
if ( language === 'es-419'window.ApplePaySession ) {
if ( ApplePaySession.canMakePayments() ) {
language = 'es';
return true;
}
if ( language === 'pt-br' ) {}
language = 'pt';
}
return language + '-' + countryfalse;
};
 
/*
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 */
Line 1,103 ⟶ 1,371:
mw.loader.using( ['mediawiki.util'] ).done( function() {
 
var form = document.forms['.donateForm'];
 
// TheseMinimum getamount usedis inusually quiteabout a1 few placesUSD
donationForm.currencyminLocal = formdonationForm.currency_codecurrencyRates[ donationForm.valuecurrency ];
donationForm.countryminLocal = mwMath.util.getParamValueceil('country' 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
Line 1,140 ⟶ 1,418:
$('.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();
}
 
// 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();
}
}
}
 
Line 1,158 ⟶ 1,470:
 
// Allow preselecting monthly
if (
mw.util.getParamValue('monthly')
&& mw.util.getParamValue('monthly') !== '0'
&& donationForm.noRecurringCountries.indexOf( donationForm.country ) === -1 ) {
&& donationForm.noRecurringCountries.indexOf( donationForm.country ) === -1
&& mw.util.getParamValue('utm_medium') !== 'endowment'
&& mw.util.getParamValue('wmf_medium') !== 'endowment'
) {
$('#frequency_monthly').click();
}
Line 1,171 ⟶ 1,488:
}
finally {
$('.frb-monthly-pitch, .frb-monthly-pitch-thanks').appendTo('.frequency-options');
$('.ptf').appendTo('.amount-options');
$('.optin-options').insertAfter('.amount-options');