Donate donatewiki https://donate.wikimedia.org/wiki/Special:FundraiserRedirector MediaWiki 1.47.0-wmf.18 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 Template:2012FR/Form-section/Radiobuttons/Default 10 3493 43094 42658 2026-09-03T19:02:55Z Pcoombe 5 remove selectAmount and selectOther 43094 wikitext text/x-wiki <html> <input type="hidden" name="currency_code" value="</html>{{{currency|{{CurrencyCode|{{{country}}}}}}}}<html>"/> <div id="radiobuttons-table-header"> </html>{{int:donate_interface-amount-legend}} ({{{currency|{{CurrencyCode|{{{country}}}}}}}})<html> </div> <fieldset class="frequency-options"> <legend class="sr-only"> How often would you like to donate? </legend> <ul> <li> <input type="radio" name="frequency" id="frequency_onetime" value="onetime" onclick="donationForm.setFrequency('onetime');" checked> <label class="frb-btn" for="frequency_onetime"></html>{{int:Frequency-Once}}<html></label> </li> <li> <input type="radio" name="frequency" id="frequency_monthly" value="monthly" onclick="donationForm.setFrequency('monthly');"> <label class="frb-btn" for="frequency_monthly"></html>{{int:Frequency-Monthly}}<html></label> </li> <li style="display: none;"> <input type="radio" name="frequency" id="frequency_annual" value="annual" onclick="donationForm.setFrequency('annual');"> <label class="frb-btn" for="frequency_annual"></html>{{int:Frequency-Annual}}<html></label> </li> </ul> </fieldset> <fieldset class="amount-options"> <legend class="sr-only"> </html>{{int:donate_interface-amount-legend}} ({{{currency|{{CurrencyCode|{{{country}}}}}}}})<html> </legend> <ul> <li class="radiobuttons-cell input_amount_0"> <input type="radio" name="amount" id="input_amount_0" value="</html>{{{donate-amount-0}}}<html>" /> <label class="frb-btn" for="input_amount_0"></html>{{CurrencyFormat|{{{donate-amount-0}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_1"> <input type="radio" name="amount" id="input_amount_1" value="</html>{{{donate-amount-1}}}<html>" /> <label class="frb-btn" for="input_amount_1"></html>{{CurrencyFormat|{{{donate-amount-1}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_2"> <input type="radio" name="amount" id="input_amount_2" value="</html>{{{donate-amount-2}}}<html>" /> <label class="frb-btn" for="input_amount_2"></html>{{CurrencyFormat|{{{donate-amount-2}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_3"> <input type="radio" name="amount" id="input_amount_3" value="</html>{{{donate-amount-3}}}<html>" /> <label class="frb-btn" for="input_amount_3"></html>{{CurrencyFormat|{{{donate-amount-3}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_4"> <input type="radio" name="amount" id="input_amount_4" value="</html>{{{donate-amount-4}}}<html>" /> <label class="frb-btn" for="input_amount_4"></html>{{CurrencyFormat|{{{donate-amount-4}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_5"> <input type="radio" name="amount" id="input_amount_5" value="</html>{{{donate-amount-5}}}<html>" /> <label class="frb-btn" for="input_amount_5"></html>{{CurrencyFormat|{{{donate-amount-5}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_6"> <input type="radio" name="amount" id="input_amount_6" value="</html>{{{donate-amount-6}}}<html>" /> <label class="frb-btn" for="input_amount_6"></html>{{CurrencyFormat|{{{donate-amount-6}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_other"> <input type="radio" name="amount" id="input_amount_other" value="Other" onclick="document.getElementById('input_amount_other_box').focus();"> <label class="frb-btn" for="input_amount_other"> <span></html>{{int:donate_interface-other}}<html></span> <input id="input_amount_other_box" type="text" inputmode="decimal" autocomplete="off" value="" tabindex="-1" class="noime"> </label> </li> </ul> <!-- tabindex="-1" allows focus with js so errors can be announced --> <div style="display: none;" tabindex="-1" class="lp-error lp-error-smallamount"> </html>{{int:Donate_interface-smallamount-error}}<html> </div> <div style="display: none;" tabindex="-1" class="lp-error lp-error-bigamount"> </html>{{int:Donate_interface-bigamount-error}}<html> </div> </fieldset> </html> qzwnad1o76xygvynw7tkkdsstcwz951 MediaWiki:Common.js 8 4162 43102 43050 2026-09-03T20:48:51Z Pcoombe 5 delete amountOptions parameter if changing country 43102 javascript text/javascript /** * MediaWiki:Common.js - Any JavaScript here will be loaded for all users on every page load. **/ $(function() { mw.loader.using( ['mediawiki.util'] ).done( function() { // If Jimmy tweets a bare link to https://donate.wikimedia.org/w/index.php?title=Special:LandingPage // we are gonna have a bad time as geolocation doesn't happen. Do a redirect to send them round again try { var url = new URL( location.href ); if ( url.searchParams.get( 'title' ) === 'Special:LandingPage' && url.searchParams.get( 'country' ) === null && url.searchParams.get( 'retried' ) === null ) { console.log( 'redirecting to pick up country parameter' ); url.pathname = '/'; url.searchParams.set( 'retried', 1 ); // only do this once url.searchParams.delete( 'title' ); window.location.href = url.toString(); } } catch (error) { console.warn('Error parsing URL. Possibly due to unreplaced % signs?'); } // Disable logo link let logoElement = document.querySelector('#p-logo a'); if ( logoElement ) { logoElement.removeAttribute('href'); logoElement.removeAttribute('title'); } // Code for donation forms - https://donate.wikimedia.org/wiki/MediaWiki:DonationForm.js if ( document.forms['donateForm'] ) { var formJS = mw.util.getParamValue( 'formJS' ); if ( formJS && formJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) { mw.loader.load( '/w/index.php?title=' + formJS + '&action=raw&ctype=text/javascript' ); } else { mw.loader.load( '/w/index.php?title=MediaWiki:DonationForm.js&action=raw&ctype=text/javascript' ); } // Load monthly convert JS // TODO: allow loading different JS variants, either here or defined in the Template mw.loader.load( '/w/index.php?title=MediaWiki:MonthlyConvert.js&action=raw&ctype=text/javascript' ); } // Allow manual country selection and reload // Run this only when needed var enableCountrySelect = function() { var language = mw.config.get('wgPageContentLanguage'), countrySelect = document.getElementById('country-select'); // Translations if ( language !== 'en' && language !== 'en-gb' ) { const translationsUrl = 'https://donate.wikimedia.org/wiki/Module:Country_links/data.json?action=raw'; $.getJSON( translationsUrl, function( translations ) { if ( translations[language] ) { var list = Array.from( countrySelect.options ); list.forEach( option => { option.innerText = translations[language][option.value] || option.innerText; }); // Sort for new language list.sort( function(a, b) { return a.innerText.localeCompare( b.innerText ); }); for ( var i = 0; i < list.length; i++ ) { list[i].parentNode.appendChild( list[i] ); } } }); } document.getElementById('country-select-go').addEventListener( 'click', function(e) { if ( countrySelect.value ) { // Chapter countries, use the built-in donatewiki redirects if ( countrySelect.value === 'DE' ) { window.location = 'https://donate.wikimedia.org/?country=DE'; } else if ( countrySelect.value === 'CH' ) { window.location = 'https://donate.wikimedia.org/?country=CH'; } else { var url = new URL( location.href ); url.searchParams.set( 'country', countrySelect.value ); url.searchParams.delete( 'preSelect' ); url.searchParams.delete( 'hpc' ); url.searchParams.delete( 'amountOptions' ); window.location = url.toString(); } } }); }; if ( document.getElementById('country-change') ) { document.getElementById('country-change').addEventListener( 'click', function(e) { document.getElementById('country-change-select').style.display = 'block'; enableCountrySelect(); }); } if ( document.getElementById('geolocate-error') ) { enableCountrySelect(); } /** * @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL * @rev 6 */ var extraCSS = mw.util.getParamValue( 'withCSS' ), extraJS = mw.util.getParamValue( 'withJS' ); if ( extraCSS ) { if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) { mw.loader.load( '/w/index.php?title=' + extraCSS + '&action=raw&ctype=text/css', 'text/css' ); } else { mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } ); } } if ( extraJS ) { if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) { mw.loader.load( '/w/index.php?title=' + extraJS + '&action=raw&ctype=text/javascript' ); } else { mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } ); } } } ); }); 1y76v1rsngbsqj4u5q01jemju93az7f Template:2012FR/Form-section/Radiobuttons/5-buttons 10 5367 43098 43074 2026-09-03T19:06:20Z Pcoombe 5 remove selectAmount and selectOther 43098 wikitext text/x-wiki <html> <input type="hidden" name="currency_code" value="</html>{{{currency|{{CurrencyCode|{{{country}}}}}}}}<html>"/> <div> <div id="radiobuttons-table-header"> </html>{{int:donate_interface-amount-legend}}{{#ifeq: {{{currencynote|}}}|||&nbsp;{{{currencynote|}}}}}<html>: </div> </div> <fieldset class="amount-options"> <ul> <li class="radiobuttons-cell input_amount_0"> <input type="radio" name="amount" id="input_amount_0" value="</html>{{{donate-amount-0}}}<html>" /> <label class="frb-btn" for="input_amount_0"></html>{{CurrencyFormat|{{{donate-amount-0}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_1"> <input type="radio" name="amount" id="input_amount_1" value="</html>{{{donate-amount-1}}}<html>" /> <label class="frb-btn" for="input_amount_1"></html>{{CurrencyFormat|{{{donate-amount-1}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_2"> <input type="radio" name="amount" id="input_amount_2" value="</html>{{{donate-amount-2}}}<html>" /> <label class="frb-btn" for="input_amount_2"></html>{{CurrencyFormat|{{{donate-amount-2}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_3"> <input type="radio" name="amount" id="input_amount_3" value="</html>{{{donate-amount-3}}}<html>" /> <label class="frb-btn" for="input_amount_3"></html>{{CurrencyFormat|{{{donate-amount-3}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_4"> <input type="radio" name="amount" id="input_amount_4" value="</html>{{{donate-amount-4}}}<html>" /> <label class="frb-btn" for="input_amount_4"></html>{{CurrencyFormat|{{{donate-amount-4}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_other"> <input type="radio" name="amount" id="input_amount_other" value="Other" onclick="document.getElementById('input_amount_other_box').focus();"> <label class="frb-btn" for="input_amount_other"> <span></html>{{int:donate_interface-other}}<html></span> <input type="number" min="0" id="input_amount_other_box" size="3" autocomplete="off" value="" tabindex="-1"> </label> </li> </ul> <div style="display: none;" class="lp-error lp-error-smallamount"></html>{{int:Donate_interface-smallamount-error}}<html></div> <div style="display: none;" class="lp-error lp-error-bigamount"></html>{{int:Donate_interface-bigamount-error}}<html></div> </fieldset> </html> r3774e0o0k205zcc5y5gprihb4evr4r Template:2012FR/Form-section/Radiobuttons/3-3-1 10 6885 43096 39730 2026-09-03T19:05:34Z Pcoombe 5 remove selectAmount and selectOther 43096 wikitext text/x-wiki <html> <input type="hidden" name="currency_code" value="</html>{{{currency|{{CurrencyCode|{{{country}}}}}}}}<html>"/> <div id="radiobuttons-table-header"> </html>{{int:donate_interface-amount-legend}} ({{{currency|{{CurrencyCode|{{{country}}}}}}}})<html> </div> <fieldset class="frequency-options"> <ul> <li> <input type="radio" name="frequency" id="frequency_onetime" value="onetime" onclick="donationForm.toggleMonthly(false);" checked> <label class="frb-btn" for="frequency_onetime"></html>{{int:donate_interface-onetime-short}}<html></label> </li> <li> <input type="radio" name="frequency" id="frequency_monthly" value="monthly" onclick="donationForm.toggleMonthly(true);"> <label class="frb-btn" for="frequency_monthly"></html>{{int:donate_interface-monthly-short}}<html></label> </li> </ul> </fieldset> <fieldset class="amount-options"> <ul> <li class="radiobuttons-cell input_amount_0"> <input type="radio" name="amount" id="input_amount_0" value="</html>{{{donate-amount-0}}}<html>" /> <label class="frb-btn" for="input_amount_0"></html>{{CurrencyFormat|{{{donate-amount-0}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_1"> <input type="radio" name="amount" id="input_amount_1" value="</html>{{{donate-amount-1}}}<html>" /> <label class="frb-btn" for="input_amount_1"></html>{{CurrencyFormat|{{{donate-amount-1}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_2"> <input type="radio" name="amount" id="input_amount_2" value="</html>{{{donate-amount-2}}}<html>" /> <label class="frb-btn" for="input_amount_2"></html>{{CurrencyFormat|{{{donate-amount-2}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_3"> <input type="radio" name="amount" id="input_amount_3" value="</html>{{{donate-amount-3}}}<html>" /> <label class="frb-btn" for="input_amount_3"></html>{{CurrencyFormat|{{{donate-amount-3}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_4"> <input type="radio" name="amount" id="input_amount_4" value="</html>{{{donate-amount-4}}}<html>" /> <label class="frb-btn" for="input_amount_4"></html>{{CurrencyFormat|{{{donate-amount-4}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_5"> <input type="radio" name="amount" id="input_amount_5" value="</html>{{{donate-amount-5}}}<html>" /> <label class="frb-btn" for="input_amount_5"></html>{{CurrencyFormat|{{{donate-amount-5}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_other"> <input type="radio" name="amount" id="input_amount_other" value="Other" onclick="document.getElementById('input_amount_other_box').focus();"> <label class="frb-btn" for="input_amount_other"> <span>Other amount</span> <input type="number" min="0" id="input_amount_other_box" size="3" autocomplete="off" value="" tabindex="-1"> </label> </li> </ul> <div style="display: none;" class="lp-error lp-error-smallamount"></html>{{int:Donate_interface-smallamount-error}}<html></div> <div style="display: none;" class="lp-error lp-error-bigamount"></html>{{int:Donate_interface-bigamount-error}}<html></div> </fieldset> <style> .amount-options ul { grid-template-columns: 1fr 1fr 1fr !important; } .input_amount_other { grid-column: span 3; } </style> </html> 3e6fa6x2hmrak50xxrgtqufcqrcvtsp Template:2012FR/Form-section/Radiobuttons/3-3-2 10 6887 43095 39732 2026-09-03T19:05:31Z Pcoombe 5 remove selectAmount and selectOther 43095 wikitext text/x-wiki <html> <input type="hidden" name="currency_code" value="</html>{{{currency|{{CurrencyCode|{{{country}}}}}}}}<html>"/> <div id="radiobuttons-table-header"> </html>{{int:donate_interface-amount-legend}} ({{{currency|{{CurrencyCode|{{{country}}}}}}}})<html> </div> <fieldset class="frequency-options"> <ul> <li> <input type="radio" name="frequency" id="frequency_onetime" value="onetime" onclick="donationForm.toggleMonthly(false);" checked> <label class="frb-btn" for="frequency_onetime"></html>{{int:donate_interface-onetime-short}}<html></label> </li> <li> <input type="radio" name="frequency" id="frequency_monthly" value="monthly" onclick="donationForm.toggleMonthly(true);"> <label class="frb-btn" for="frequency_monthly"></html>{{int:donate_interface-monthly-short}}<html></label> </li> </ul> </fieldset> <fieldset class="amount-options"> <ul> <li class="radiobuttons-cell input_amount_0"> <input type="radio" name="amount" id="input_amount_0" value="</html>{{{donate-amount-0}}}<html>" /> <label class="frb-btn" for="input_amount_0"></html>{{CurrencyFormat|{{{donate-amount-0}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_1"> <input type="radio" name="amount" id="input_amount_1" value="</html>{{{donate-amount-1}}}<html>" /> <label class="frb-btn" for="input_amount_1"></html>{{CurrencyFormat|{{{donate-amount-1}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_2"> <input type="radio" name="amount" id="input_amount_2" value="</html>{{{donate-amount-2}}}<html>" /> <label class="frb-btn" for="input_amount_2"></html>{{CurrencyFormat|{{{donate-amount-2}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_3"> <input type="radio" name="amount" id="input_amount_3" value="</html>{{{donate-amount-3}}}<html>" /> <label class="frb-btn" for="input_amount_3"></html>{{CurrencyFormat|{{{donate-amount-3}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_4"> <input type="radio" name="amount" id="input_amount_4" value="</html>{{{donate-amount-4}}}<html>" /> <label class="frb-btn" for="input_amount_4"></html>{{CurrencyFormat|{{{donate-amount-4}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_5"> <input type="radio" name="amount" id="input_amount_5" value="</html>{{{donate-amount-5}}}<html>" /> <label class="frb-btn" for="input_amount_5"></html>{{CurrencyFormat|{{{donate-amount-5}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_6"> <input type="radio" name="amount" id="input_amount_6" value="</html>{{{donate-amount-6}}}<html>" /> <label class="frb-btn" for="input_amount_6"></html>{{CurrencyFormat|{{{donate-amount-6}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_other"> <input type="radio" name="amount" id="input_amount_other" value="Other" onclick="document.getElementById('input_amount_other_box').focus();"> <label class="frb-btn" for="input_amount_other"> <span>Other amount</span> <input type="number" min="0" id="input_amount_other_box" size="3" autocomplete="off" value="" tabindex="-1"> </label> </li> </ul> <div style="display: none;" class="lp-error lp-error-smallamount"></html>{{int:Donate_interface-smallamount-error}}<html></div> <div style="display: none;" class="lp-error lp-error-bigamount"></html>{{int:Donate_interface-bigamount-error}}<html></div> </fieldset> <style> .amount-options ul { grid-template-columns: 1fr 1fr 1fr !important; } .input_amount_other { grid-column: span 2; } </style> </html> nzabh7bphptj5yjxpa0brwpt1xczjvl MediaWiki:DonationForm.js 8 7993 43093 43073 2026-09-03T19:00:56Z Pcoombe 5 updates from sandbox: amountOptions parameter, amount button functions cleanup, spacing cleanup 43093 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 ] ] ], "MinPlus5-75" : [ [ 0, [ 5.75, 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 ] ] ], "MVP" : [ [ 0, [ 250, 450, 750, 1000, 1500, 2000, 5000 ] ], [ 350, [ 350, 600, 800, 1200, 1500, 2000, 5000 ] ], [ 450, [ 450, 750, 950, 1300, 1750, 2500, 5000 ] ], [ 550, [ 550, 850, 1000, 1500, 2000, 2500, 5000 ] ], [ 650, [ 650, 950, 1200, 1750, 2500, 5000, 10000 ] ], [ 750, [ 750, 1000, 1500, 2000, 3000, 5000, 10000 ] ], [ 850, [ 850, 1200, 1500, 2500, 5000, 7500, 10000 ] ], [ 950, [ 950, 1200, 1500, 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 ] ] ], "MinPlus5-75" : [ [ 0, [ 5.75, 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 ] ] ], "MVP" : [ [ 0, [ 250, 450, 750, 1000, 1500, 2000, 5000 ] ], [ 350, [ 350, 600, 800, 1200, 1500, 2000, 5000 ] ], [ 450, [ 450, 750, 950, 1300, 1750, 2500, 5000 ] ], [ 550, [ 550, 850, 1000, 1500, 2000, 2500, 5000 ] ], [ 650, [ 650, 950, 1200, 1750, 2500, 5000, 10000 ] ], [ 750, [ 750, 1000, 1500, 2000, 3000, 5000, 10000 ] ], [ 850, [ 850, 1200, 1500, 2500, 5000, 7500, 10000 ] ], [ 950, [ 950, 1200, 1500, 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 ] ] ], "MinPlus5-75" : [ [ 0, [ 5.75, 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 ] ] ], "MVP" : [ [ 0, [ 250, 450, 750, 1000, 1500, 2000, 5000 ] ], [ 350, [ 350, 600, 800, 1200, 1500, 2000, 5000 ] ], [ 450, [ 450, 750, 950, 1300, 1750, 2500, 5000 ] ], [ 550, [ 550, 850, 1000, 1500, 2000, 2500, 5000 ] ], [ 650, [ 650, 950, 1200, 1750, 2500, 5000, 10000 ] ], [ 750, [ 750, 1000, 1500, 2000, 3000, 5000, 10000 ] ], [ 850, [ 850, 1200, 1500, 2500, 5000, 7500, 10000 ] ], [ 950, [ 950, 1200, 1500, 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 // Will delete DM 2526 sets soon to cleanup. Waiting on OK from Megan Ritch (Panos). 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 ] ] ]; // FY2627 hpcSets // Direct Mail hpcSets radioAmountsData[ currencyList[i] ].DM_2627_15 = [ [ 0, [ 15, 25, 35, 50, 100, 200, 250 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2627_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2627_5000 = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; } 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'); } } /* -- 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' && [ 'AR', 'CL', 'CO', 'MX', 'PE', 'UY', 'US' ].includes(params.country) ) { 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' ); } // A/B test for SMS opt-in on payments form if ( params.country === 'US' && params.uselang === 'en' && mw.util.getParamValue( 'wmf_medium' ) === 'smsOptinTest' ) { if ( Math.random() < 0.5 ) { params.variant = 'smsOptin'; donationForm.extraData.smsOptinTest = 1; } else { donationForm.extraData.smsOptinTest = 0; } } // 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'); } // And Yape if ( params.payment_method === 'ew' && params.payment_submethod === 'yape' ) { 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; if ( form.frequency ) { 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., '.includes(chr) ) { 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', // for certain issues in email links 'en', 'en-ca', 'en-gb', 'en-us', 'ca', 'cs', 'da', 'de', 'el', 'es-419', 'es', 'fr', 'hu', 'it', 'ja', 'nb', 'nl', 'pl', 'pt-br', 'pt', 'sv', ]; 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 (let j = 0; j < newAmounts.length; j++) { let $radio = $( `#input_amount_${j}` ); let $label = $( `label[for="input_amount_${j}"]` ); $radio.val( newAmounts[j] ); $label.text( donationForm.formatCurrency( newAmounts[j] ) ); } // Remove any extra amount buttons if newAmounts has fewer than 7 elements for (let j = newAmounts.length; j < 7; j++) { let $option = $( `.input_amount_${j}` ); $option.remove(); } }; /** * 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; } // Clear the other amount input field when a preset amount is selected $('input[name="amount"][value!="Other"]').click( function() { $('#input_amount_other_box').val(''); }); // Select other amount radio button when the other amount input field is focused $('#input_amount_other_box').on('focus', function() { document.getElementById('input_amount_other').checked = true; }); // 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.includes( donationForm.country ) ) { $('#frequency_onetime').prop('checked', true); $('.frequency-options, #cancel-monthly, #donate-recurring-smallprint').hide(); } if ( donationForm.noRecurringPaypalCountries.includes( donationForm.country ) ) { $( '.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'); // 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.includes( donationForm.country ) && 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(); // amountOptions parameter should override other parameters let amountOptionsParam = mw.util.getParamValue( 'amountOptions' ); if ( amountOptionsParam ) { let amounts = amountOptionsParam.split(',').map( (x) => parseFloat(x) ); donationForm.setAmountOptions( amounts ); } // 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(); } }); }); o6ozvweh406agwubflicajw9cxz3o7v MediaWiki:DonationFormSandbox.js 8 8629 43076 41862 2026-09-03T16:48:53Z Pcoombe 5 update 43076 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 ] ] ], "MinPlus5-75" : [ [ 0, [ 5.75, 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 ] ] ], "MVP" : [ [ 0, [ 250, 450, 750, 1000, 1500, 2000, 5000 ] ], [ 350, [ 350, 600, 800, 1200, 1500, 2000, 5000 ] ], [ 450, [ 450, 750, 950, 1300, 1750, 2500, 5000 ] ], [ 550, [ 550, 850, 1000, 1500, 2000, 2500, 5000 ] ], [ 650, [ 650, 950, 1200, 1750, 2500, 5000, 10000 ] ], [ 750, [ 750, 1000, 1500, 2000, 3000, 5000, 10000 ] ], [ 850, [ 850, 1200, 1500, 2500, 5000, 7500, 10000 ] ], [ 950, [ 950, 1200, 1500, 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 ] ] ], "MinPlus5-75" : [ [ 0, [ 5.75, 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 ] ] ], "MVP" : [ [ 0, [ 250, 450, 750, 1000, 1500, 2000, 5000 ] ], [ 350, [ 350, 600, 800, 1200, 1500, 2000, 5000 ] ], [ 450, [ 450, 750, 950, 1300, 1750, 2500, 5000 ] ], [ 550, [ 550, 850, 1000, 1500, 2000, 2500, 5000 ] ], [ 650, [ 650, 950, 1200, 1750, 2500, 5000, 10000 ] ], [ 750, [ 750, 1000, 1500, 2000, 3000, 5000, 10000 ] ], [ 850, [ 850, 1200, 1500, 2500, 5000, 7500, 10000 ] ], [ 950, [ 950, 1200, 1500, 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 ] ] ], "MinPlus5-75" : [ [ 0, [ 5.75, 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 ] ] ], "MVP" : [ [ 0, [ 250, 450, 750, 1000, 1500, 2000, 5000 ] ], [ 350, [ 350, 600, 800, 1200, 1500, 2000, 5000 ] ], [ 450, [ 450, 750, 950, 1300, 1750, 2500, 5000 ] ], [ 550, [ 550, 850, 1000, 1500, 2000, 2500, 5000 ] ], [ 650, [ 650, 950, 1200, 1750, 2500, 5000, 10000 ] ], [ 750, [ 750, 1000, 1500, 2000, 3000, 5000, 10000 ] ], [ 850, [ 850, 1200, 1500, 2500, 5000, 7500, 10000 ] ], [ 950, [ 950, 1200, 1500, 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 // Will delete DM 2526 sets soon to cleanup. Waiting on OK from Megan Ritch (Panos). 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 ] ] ]; // FY2627 hpcSets // Direct Mail hpcSets radioAmountsData[ currencyList[i] ].DM_2627_15 = [ [ 0, [ 15, 25, 35, 50, 100, 200, 250 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2627_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2627_5000 = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; } 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' ); } // A/B test for SMS opt-in on payments form if ( params.country === 'US' && params.uselang === 'en' && mw.util.getParamValue( 'wmf_medium' ) === 'smsOptinTest' ) { if ( Math.random() < 0.5 ) { params.variant = 'smsOptin'; donationForm.extraData.smsOptinTest = 1; } else { donationForm.extraData.smsOptinTest = 0; } } // 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'); } // And Yape if ( params.payment_method === 'ew' && params.payment_submethod === 'yape' ) { 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; if ( form.frequency ) { 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., '.includes(chr) ) { 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', // for certain issues in email links 'en', 'en-ca', 'en-gb', 'en-us', 'ca', 'cs', 'da', 'de', 'el', 'es-419', 'es', 'fr', 'hu', 'it', 'ja', 'nb', 'nl', 'pl', 'pt-br', 'pt', 'sv', ]; 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.includes( donationForm.country ) ) { $('#frequency_onetime').prop('checked', true); $('.frequency-options, #cancel-monthly, #donate-recurring-smallprint').hide(); } if ( donationForm.noRecurringPaypalCountries.includes( donationForm.country ) ) { $( '.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'); // 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.includes( donationForm.country ) && 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(); } }); }); 3stkxpruchg2dpnbx06ei8lg5g9sfmq 43077 43076 2026-09-03T16:50:56Z Pcoombe 5 allow setAmountOptions to remove extra buttons if fewer amounts specified 43077 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 ] ] ], "MinPlus5-75" : [ [ 0, [ 5.75, 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 ] ] ], "MVP" : [ [ 0, [ 250, 450, 750, 1000, 1500, 2000, 5000 ] ], [ 350, [ 350, 600, 800, 1200, 1500, 2000, 5000 ] ], [ 450, [ 450, 750, 950, 1300, 1750, 2500, 5000 ] ], [ 550, [ 550, 850, 1000, 1500, 2000, 2500, 5000 ] ], [ 650, [ 650, 950, 1200, 1750, 2500, 5000, 10000 ] ], [ 750, [ 750, 1000, 1500, 2000, 3000, 5000, 10000 ] ], [ 850, [ 850, 1200, 1500, 2500, 5000, 7500, 10000 ] ], [ 950, [ 950, 1200, 1500, 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 ] ] ], "MinPlus5-75" : [ [ 0, [ 5.75, 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 ] ] ], "MVP" : [ [ 0, [ 250, 450, 750, 1000, 1500, 2000, 5000 ] ], [ 350, [ 350, 600, 800, 1200, 1500, 2000, 5000 ] ], [ 450, [ 450, 750, 950, 1300, 1750, 2500, 5000 ] ], [ 550, [ 550, 850, 1000, 1500, 2000, 2500, 5000 ] ], [ 650, [ 650, 950, 1200, 1750, 2500, 5000, 10000 ] ], [ 750, [ 750, 1000, 1500, 2000, 3000, 5000, 10000 ] ], [ 850, [ 850, 1200, 1500, 2500, 5000, 7500, 10000 ] ], [ 950, [ 950, 1200, 1500, 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 ] ] ], "MinPlus5-75" : [ [ 0, [ 5.75, 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 ] ] ], "MVP" : [ [ 0, [ 250, 450, 750, 1000, 1500, 2000, 5000 ] ], [ 350, [ 350, 600, 800, 1200, 1500, 2000, 5000 ] ], [ 450, [ 450, 750, 950, 1300, 1750, 2500, 5000 ] ], [ 550, [ 550, 850, 1000, 1500, 2000, 2500, 5000 ] ], [ 650, [ 650, 950, 1200, 1750, 2500, 5000, 10000 ] ], [ 750, [ 750, 1000, 1500, 2000, 3000, 5000, 10000 ] ], [ 850, [ 850, 1200, 1500, 2500, 5000, 7500, 10000 ] ], [ 950, [ 950, 1200, 1500, 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 // Will delete DM 2526 sets soon to cleanup. Waiting on OK from Megan Ritch (Panos). 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 ] ] ]; // FY2627 hpcSets // Direct Mail hpcSets radioAmountsData[ currencyList[i] ].DM_2627_15 = [ [ 0, [ 15, 25, 35, 50, 100, 200, 250 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2627_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2627_5000 = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; } 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' ); } // A/B test for SMS opt-in on payments form if ( params.country === 'US' && params.uselang === 'en' && mw.util.getParamValue( 'wmf_medium' ) === 'smsOptinTest' ) { if ( Math.random() < 0.5 ) { params.variant = 'smsOptin'; donationForm.extraData.smsOptinTest = 1; } else { donationForm.extraData.smsOptinTest = 0; } } // 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'); } // And Yape if ( params.payment_method === 'ew' && params.payment_submethod === 'yape' ) { 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; if ( form.frequency ) { 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., '.includes(chr) ) { 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', // for certain issues in email links 'en', 'en-ca', 'en-gb', 'en-us', 'ca', 'cs', 'da', 'de', 'el', 'es-419', 'es', 'fr', 'hu', 'it', 'ja', 'nb', 'nl', 'pl', 'pt-br', 'pt', 'sv', ]; 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 (let j = 0; j < newAmounts.length; j++) { let $radio = $( `#input_amount_${j}` ); let $label = $( `label[for="input_amount_${j}"]` ); $radio.val( newAmounts[j] ); $label.text( donationForm.formatCurrency( newAmounts[j] ) ); } // Remove any extra amount buttons if newAmounts has fewer than 7 elements for (let j = newAmounts.length; j < 7; j++) { let $option = $( `.input_amount_${j}` ); $option.remove(); } }; /** * 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.includes( donationForm.country ) ) { $('#frequency_onetime').prop('checked', true); $('.frequency-options, #cancel-monthly, #donate-recurring-smallprint').hide(); } if ( donationForm.noRecurringPaypalCountries.includes( donationForm.country ) ) { $( '.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'); // 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.includes( donationForm.country ) && 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(); } }); }); 1fhnl0nksvioh8j5zewf8f0xehd58zh 43078 43077 2026-09-03T16:54:48Z Pcoombe 5 add amountOptions parameter 43078 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 ] ] ], "MinPlus5-75" : [ [ 0, [ 5.75, 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 ] ] ], "MVP" : [ [ 0, [ 250, 450, 750, 1000, 1500, 2000, 5000 ] ], [ 350, [ 350, 600, 800, 1200, 1500, 2000, 5000 ] ], [ 450, [ 450, 750, 950, 1300, 1750, 2500, 5000 ] ], [ 550, [ 550, 850, 1000, 1500, 2000, 2500, 5000 ] ], [ 650, [ 650, 950, 1200, 1750, 2500, 5000, 10000 ] ], [ 750, [ 750, 1000, 1500, 2000, 3000, 5000, 10000 ] ], [ 850, [ 850, 1200, 1500, 2500, 5000, 7500, 10000 ] ], [ 950, [ 950, 1200, 1500, 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 ] ] ], "MinPlus5-75" : [ [ 0, [ 5.75, 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 ] ] ], "MVP" : [ [ 0, [ 250, 450, 750, 1000, 1500, 2000, 5000 ] ], [ 350, [ 350, 600, 800, 1200, 1500, 2000, 5000 ] ], [ 450, [ 450, 750, 950, 1300, 1750, 2500, 5000 ] ], [ 550, [ 550, 850, 1000, 1500, 2000, 2500, 5000 ] ], [ 650, [ 650, 950, 1200, 1750, 2500, 5000, 10000 ] ], [ 750, [ 750, 1000, 1500, 2000, 3000, 5000, 10000 ] ], [ 850, [ 850, 1200, 1500, 2500, 5000, 7500, 10000 ] ], [ 950, [ 950, 1200, 1500, 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 ] ] ], "MinPlus5-75" : [ [ 0, [ 5.75, 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 ] ] ], "MVP" : [ [ 0, [ 250, 450, 750, 1000, 1500, 2000, 5000 ] ], [ 350, [ 350, 600, 800, 1200, 1500, 2000, 5000 ] ], [ 450, [ 450, 750, 950, 1300, 1750, 2500, 5000 ] ], [ 550, [ 550, 850, 1000, 1500, 2000, 2500, 5000 ] ], [ 650, [ 650, 950, 1200, 1750, 2500, 5000, 10000 ] ], [ 750, [ 750, 1000, 1500, 2000, 3000, 5000, 10000 ] ], [ 850, [ 850, 1200, 1500, 2500, 5000, 7500, 10000 ] ], [ 950, [ 950, 1200, 1500, 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 // Will delete DM 2526 sets soon to cleanup. Waiting on OK from Megan Ritch (Panos). 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 ] ] ]; // FY2627 hpcSets // Direct Mail hpcSets radioAmountsData[ currencyList[i] ].DM_2627_15 = [ [ 0, [ 15, 25, 35, 50, 100, 200, 250 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2627_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2627_5000 = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; } 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' ); } // A/B test for SMS opt-in on payments form if ( params.country === 'US' && params.uselang === 'en' && mw.util.getParamValue( 'wmf_medium' ) === 'smsOptinTest' ) { if ( Math.random() < 0.5 ) { params.variant = 'smsOptin'; donationForm.extraData.smsOptinTest = 1; } else { donationForm.extraData.smsOptinTest = 0; } } // 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'); } // And Yape if ( params.payment_method === 'ew' && params.payment_submethod === 'yape' ) { 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; if ( form.frequency ) { 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., '.includes(chr) ) { 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', // for certain issues in email links 'en', 'en-ca', 'en-gb', 'en-us', 'ca', 'cs', 'da', 'de', 'el', 'es-419', 'es', 'fr', 'hu', 'it', 'ja', 'nb', 'nl', 'pl', 'pt-br', 'pt', 'sv', ]; 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 (let j = 0; j < newAmounts.length; j++) { let $radio = $( `#input_amount_${j}` ); let $label = $( `label[for="input_amount_${j}"]` ); $radio.val( newAmounts[j] ); $label.text( donationForm.formatCurrency( newAmounts[j] ) ); } // Remove any extra amount buttons if newAmounts has fewer than 7 elements for (let j = newAmounts.length; j < 7; j++) { let $option = $( `.input_amount_${j}` ); $option.remove(); } }; /** * 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.includes( donationForm.country ) ) { $('#frequency_onetime').prop('checked', true); $('.frequency-options, #cancel-monthly, #donate-recurring-smallprint').hide(); } if ( donationForm.noRecurringPaypalCountries.includes( donationForm.country ) ) { $( '.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'); // 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.includes( donationForm.country ) && 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(); // amountOptions parameter should override other parameters let amountOptionsParam = mw.util.getParamValue( 'amountOptions' ); if ( amountOptionsParam ) { let amounts = amountOptionsParam.split(',').map( (x) => parseFloat(x) ); donationForm.setAmountOptions( amounts ); } // 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(); } }); }); d6t119n8iekt8xhg6zx4ohchj2iozgz 43090 43078 2026-09-03T18:44:19Z Pcoombe 5 spacing cleanup 43090 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 ] ] ], "MinPlus5-75" : [ [ 0, [ 5.75, 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 ] ] ], "MVP" : [ [ 0, [ 250, 450, 750, 1000, 1500, 2000, 5000 ] ], [ 350, [ 350, 600, 800, 1200, 1500, 2000, 5000 ] ], [ 450, [ 450, 750, 950, 1300, 1750, 2500, 5000 ] ], [ 550, [ 550, 850, 1000, 1500, 2000, 2500, 5000 ] ], [ 650, [ 650, 950, 1200, 1750, 2500, 5000, 10000 ] ], [ 750, [ 750, 1000, 1500, 2000, 3000, 5000, 10000 ] ], [ 850, [ 850, 1200, 1500, 2500, 5000, 7500, 10000 ] ], [ 950, [ 950, 1200, 1500, 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 ] ] ], "MinPlus5-75" : [ [ 0, [ 5.75, 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 ] ] ], "MVP" : [ [ 0, [ 250, 450, 750, 1000, 1500, 2000, 5000 ] ], [ 350, [ 350, 600, 800, 1200, 1500, 2000, 5000 ] ], [ 450, [ 450, 750, 950, 1300, 1750, 2500, 5000 ] ], [ 550, [ 550, 850, 1000, 1500, 2000, 2500, 5000 ] ], [ 650, [ 650, 950, 1200, 1750, 2500, 5000, 10000 ] ], [ 750, [ 750, 1000, 1500, 2000, 3000, 5000, 10000 ] ], [ 850, [ 850, 1200, 1500, 2500, 5000, 7500, 10000 ] ], [ 950, [ 950, 1200, 1500, 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 ] ] ], "MinPlus5-75" : [ [ 0, [ 5.75, 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 ] ] ], "MVP" : [ [ 0, [ 250, 450, 750, 1000, 1500, 2000, 5000 ] ], [ 350, [ 350, 600, 800, 1200, 1500, 2000, 5000 ] ], [ 450, [ 450, 750, 950, 1300, 1750, 2500, 5000 ] ], [ 550, [ 550, 850, 1000, 1500, 2000, 2500, 5000 ] ], [ 650, [ 650, 950, 1200, 1750, 2500, 5000, 10000 ] ], [ 750, [ 750, 1000, 1500, 2000, 3000, 5000, 10000 ] ], [ 850, [ 850, 1200, 1500, 2500, 5000, 7500, 10000 ] ], [ 950, [ 950, 1200, 1500, 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 // Will delete DM 2526 sets soon to cleanup. Waiting on OK from Megan Ritch (Panos). 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 ] ] ]; // FY2627 hpcSets // Direct Mail hpcSets radioAmountsData[ currencyList[i] ].DM_2627_15 = [ [ 0, [ 15, 25, 35, 50, 100, 200, 250 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2627_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2627_5000 = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; } 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' ); } // A/B test for SMS opt-in on payments form if ( params.country === 'US' && params.uselang === 'en' && mw.util.getParamValue( 'wmf_medium' ) === 'smsOptinTest' ) { if ( Math.random() < 0.5 ) { params.variant = 'smsOptin'; donationForm.extraData.smsOptinTest = 1; } else { donationForm.extraData.smsOptinTest = 0; } } // 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'); } // And Yape if ( params.payment_method === 'ew' && params.payment_submethod === 'yape' ) { 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; if ( form.frequency ) { 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., '.includes(chr) ) { 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', // for certain issues in email links 'en', 'en-ca', 'en-gb', 'en-us', 'ca', 'cs', 'da', 'de', 'el', 'es-419', 'es', 'fr', 'hu', 'it', 'ja', 'nb', 'nl', 'pl', 'pt-br', 'pt', 'sv', ]; 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 (let j = 0; j < newAmounts.length; j++) { let $radio = $( `#input_amount_${j}` ); let $label = $( `label[for="input_amount_${j}"]` ); $radio.val( newAmounts[j] ); $label.text( donationForm.formatCurrency( newAmounts[j] ) ); } // Remove any extra amount buttons if newAmounts has fewer than 7 elements for (let j = newAmounts.length; j < 7; j++) { let $option = $( `.input_amount_${j}` ); $option.remove(); } }; /** * 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.includes( donationForm.country ) ) { $('#frequency_onetime').prop('checked', true); $('.frequency-options, #cancel-monthly, #donate-recurring-smallprint').hide(); } if ( donationForm.noRecurringPaypalCountries.includes( donationForm.country ) ) { $( '.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'); // 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.includes( donationForm.country ) && 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(); // amountOptions parameter should override other parameters let amountOptionsParam = mw.util.getParamValue( 'amountOptions' ); if ( amountOptionsParam ) { let amounts = amountOptionsParam.split(',').map( (x) => parseFloat(x) ); donationForm.setAmountOptions( amounts ); } // 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(); } }); }); n6kv1qmyopdp88x5s8kfu5ixq9nrus8 43091 43090 2026-09-03T18:54:37Z Pcoombe 5 cleaning up some amount button behaviours 43091 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 ] ] ], "MinPlus5-75" : [ [ 0, [ 5.75, 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 ] ] ], "MVP" : [ [ 0, [ 250, 450, 750, 1000, 1500, 2000, 5000 ] ], [ 350, [ 350, 600, 800, 1200, 1500, 2000, 5000 ] ], [ 450, [ 450, 750, 950, 1300, 1750, 2500, 5000 ] ], [ 550, [ 550, 850, 1000, 1500, 2000, 2500, 5000 ] ], [ 650, [ 650, 950, 1200, 1750, 2500, 5000, 10000 ] ], [ 750, [ 750, 1000, 1500, 2000, 3000, 5000, 10000 ] ], [ 850, [ 850, 1200, 1500, 2500, 5000, 7500, 10000 ] ], [ 950, [ 950, 1200, 1500, 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 ] ] ], "MinPlus5-75" : [ [ 0, [ 5.75, 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 ] ] ], "MVP" : [ [ 0, [ 250, 450, 750, 1000, 1500, 2000, 5000 ] ], [ 350, [ 350, 600, 800, 1200, 1500, 2000, 5000 ] ], [ 450, [ 450, 750, 950, 1300, 1750, 2500, 5000 ] ], [ 550, [ 550, 850, 1000, 1500, 2000, 2500, 5000 ] ], [ 650, [ 650, 950, 1200, 1750, 2500, 5000, 10000 ] ], [ 750, [ 750, 1000, 1500, 2000, 3000, 5000, 10000 ] ], [ 850, [ 850, 1200, 1500, 2500, 5000, 7500, 10000 ] ], [ 950, [ 950, 1200, 1500, 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 ] ] ], "MinPlus5-75" : [ [ 0, [ 5.75, 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 ] ] ], "MVP" : [ [ 0, [ 250, 450, 750, 1000, 1500, 2000, 5000 ] ], [ 350, [ 350, 600, 800, 1200, 1500, 2000, 5000 ] ], [ 450, [ 450, 750, 950, 1300, 1750, 2500, 5000 ] ], [ 550, [ 550, 850, 1000, 1500, 2000, 2500, 5000 ] ], [ 650, [ 650, 950, 1200, 1750, 2500, 5000, 10000 ] ], [ 750, [ 750, 1000, 1500, 2000, 3000, 5000, 10000 ] ], [ 850, [ 850, 1200, 1500, 2500, 5000, 7500, 10000 ] ], [ 950, [ 950, 1200, 1500, 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 // Will delete DM 2526 sets soon to cleanup. Waiting on OK from Megan Ritch (Panos). 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 ] ] ]; // FY2627 hpcSets // Direct Mail hpcSets radioAmountsData[ currencyList[i] ].DM_2627_15 = [ [ 0, [ 15, 25, 35, 50, 100, 200, 250 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2627_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2627_5000 = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; } 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'); } } /* -- 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' ); } // A/B test for SMS opt-in on payments form if ( params.country === 'US' && params.uselang === 'en' && mw.util.getParamValue( 'wmf_medium' ) === 'smsOptinTest' ) { if ( Math.random() < 0.5 ) { params.variant = 'smsOptin'; donationForm.extraData.smsOptinTest = 1; } else { donationForm.extraData.smsOptinTest = 0; } } // 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'); } // And Yape if ( params.payment_method === 'ew' && params.payment_submethod === 'yape' ) { 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; if ( form.frequency ) { 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., '.includes(chr) ) { 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', // for certain issues in email links 'en', 'en-ca', 'en-gb', 'en-us', 'ca', 'cs', 'da', 'de', 'el', 'es-419', 'es', 'fr', 'hu', 'it', 'ja', 'nb', 'nl', 'pl', 'pt-br', 'pt', 'sv', ]; 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 (let j = 0; j < newAmounts.length; j++) { let $radio = $( `#input_amount_${j}` ); let $label = $( `label[for="input_amount_${j}"]` ); $radio.val( newAmounts[j] ); $label.text( donationForm.formatCurrency( newAmounts[j] ) ); } // Remove any extra amount buttons if newAmounts has fewer than 7 elements for (let j = newAmounts.length; j < 7; j++) { let $option = $( `.input_amount_${j}` ); $option.remove(); } }; /** * 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; } // Clear the other amount input field when a preset amount is selected $('input[name="amount"][value!="Other"]').click( function() { $('#input_amount_other_box').val(''); }); // Select other amount radio button when the other amount input field is focused $('#input_amount_other_box').on('focus', function() { document.getElementById('input_amount_other').checked = true; }); // 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.includes( donationForm.country ) ) { $('#frequency_onetime').prop('checked', true); $('.frequency-options, #cancel-monthly, #donate-recurring-smallprint').hide(); } if ( donationForm.noRecurringPaypalCountries.includes( donationForm.country ) ) { $( '.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'); // 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.includes( donationForm.country ) && 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(); // amountOptions parameter should override other parameters let amountOptionsParam = mw.util.getParamValue( 'amountOptions' ); if ( amountOptionsParam ) { let amounts = amountOptionsParam.split(',').map( (x) => parseFloat(x) ); donationForm.setAmountOptions( amounts ); } // 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(); } }); }); 7ryh57t4ehi7ta0p9clw5z6lt5yz209 43092 43091 2026-09-03T18:58:09Z Pcoombe 5 simplify es-419 check 43092 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 ] ] ], "MinPlus5-75" : [ [ 0, [ 5.75, 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 ] ] ], "MVP" : [ [ 0, [ 250, 450, 750, 1000, 1500, 2000, 5000 ] ], [ 350, [ 350, 600, 800, 1200, 1500, 2000, 5000 ] ], [ 450, [ 450, 750, 950, 1300, 1750, 2500, 5000 ] ], [ 550, [ 550, 850, 1000, 1500, 2000, 2500, 5000 ] ], [ 650, [ 650, 950, 1200, 1750, 2500, 5000, 10000 ] ], [ 750, [ 750, 1000, 1500, 2000, 3000, 5000, 10000 ] ], [ 850, [ 850, 1200, 1500, 2500, 5000, 7500, 10000 ] ], [ 950, [ 950, 1200, 1500, 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 ] ] ], "MinPlus5-75" : [ [ 0, [ 5.75, 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 ] ] ], "MVP" : [ [ 0, [ 250, 450, 750, 1000, 1500, 2000, 5000 ] ], [ 350, [ 350, 600, 800, 1200, 1500, 2000, 5000 ] ], [ 450, [ 450, 750, 950, 1300, 1750, 2500, 5000 ] ], [ 550, [ 550, 850, 1000, 1500, 2000, 2500, 5000 ] ], [ 650, [ 650, 950, 1200, 1750, 2500, 5000, 10000 ] ], [ 750, [ 750, 1000, 1500, 2000, 3000, 5000, 10000 ] ], [ 850, [ 850, 1200, 1500, 2500, 5000, 7500, 10000 ] ], [ 950, [ 950, 1200, 1500, 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 ] ] ], "MinPlus5-75" : [ [ 0, [ 5.75, 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 ] ] ], "MVP" : [ [ 0, [ 250, 450, 750, 1000, 1500, 2000, 5000 ] ], [ 350, [ 350, 600, 800, 1200, 1500, 2000, 5000 ] ], [ 450, [ 450, 750, 950, 1300, 1750, 2500, 5000 ] ], [ 550, [ 550, 850, 1000, 1500, 2000, 2500, 5000 ] ], [ 650, [ 650, 950, 1200, 1750, 2500, 5000, 10000 ] ], [ 750, [ 750, 1000, 1500, 2000, 3000, 5000, 10000 ] ], [ 850, [ 850, 1200, 1500, 2500, 5000, 7500, 10000 ] ], [ 950, [ 950, 1200, 1500, 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 // Will delete DM 2526 sets soon to cleanup. Waiting on OK from Megan Ritch (Panos). 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 ] ] ]; // FY2627 hpcSets // Direct Mail hpcSets radioAmountsData[ currencyList[i] ].DM_2627_15 = [ [ 0, [ 15, 25, 35, 50, 100, 200, 250 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2627_250 = [ [ 0, [ 250, 300, 500, 750, 1000, 2500, 5000 ] ] ]; radioAmountsData[ currencyList[i] ].DM_2627_5000 = [ [ 0, [ 5000, 7500, 10000, 12500, 15000, 17500, 20000 ] ] ]; } 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'); } } /* -- 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' && [ 'AR', 'CL', 'CO', 'MX', 'PE', 'UY', 'US' ].includes(params.country) ) { 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' ); } // A/B test for SMS opt-in on payments form if ( params.country === 'US' && params.uselang === 'en' && mw.util.getParamValue( 'wmf_medium' ) === 'smsOptinTest' ) { if ( Math.random() < 0.5 ) { params.variant = 'smsOptin'; donationForm.extraData.smsOptinTest = 1; } else { donationForm.extraData.smsOptinTest = 0; } } // 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'); } // And Yape if ( params.payment_method === 'ew' && params.payment_submethod === 'yape' ) { 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; if ( form.frequency ) { 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., '.includes(chr) ) { 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', // for certain issues in email links 'en', 'en-ca', 'en-gb', 'en-us', 'ca', 'cs', 'da', 'de', 'el', 'es-419', 'es', 'fr', 'hu', 'it', 'ja', 'nb', 'nl', 'pl', 'pt-br', 'pt', 'sv', ]; 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 (let j = 0; j < newAmounts.length; j++) { let $radio = $( `#input_amount_${j}` ); let $label = $( `label[for="input_amount_${j}"]` ); $radio.val( newAmounts[j] ); $label.text( donationForm.formatCurrency( newAmounts[j] ) ); } // Remove any extra amount buttons if newAmounts has fewer than 7 elements for (let j = newAmounts.length; j < 7; j++) { let $option = $( `.input_amount_${j}` ); $option.remove(); } }; /** * 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; } // Clear the other amount input field when a preset amount is selected $('input[name="amount"][value!="Other"]').click( function() { $('#input_amount_other_box').val(''); }); // Select other amount radio button when the other amount input field is focused $('#input_amount_other_box').on('focus', function() { document.getElementById('input_amount_other').checked = true; }); // 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.includes( donationForm.country ) ) { $('#frequency_onetime').prop('checked', true); $('.frequency-options, #cancel-monthly, #donate-recurring-smallprint').hide(); } if ( donationForm.noRecurringPaypalCountries.includes( donationForm.country ) ) { $( '.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'); // 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.includes( donationForm.country ) && 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(); // amountOptions parameter should override other parameters let amountOptionsParam = mw.util.getParamValue( 'amountOptions' ); if ( amountOptionsParam ) { let amounts = amountOptionsParam.split(',').map( (x) => parseFloat(x) ); donationForm.setAmountOptions( amounts ); } // 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(); } }); }); o6ozvweh406agwubflicajw9cxz3o7v Template:2012FR/Form-section/Radiobuttons/3buttons 10 9332 43097 39514 2026-09-03T19:06:04Z Pcoombe 5 remove selectAmount and selectOther 43097 wikitext text/x-wiki <html> <input type="hidden" name="currency_code" value="</html>{{{currency|{{CurrencyCode|{{{country}}}}}}}}<html>"/> <div id="radiobuttons-table-header"> </html>{{int:donate_interface-amount-legend}} ({{{currency|{{CurrencyCode|{{{country}}}}}}}})<html> </div> <fieldset class="frequency-options"> <ul> <li> <input type="radio" name="frequency" id="frequency_onetime" value="onetime" onclick="donationForm.toggleMonthly(false);" checked> <label class="frb-btn" for="frequency_onetime"></html>{{int:donate_interface-onetime-short}}<html></label> </li> <li> <input type="radio" name="frequency" id="frequency_monthly" value="monthly" onclick="donationForm.toggleMonthly(true);"> <label class="frb-btn" for="frequency_monthly"></html>{{int:donate_interface-monthly-short}}<html></label> </li> </ul> </fieldset> <fieldset class="amount-options"> <ul> <li class="radiobuttons-cell input_amount_1"> <input type="radio" name="amount" id="input_amount_1" value="</html>{{{donate-amount-1}}}<html>" /> <label class="frb-btn" for="input_amount_1"></html>{{CurrencyFormat|{{{donate-amount-1}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_2"> <input type="radio" name="amount" id="input_amount_2" value="</html>{{{donate-amount-2}}}<html>" /> <label class="frb-btn" for="input_amount_2"></html>{{CurrencyFormat|{{{donate-amount-2}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_4"> <input type="radio" name="amount" id="input_amount_4" value="</html>{{{donate-amount-4}}}<html>" /> <label class="frb-btn" for="input_amount_4"></html>{{CurrencyFormat|{{{donate-amount-4}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_other"> <input type="radio" name="amount" id="input_amount_other" value="Other" onclick="document.getElementById('input_amount_other_box').focus();"> <label class="frb-btn" for="input_amount_other"> <span></html>{{int:donate_interface-other}}<html></span> <input id="input_amount_other_box" type="text" inputmode="decimal" autocomplete="off" value="" tabindex="-1" class="noime"> </label> </li> </ul> <div style="display: none;" class="lp-error lp-error-smallamount"></html>{{int:Donate_interface-smallamount-error}}<html></div> <div style="display: none;" class="lp-error lp-error-bigamount"></html>{{int:Donate_interface-bigamount-error}}<html></div> </fieldset> </html> 44v8s63s6863ovjobq9o3rcrzn8q487 Template:2012FR/Form-section/Radiobuttons/Annual 10 9748 43099 41145 2026-09-03T19:06:48Z Pcoombe 5 remove selectAmount and selectOther 43099 wikitext text/x-wiki <html> <input type="hidden" name="currency_code" value="</html>{{{currency|{{CurrencyCode|{{{country}}}}}}}}<html>"/> <div id="radiobuttons-table-header"> </html>{{int:donate_interface-amount-legend}} ({{{currency|{{CurrencyCode|{{{country}}}}}}}})<html> </div> <fieldset class="frequency-options"> <legend class="sr-only"> How often would you like to donate? </legend> <ul> <li> <input type="radio" name="frequency" id="frequency_onetime" value="onetime" onclick="donationForm.setFrequency('onetime');" checked> <label class="frb-btn" for="frequency_onetime"></html>{{int:donate_interface-onetime-short}}<html></label> </li> <li> <input type="radio" name="frequency" id="frequency_monthly" value="monthly" onclick="donationForm.setFrequency('monthly');"> <label class="frb-btn" for="frequency_monthly"></html>{{int:donate_interface-monthly-short}}<html></label> </li> <li> <input type="radio" name="frequency" id="frequency_annual" value="annual" onclick="donationForm.setFrequency('annual');"> <label class="frb-btn" for="frequency_annual"></html>{{int:Frequency-Annual}}<html></label> </li> </ul> </fieldset> <fieldset class="amount-options"> <legend class="sr-only"> </html>{{int:donate_interface-amount-legend}} ({{{currency|{{CurrencyCode|{{{country}}}}}}}})<html> </legend> <ul> <li class="radiobuttons-cell input_amount_0"> <input type="radio" name="amount" id="input_amount_0" value="</html>{{{donate-amount-0}}}<html>" /> <label class="frb-btn" for="input_amount_0"></html>{{CurrencyFormat|{{{donate-amount-0}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_1"> <input type="radio" name="amount" id="input_amount_1" value="</html>{{{donate-amount-1}}}<html>" /> <label class="frb-btn" for="input_amount_1"></html>{{CurrencyFormat|{{{donate-amount-1}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_2"> <input type="radio" name="amount" id="input_amount_2" value="</html>{{{donate-amount-2}}}<html>" /> <label class="frb-btn" for="input_amount_2"></html>{{CurrencyFormat|{{{donate-amount-2}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_3"> <input type="radio" name="amount" id="input_amount_3" value="</html>{{{donate-amount-3}}}<html>" /> <label class="frb-btn" for="input_amount_3"></html>{{CurrencyFormat|{{{donate-amount-3}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_4"> <input type="radio" name="amount" id="input_amount_4" value="</html>{{{donate-amount-4}}}<html>" /> <label class="frb-btn" for="input_amount_4"></html>{{CurrencyFormat|{{{donate-amount-4}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_5"> <input type="radio" name="amount" id="input_amount_5" value="</html>{{{donate-amount-5}}}<html>" /> <label class="frb-btn" for="input_amount_5"></html>{{CurrencyFormat|{{{donate-amount-5}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_6"> <input type="radio" name="amount" id="input_amount_6" value="</html>{{{donate-amount-6}}}<html>" /> <label class="frb-btn" for="input_amount_6"></html>{{CurrencyFormat|{{{donate-amount-6}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_other"> <input type="radio" name="amount" id="input_amount_other" value="Other" onclick="document.getElementById('input_amount_other_box').focus();"> <label class="frb-btn" for="input_amount_other"> <span></html>{{int:donate_interface-other}}<html></span> <input id="input_amount_other_box" type="text" inputmode="decimal" autocomplete="off" value="" tabindex="-1" class="noime"> </label> </li> </ul> <!-- tabindex="-1" allows focus with js so errors can be announced --> <div style="display: none;" tabindex="-1" class="lp-error lp-error-smallamount"> </html>{{int:Donate_interface-smallamount-error}}<html> </div> <div style="display: none;" tabindex="-1" class="lp-error lp-error-bigamount"> </html>{{int:Donate_interface-bigamount-error}}<html> </div> </fieldset> </html> 54oal74uvyicvlwedfubijtn474tqk9 Template:2012FR/Form-section/Radiobuttons/FY2526 2-freq 10 10024 43101 41593 2026-09-03T19:07:40Z Pcoombe 5 remove selectAmount and selectOther 43101 wikitext text/x-wiki <html> <input type="hidden" name="currency_code" value="</html>{{{currency|{{CurrencyCode|{{{country}}}}}}}}<html>"/> <div id="radiobuttons-table-header"> </html>{{int:donate_interface-amount-legend}} ({{{currency|{{CurrencyCode|{{{country}}}}}}}})<html> </div> <fieldset class="frequency-options"> <legend class="sr-only"> How often would you like to donate? </legend> <ul> <li> <input type="radio" name="frequency" id="frequency_onetime" value="onetime" onclick="donationForm.setFrequency('onetime');" checked> <label class="frb-btn" for="frequency_onetime"></html>{{int:donate_interface-onetime-short}}<html></label> </li> <li> <input type="radio" name="frequency" id="frequency_monthly" value="monthly" onclick="donationForm.setFrequency('monthly');"> <label class="frb-btn" for="frequency_monthly"></html>{{int:donate_interface-monthly-short}}<html></label> </li> </ul> </fieldset> <fieldset class="amount-options"> <legend class="sr-only"> </html>{{int:donate_interface-amount-legend}} ({{{currency|{{CurrencyCode|{{{country}}}}}}}})<html> </legend> <ul> <li class="radiobuttons-cell input_amount_0"> <input type="radio" name="amount" id="input_amount_0" value="</html>{{{donate-amount-0}}}<html>" /> <label class="frb-btn" for="input_amount_0"></html>{{CurrencyFormat|{{{donate-amount-0}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_1"> <input type="radio" name="amount" id="input_amount_1" value="</html>{{{donate-amount-1}}}<html>" /> <label class="frb-btn" for="input_amount_1"></html>{{CurrencyFormat|{{{donate-amount-1}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_2"> <input type="radio" name="amount" id="input_amount_2" value="</html>{{{donate-amount-2}}}<html>" /> <label class="frb-btn" for="input_amount_2"></html>{{CurrencyFormat|{{{donate-amount-2}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_3"> <input type="radio" name="amount" id="input_amount_3" value="</html>{{{donate-amount-3}}}<html>" /> <label class="frb-btn" for="input_amount_3"></html>{{CurrencyFormat|{{{donate-amount-3}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_4"> <input type="radio" name="amount" id="input_amount_4" value="</html>{{{donate-amount-4}}}<html>" /> <label class="frb-btn" for="input_amount_4"></html>{{CurrencyFormat|{{{donate-amount-4}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_5"> <input type="radio" name="amount" id="input_amount_5" value="</html>{{{donate-amount-5}}}<html>" /> <label class="frb-btn" for="input_amount_5"></html>{{CurrencyFormat|{{{donate-amount-5}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_6"> <input type="radio" name="amount" id="input_amount_6" value="</html>{{{donate-amount-6}}}<html>" /> <label class="frb-btn" for="input_amount_6"></html>{{CurrencyFormat|{{{donate-amount-6}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_other"> <input type="radio" name="amount" id="input_amount_other" value="Other" onclick="document.getElementById('input_amount_other_box').focus();"> <label class="frb-btn" for="input_amount_other"> <span></html>{{int:donate_interface-other}}<html></span> <input id="input_amount_other_box" type="text" inputmode="decimal" autocomplete="off" value="" tabindex="-1" class="noime"> </label> </li> </ul> <!-- tabindex="-1" allows focus with js so errors can be announced --> <div style="display: none;" tabindex="-1" class="lp-error lp-error-smallamount"> </html>{{int:Donate_interface-smallamount-error}}<html> </div> <div style="display: none;" tabindex="-1" class="lp-error lp-error-bigamount"> </html>{{int:Donate_interface-bigamount-error}}<html> </div> </fieldset> </html> fk9wgey8jsjeiocm4k1dxtt10j890oq Template:2012FR/Form-section/Radiobuttons/BannersMatch 10 10034 43100 41714 2026-09-03T19:07:20Z Pcoombe 5 remove selectAmount and selectOther 43100 wikitext text/x-wiki <html> <input type="hidden" name="currency_code" value="</html>{{{currency|{{CurrencyCode|{{{country}}}}}}}}<html>"/> <div id="radiobuttons-table-header"> </html>{{int:donate_interface-amount-legend}} ({{{currency|{{CurrencyCode|{{{country}}}}}}}})<html> </div> <fieldset class="frequency-options"> <legend class="hide-mb">1. How often would you like to donate?</legend> <ul> <li> <input type="radio" name="frequency" id="frequency_onetime" value="onetime" onclick="donationForm.setFrequency('onetime');" checked> <label class="frb-btn" for="frequency_onetime"></html>Once<html></label> </li> <li> <input type="radio" name="frequency" id="frequency_monthly" value="monthly" onclick="donationForm.setFrequency('monthly');"> <label class="frb-btn" for="frequency_monthly"></html>{{int:donate_interface-monthly-short}}<html></label> </li> <li style="display: none;"> <input type="radio" name="frequency" id="frequency_annual" value="annual" onclick="donationForm.setFrequency('annual');"> <label class="frb-btn" for="frequency_annual"></html>{{int:Frequency-Annual}}<html></label> </li> </ul> </fieldset> <fieldset class="amount-options"> <legend class="highlight-spacing hide-mb"> </html>2. Please select an amount ({{{currency|{{CurrencyCode|{{{country}}}}}}}}). The average donation in {{Template:Copy/Country|country={{{country}}}}} is around {{Template:Copy/AverageAmount|country={{{country}}}}}.<html> </legend> <ul> <li class="radiobuttons-cell input_amount_0"> <input type="radio" name="amount" id="input_amount_0" value="</html>{{{donate-amount-0}}}<html>" /> <label class="frb-btn" for="input_amount_0"></html>{{CurrencyFormat|{{{donate-amount-0}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_1"> <input type="radio" name="amount" id="input_amount_1" value="</html>{{{donate-amount-1}}}<html>" /> <label class="frb-btn" for="input_amount_1"></html>{{CurrencyFormat|{{{donate-amount-1}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_2 frb-highlight"> <input type="radio" name="amount" id="input_amount_2" value="</html>{{{donate-amount-2}}}<html>" /> <label class="frb-btn" for="input_amount_2"></html>{{CurrencyFormat|{{{donate-amount-2}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> <div class="frb-amount-highlight hide-mb">Preferred Amount</div> </li> <li class="radiobuttons-cell input_amount_3"> <input type="radio" name="amount" id="input_amount_3" value="</html>{{{donate-amount-3}}}<html>" /> <label class="frb-btn" for="input_amount_3"></html>{{CurrencyFormat|{{{donate-amount-3}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_4"> <input type="radio" name="amount" id="input_amount_4" value="</html>{{{donate-amount-4}}}<html>" /> <label class="frb-btn" for="input_amount_4"></html>{{CurrencyFormat|{{{donate-amount-4}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_5"> <input type="radio" name="amount" id="input_amount_5" value="</html>{{{donate-amount-5}}}<html>" /> <label class="frb-btn" for="input_amount_5"></html>{{CurrencyFormat|{{{donate-amount-5}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_6"> <input type="radio" name="amount" id="input_amount_6" value="</html>{{{donate-amount-6}}}<html>" /> <label class="frb-btn" for="input_amount_6"></html>{{CurrencyFormat|{{{donate-amount-6}}}|{{{currency}}}|{{{country}}}|{{{language}}}}}<html></label> </li> <li class="radiobuttons-cell input_amount_other"> <input type="radio" name="amount" id="input_amount_other" value="Other" onclick="document.getElementById('input_amount_other_box').focus();"> <label class="frb-btn" for="input_amount_other"> <input id="input_amount_other_box" type="text" inputmode="decimal" autocomplete="off" value="" tabindex="-1" class="noime" placeholder="Other"> </label> </li> </ul> <!-- tabindex="-1" allows focus with js so errors can be announced --> <div style="display: none;" tabindex="-1" class="lp-error lp-error-smallamount"> </html>{{int:Donate_interface-smallamount-error}}<html> </div> <div style="display: none;" tabindex="-1" class="lp-error lp-error-bigamount"> </html>{{int:Donate_interface-bigamount-error}}<html> </div> </fieldset> </html> l9v2pllp5qo5013zg7j2p6d3jwe4xwi MediaWiki:Gadgets-definition 8 10462 43103 43024 2026-09-03T20:54:53Z Pcoombe 5 starting DonationForm gadget 43103 wikitext text/x-wiki * EditorTools [ ResourceLoader | default | rights=viewmywatchlist ] | EditorTools.js | EditorTools.css * DonationForm [ ResourceLoader | dependencies=mediawiki.util ] | DonationForm.js 8sqqrcvnb5omvznw06fymrf6m128bgr File:DAFday-Cover.png 6 10473 43079 2026-09-03T18:11:35Z RLopez-WMF 53 43079 wikitext text/x-wiki phoiac9h4m842xq45sp7s6u21eteeq1 File:DAFday-Squared.png 6 10474 43080 2026-09-03T18:11:49Z RLopez-WMF 53 43080 wikitext text/x-wiki phoiac9h4m842xq45sp7s6u21eteeq1 File:Wir-image1.png 6 10475 43081 2026-09-03T18:12:44Z RLopez-WMF 53 43081 wikitext text/x-wiki phoiac9h4m842xq45sp7s6u21eteeq1 File:Wir-image2.png 6 10476 43082 2026-09-03T18:12:55Z RLopez-WMF 53 43082 wikitext text/x-wiki phoiac9h4m842xq45sp7s6u21eteeq1 File:Wir-image3.jpg 6 10477 43083 2026-09-03T18:13:07Z RLopez-WMF 53 43083 wikitext text/x-wiki phoiac9h4m842xq45sp7s6u21eteeq1 File:Wir-image4.png 6 10478 43084 2026-09-03T18:13:18Z RLopez-WMF 53 43084 wikitext text/x-wiki phoiac9h4m842xq45sp7s6u21eteeq1 File:Wir-image5.jpg 6 10479 43085 2026-09-03T18:13:28Z RLopez-WMF 53 43085 wikitext text/x-wiki phoiac9h4m842xq45sp7s6u21eteeq1 File:Wir-image6.jpg 6 10480 43086 2026-09-03T18:13:40Z RLopez-WMF 53 43086 wikitext text/x-wiki phoiac9h4m842xq45sp7s6u21eteeq1 File:Wir-image7.jpg 6 10481 43087 2026-09-03T18:13:56Z RLopez-WMF 53 43087 wikitext text/x-wiki phoiac9h4m842xq45sp7s6u21eteeq1 File:Wir-image8.png 6 10482 43088 2026-09-03T18:14:07Z RLopez-WMF 53 43088 wikitext text/x-wiki phoiac9h4m842xq45sp7s6u21eteeq1 File:Wir-image9.jpg 6 10483 43089 2026-09-03T18:14:22Z RLopez-WMF 53 43089 wikitext text/x-wiki phoiac9h4m842xq45sp7s6u21eteeq1 MediaWiki:Gadget-DonationForm 8 10484 43104 2026-09-03T20:55:33Z Pcoombe 5 Created page with "Donation form javascript: [[MediaWiki:Gadget-DonationForm.js]]" 43104 wikitext text/x-wiki Donation form javascript: [[MediaWiki:Gadget-DonationForm.js]] 8697ec56ndfbhgpmbxbo0gb8m9scihe MediaWiki:Gadget-DonationForm.js 8 10485 43105 2026-09-03T20:55:46Z Pcoombe 5 create empty page 43105 javascript text/javascript phoiac9h4m842xq45sp7s6u21eteeq1