MediaWiki:MonthlyConvert.js: Difference between revisions

Content deleted Content added
add monthly suggest amounts for HUF, ILS, ZAR, (MYR, RON, PLN), (DKK, NOK)
use donationForm.minLocal and donationForm.maxLocal for Other amount
 
(24 intermediate revisions by the same user not shown)
Line 5:
// https://docs.google.com/spreadsheets/d/1z36zi8EegPLAvR5FYAgwz8ywKZ50QNB82SpwpTdk-xQ/edit#gid=1258723967
mc.amounts = {
'USDEUR' : [ // also CAD, AUD, NZDGBP
[ 21.7499, 0 ],
[ 2.35, 1.40 ],
[ 9, 1.75 ],
[ 12, 2 ],
Line 35 ⟶ 36:
[ Infinity, 0 ]
],
'GBPUSD' : [ // also EURCAD, AUD, NZD
[ 12.9974, 0 ],
[ 9, 1.75 ],
[ 12, 2 ],
Line 63 ⟶ 64:
[ 250, 25 ],
[ 499, 50 ],
[ Infinity, 0 ]
],
'INR' : [
[ 300, 150 ],
[ 500, 175 ],
[ 1000, 250 ],
[ 1500, 350 ],
[ 3000, 500 ],
[ 5000, 750 ],
[ 10000, 1000 ],
[ 25000, 2500 ],
[ Infinity, 0 ]
],
Line 106 ⟶ 96:
[ Infinity, 0 ]
],
'SEK' : [ // Also NOK
[ 5029, 250 ],
[ 10035, 3020 ],
[ 20055, 5025 ],
[ 300105, 7030 ],
[ 500160, 9040 ],
[ 1000210, 11050 ],
[ 2500360, 25060 ],
[ 5000450, 50075 ],
[ 600, 100 ],
[ 800, 125 ],
[ 900, 150 ],
[ 1200, 200 ],
[ 1500, 250 ],
[ 1800, 300 ],
[ 2100, 350 ],
[ Infinity, 0 ]
],
Line 182 ⟶ 179:
[ Infinity, 0 ]
],
'DKK' : [ // Also NOK
[ 19, 0 ],
[ 2025, 10 ],
[ 120, 20 ],
[ 180250, 3040 ],
[ 300350, 50 ],
[ 450, 75 ],
[ 600, 100 ],
Line 196 ⟶ 193:
[ 1800, 300 ],
[ 2100, 350 ],
[ Infinity, 0 ]
],
'CZK' : [
[ 49, 0 ],
[ 180, 30 ],
[ 300, 50 ],
[ 600, 100 ],
[ 900, 150 ],
[ 1200, 200 ],
[ 1500, 250 ],
[ 1800, 300 ],
[ 2100, 350 ],
[ 2400, 400 ],
[ 3000, 500 ],
[ 3600, 600 ],
[ 4200, 700 ],
[ 4800, 800 ],
[ Infinity, 0 ]
],
'CLP' : [
[ 1999, 0 ],
[ 2300, 1000 ],
[ 2700, 1100 ],
[ 3300, 1200 ],
[ 4200, 1300 ],
[ 5500, 1400 ],
[ 9000, 1500 ],
[ 10500, 1700 ],
[ 16000, 2600 ],
[ 20800, 3400 ],
[ 26000, 4200 ],
[ 31200, 5000 ],
[ 38400, 6400 ],
[ 55000, 8500 ],
[ Infinity, 0 ]
],
'UYU' : [
[ 99, 0 ],
[ 120, 50 ],
[ 170, 65 ],
[ 220, 70 ],
[ 320, 75 ],
[ 480, 85 ],
[ 520, 90 ],
[ 750, 125 ],
[ 1050, 170 ],
[ 1350, 225 ],
[ 1600, 250 ],
[ 1800, 300 ],
[ 2100, 320 ],
[ Infinity, 0 ]
],
'PEN' : [
[ 9, 0 ],
[ 12, 5 ],
[ 17, 6 ],
[ 26, 7 ],
[ 48, 8 ],
[ 55, 9 ],
[ 78, 13 ],
[ 105, 17 ],
[ 130, 21 ],
[ 160, 26 ],
[ 180, 30 ],
[ 210, 32 ],
[ Infinity, 0 ]
],
'COP' : [
[ 9999, 0 ],
[ 11300, 5000 ],
[ 17000, 5200 ],
[ 22000, 5500 ],
[ 27000, 5800 ],
[ 45000, 7500 ],
[ 55000, 9000 ],
[ 75000, 12500 ],
[ 105000, 17000 ],
[ 120000, 20000 ],
[ 160000, 25000 ],
[ 180000, 30000 ],
[ 250000, 34000 ],
[ Infinity, 0 ]
],
'BRL' : [
[ 9, 0 ],
[ 12, 6 ],
[ 22, 7 ],
[ 35, 8 ],
[ 45, 9 ],
[ 55, 10 ],
[ 80, 12 ],
[ 105, 16 ],
[ 160, 25 ],
[ 210, 35 ],
[ 270, 45 ],
[ 320, 50 ],
[ Infinity, 0 ]
],
'MXN' : [
[ 39, 0 ],
[ 48, 25 ],
[ 60, 28 ],
[ 110, 30 ],
[ 160, 35 ],
[ 260, 45 ],
[ 270, 50 ],
[ 350, 60 ],
[ 550, 85 ],
[ 650, 90 ],
[ 750, 120 ],
[ 1500, 160 ],
[ Infinity, 0 ]
]
};
 
mc.amounts.EUR = mc.amounts.GBP;
mc.amounts.GBP = mc.amounts.EUR;
mc.amounts.CAD = mc.amounts.USD;
mc.amounts.AUD = mc.amounts.USD;
mc.amounts.NZD = mc.amounts.USD;
 
mc.amounts.RON = mc.amounts.MYR;
mc.amounts.PLN = mc.amounts.MYR;
mc.amounts.NOK = mc.amounts.DKKSEK;
 
mc.getSuggestedAmount = function ( amount, currency ) {
Line 250 ⟶ 361:
 
var amount = mc.getOtherAmount();
var minAmount = donationForm.minimums[ donationForm.currency ] || 1;
 
if ( amount === null || isNaN(amount) || amount <= 0 || amount < minAmountdonationForm.minLocal ) {
$('.mc-edit-amount').addClass('mc-haserror');
$('.mc-error-bigamount').hide();
$('.mc-error-smallamount').show();
return false;
} else if ( amount > donationForm.maxUSD * minAmountmaxLocal ) {
$('.mc-edit-amount').addClass('mc-haserror');
$('.mc-error-smallamount').hide();
Line 273 ⟶ 383:
 
var initialAmount = params.amount,
currency = params.currency_codecurrency || 'USD',
suggestedAmount = mc.getSuggestedAmount( initialAmount, currency ),
locale = donationForm.getLocale( params.uselang, params.country ),
skipMc;
 
if ( mw.util.getParamValue( 'monthlyconvert' ) === 'false' || mw.util.getParamValue( 'monthlyconvert' ) === 'none' ) {
skipMc = true;
}
 
if ( mw.util.getParamValue( 'wmf_medium' ) === 'endowment' || mw.util.getParamValue( 'utm_medium' ) === 'endowment' ) {
// No recurring for endowment
skipMc = true;
}
 
if ( params.recurring ) {
Line 285 ⟶ 404:
if ( donationForm.noRecurringCountries.indexOf( params.country ) !== -1 ) {
// Country where we don't offer any recurring
skipMc = true;
}
 
if ( params.payment_method === 'paypal' && donationForm.noRecurringPaypalCountries.indexOf( params.country ) !== -1 ) {
skipMc = true;
}
Line 295 ⟶ 418:
if (
( params.payment_method === 'paypal' ) ||
( params.payment_method === 'apple' ) ||
( params.payment_method === 'rtbt' && params.payment_submethod === 'rtbt_ideal' ) ||
( params.payment_method === 'ccbt' && params.gatewaypayment_submethod === 'adyenupi' ) ||
( params.payment_method === 'bt' && params.payment_submethod === 'paytmwallet' ) ||
( params.payment_method === 'rtbt' && params.payment_submethod === 'sepadirectdebit' ) ||
( params.payment_method === 'venmo' )
) {
// suitable method!
Line 316 ⟶ 441:
$('.mc-no-button').on( 'click', function() {
params.amount = initialAmount;
params.recurring = false0;
callback( params );
});
Line 324 ⟶ 449:
donationForm.extraData.originalAmt = initialAmount;
params.amount = suggestedAmount;
params.recurring = true1;
params.frequency_unit = 'month';
callback( params );
});
Line 341 ⟶ 467:
donationForm.extraData.originalAmt = initialAmount;
params.amount = mc.getOtherAmount();
params.recurring = true1;
params.frequency_unit = 'month';
callback( params );
}
Line 347 ⟶ 474:
 
$('.mc-modal-screen').show();
document.querySelector('.mc-button').focus();
$('body').addClass('modal-open');
}
Line 356 ⟶ 484:
$( '.mc-diff-amount-link' ).on( 'click keypress', function ( e ) {
if ( e.which === 13 || e.type === 'click' ) {
$( '.mc-choice' ).fadeOut( function hide() {;
$( '.mc-edit-amount' ).fadeInshow();
$( '.mc-other-amount-input' ).focus();
} );
}
} );
Line 365 ⟶ 492:
$( '.mc-choice .mc-back' ).on( 'click keypress', function ( e ) {
if ( e.which === 13 || e.type === 'click' ) {
$( '.mc-edit-amount' ).fadeOut( function hide() {;
$('.mc-modal-screen').hide();
$('body').removeClass('modal-open');
} );
}
} );
Line 374 ⟶ 500:
$( '.mc-edit-amount .mc-back' ).on( 'click keypress', function ( e ) {
if ( e.which === 13 || e.type === 'click' ) {
$( '.mc-edit-amount' ).fadeOut( function hide() {;
$( '.mc-choice' ).fadeInshow();
} );
}
} );