https://www.mediawiki.org/wiki/Special:Code/MediaWiki/102213

Revision: 102213
Author:   kaldari
Date:     2011-11-07 00:02:20 +0000 (Mon, 07 Nov 2011)
Log Message:
-----------
redoing amount validation so we dont have to repeat the list all over the place

Modified Paths:
--------------
    trunk/extensions/DonationInterface/donationinterface.php
    trunk/extensions/DonationInterface/gateway_forms/Form.php
    
trunk/extensions/DonationInterface/gateway_forms/rapidhtml/RapidHtmlResources.php
    
trunk/extensions/DonationInterface/gateway_forms/rapidhtml/html/webitects_1.html
    
trunk/extensions/DonationInterface/gateway_forms/rapidhtml/html/webitects_1a.html
    
trunk/extensions/DonationInterface/gateway_forms/rapidhtml/html/webitects_2.html
    trunk/extensions/DonationInterface/gateway_forms/rapidhtml/js/lightbox1.js
    
trunk/extensions/DonationInterface/globalcollect_gateway/forms/js/lightbox1.js
    
trunk/extensions/DonationInterface/globalcollect_gateway/forms/js/webitects.js
    trunk/extensions/DonationInterface/payflowpro_gateway/forms/js/lightbox1.js
    
trunk/extensions/DonationInterface/payflowpro_gateway/forms/js/webitects_2_2step.js
    
trunk/extensions/DonationInterface/payflowpro_gateway/forms/js/webitects_2_3step.js

Added Paths:
-----------
    trunk/extensions/DonationInterface/modules/validate.currencyMinimums.js

Modified: trunk/extensions/DonationInterface/donationinterface.php
===================================================================
--- trunk/extensions/DonationInterface/donationinterface.php    2011-11-06 
23:59:56 UTC (rev 102212)
+++ trunk/extensions/DonationInterface/donationinterface.php    2011-11-07 
00:02:20 UTC (rev 102213)
@@ -622,11 +622,17 @@
        )
 );
 
+// minimum amounts for all currencies
+$wgResourceModules[ 'di.form.core.minimums' ] = array(
+       'scripts' => 'validate.currencyMinimums.js',
+       'localBasePath' => $donationinterface_dir . 'modules',
+       'remoteExtPath' => 'DonationInterface/modules'
+);
+
 // form validation resource
-//TODO: Move this somewhere gateway-agnostic.
-$wgResourceModules[ 'pfp.form.core.validate' ] = array(
+$wgResourceModules[ 'di.form.core.validate' ] = array(
        'scripts' => 'validate_input.js',
-       'dependencies' => array( 'pfp.form.core.pfp_css', 
'ext.donationInterface.errorMessages' ),
+       'dependencies' => array( 'pfp.form.core.pfp_css', 
'di.form.core.minimums', 'ext.donationInterface.errorMessages' ),
        'localBasePath' => $donationinterface_dir . 'modules',
        'remoteExtPath' => 'DonationInterface/modules'
 );
@@ -635,7 +641,7 @@
 //TODO: Move this somewhere gateway-agnostic.
 $wgResourceModules[ 'pfp.form.core.placeholders' ] = array(
        'scripts' => 'form_placeholders.js',
-       'dependencies' => 'pfp.form.core.validate',
+       'dependencies' => 'di.form.core.validate',
        'messages' => array(
                'donate_interface-donor-fname',
                'donate_interface-donor-lname',
@@ -660,7 +666,7 @@
 // TowStepTwoColumnLetter3
 $wgResourceModules[ 'pfp.form.TwoStepTwoColumnLetter3' ] = array(
        'styles' => 'css/TwoStepTwoColumnLetter3.css',
-       'dependencies' => 'pfp.form.core.validate',
+       'dependencies' => 'di.form.core.validate',
 ) + $wgResourceTemplate;
 
 // API JS

Modified: trunk/extensions/DonationInterface/gateway_forms/Form.php
===================================================================
--- trunk/extensions/DonationInterface/gateway_forms/Form.php   2011-11-06 
23:59:56 UTC (rev 102212)
+++ trunk/extensions/DonationInterface/gateway_forms/Form.php   2011-11-07 
00:02:20 UTC (rev 102213)
@@ -795,7 +795,7 @@
 
        protected function loadValidateJs() {
                global $wgOut;
-               $wgOut->addModules( 'pfp.form.core.validate' );
+               $wgOut->addModules( 'di.form.core.validate' );
        }
 
        protected function loadApiJs() {

Modified: 
trunk/extensions/DonationInterface/gateway_forms/rapidhtml/RapidHtmlResources.php
===================================================================
--- 
trunk/extensions/DonationInterface/gateway_forms/rapidhtml/RapidHtmlResources.php
   2011-11-06 23:59:56 UTC (rev 102212)
+++ 
trunk/extensions/DonationInterface/gateway_forms/rapidhtml/RapidHtmlResources.php
   2011-11-07 00:02:20 UTC (rev 102213)
@@ -119,7 +119,7 @@
        'scripts' => 'js/webitects_2_3step.js',
        'dependencies' => array(
                'di.form.rapidhtml.webitects',
-               'pfp.form.core.validate'
+               'di.form.core.validate'
        ),
        'localBasePath' => dirname( __FILE__ 
).'/../../payflowpro_gateway/forms',
        'remoteExtPath' => $wgPayflowRapidHtmlRemoteExtPath,
@@ -129,7 +129,7 @@
        'scripts' => 'js/webitects_2_2step.js',
        'dependencies' => array(
                'di.form.rapidhtml.webitects',
-               'pfp.form.core.validate'
+               'di.form.core.validate'
        ),
        'localBasePath' => dirname( __FILE__ 
).'/../../payflowpro_gateway/forms',
        'remoteExtPath' => $wgPayflowRapidHtmlRemoteExtPath,

Modified: 
trunk/extensions/DonationInterface/gateway_forms/rapidhtml/html/webitects_1.html
===================================================================
--- 
trunk/extensions/DonationInterface/gateway_forms/rapidhtml/html/webitects_1.html
    2011-11-06 23:59:56 UTC (rev 102212)
+++ 
trunk/extensions/DonationInterface/gateway_forms/rapidhtml/html/webitects_1.html
    2011-11-07 00:02:20 UTC (rev 102213)
@@ -320,9 +320,6 @@
                            });
                            
                            function validateAmount(){
-                               var minimums = {
-                                       'USD' : 1
-                                   };
                                var error = true;
                                                var amount = 
$('input[name="amount"]').val(); // get the amount
                                        var otherAmount = amount // create a 
working copy
@@ -338,11 +335,11 @@
                                        // Check amount is at least the minimum
                                        var currency = 'USD'; // hard-coded for 
these forms and tests
                                        
$('input[name="currency"]').val(currency);
-                                       if ( typeof( minimums[currency] ) == 
'undefined' ) {
-                                               minimums[currency] = 1;
+                                       if ( typeof( 
wgCurrencyMinimums[currency] ) == 'undefined' ) {
+                                               wgCurrencyMinimums[currency] = 
1;
                                        }
-                                       if ( amount < minimums[currency] || 
error ) {
-                                               alert( 'You must contribute at 
least $1'.replace('$1', minimums[currency] + ' ' + currency ) );
+                                       if ( amount < 
wgCurrencyMinimums[currency] || error ) {
+                                               alert( 'You must contribute at 
least $1'.replace('$1', wgCurrencyMinimums[currency] + ' ' + currency ) );
                                                error = true;
                                        }
                                        return !error;

Modified: 
trunk/extensions/DonationInterface/gateway_forms/rapidhtml/html/webitects_1a.html
===================================================================
--- 
trunk/extensions/DonationInterface/gateway_forms/rapidhtml/html/webitects_1a.html
   2011-11-06 23:59:56 UTC (rev 102212)
+++ 
trunk/extensions/DonationInterface/gateway_forms/rapidhtml/html/webitects_1a.html
   2011-11-07 00:02:20 UTC (rev 102213)
@@ -321,9 +321,6 @@
                            });
                            
                            function validateAmount(){
-                               var minimums = {
-                                       'USD' : 1
-                                   };
                                var error = true;
                                                var amount = 
$('input[name="amount"]').val(); // get the amount
                                        var otherAmount = amount // create a 
working copy
@@ -339,11 +336,11 @@
                                        // Check amount is at least the minimum
                                        var currency = 'USD'; // hard-coded for 
these forms and tests
                                        
$('input[name="currency"]').val(currency);
-                                       if ( typeof( minimums[currency] ) == 
'undefined' ) {
-                                               minimums[currency] = 1;
+                                       if ( typeof( 
wgCurrencyMinimums[currency] ) == 'undefined' ) {
+                                               wgCurrencyMinimums[currency] = 
1;
                                        }
-                                       if ( amount < minimums[currency] || 
error ) {
-                                               alert( 'You must contribute at 
least $1'.replace('$1', minimums[currency] + ' ' + currency ) );
+                                       if ( amount < 
wgCurrencyMinimums[currency] || error ) {
+                                               alert( 'You must contribute at 
least $1'.replace('$1', wgCurrencyMinimums[currency] + ' ' + currency ) );
                                                error = true;
                                        }
                                        return !error;

Modified: 
trunk/extensions/DonationInterface/gateway_forms/rapidhtml/html/webitects_2.html
===================================================================
--- 
trunk/extensions/DonationInterface/gateway_forms/rapidhtml/html/webitects_2.html
    2011-11-06 23:59:56 UTC (rev 102212)
+++ 
trunk/extensions/DonationInterface/gateway_forms/rapidhtml/html/webitects_2.html
    2011-11-07 00:02:20 UTC (rev 102213)
@@ -324,9 +324,6 @@
                            });
                            
                            function validateAmount(){
-                               var minimums = {
-                                       'USD' : 1
-                                   };
                                var error = true;
                                                var amount = 
$('input[name="amount"]').val(); // get the amount
                                        var otherAmount = amount // create a 
working copy
@@ -342,11 +339,11 @@
                                        // Check amount is at least the minimum
                                        var currency = 'USD'; // hard-coded for 
these forms and tests
                                        
$('input[name="currency"]').val(currency);
-                                       if ( typeof( minimums[currency] ) == 
'undefined' ) {
-                                               minimums[currency] = 1;
+                                       if ( typeof( 
wgCurrencyMinimums[currency] ) == 'undefined' ) {
+                                               wgCurrencyMinimums[currency] = 
1;
                                        }
-                                       if ( amount < minimums[currency] || 
error ) {
-                                               alert( 'You must contribute at 
least $1'.replace('$1', minimums[currency] + ' ' + currency ) );
+                                       if ( amount < 
wgCurrencyMinimums[currency] || error ) {
+                                               alert( 'You must contribute at 
least $1'.replace('$1', wgCurrencyMinimums[currency] + ' ' + currency ) );
                                                error = true;
                                        }
                                        return !error;

Modified: 
trunk/extensions/DonationInterface/gateway_forms/rapidhtml/js/lightbox1.js
===================================================================
--- trunk/extensions/DonationInterface/gateway_forms/rapidhtml/js/lightbox1.js  
2011-11-06 23:59:56 UTC (rev 102212)
+++ trunk/extensions/DonationInterface/gateway_forms/rapidhtml/js/lightbox1.js  
2011-11-07 00:02:20 UTC (rev 102213)
@@ -156,9 +156,6 @@
        }
        
        function validateAmount(){
-               var minimums = {
-                       'USD' : 1
-               };
                var error = true;
                var amount = $( "input[name='amount']" ).val(); // get the 
amount
                var otherAmount = amount // create a working copy
@@ -174,11 +171,11 @@
                // Check amount is at least the minimum
                var currency = 'USD'; // hard-coded for these forms and tests
                $( "input[name='currency']" ).val( currency );
-               if ( typeof( minimums[currency] ) == 'undefined' ) {
-                       minimums[currency] = 1;
+               if ( typeof( wgCurrencyMinimums[currency] ) == 'undefined' ) {
+                       wgCurrencyMinimums[currency] = 1;
                }
-               if ( amount < minimums[currency] || error ) {
-                       alert( 'You must contribute at least $1'.replace('$1', 
minimums[currency] + ' ' + currency ) );
+               if ( amount < wgCurrencyMinimums[currency] || error ) {
+                       alert( 'You must contribute at least $1'.replace('$1', 
wgCurrencyMinimums[currency] + ' ' + currency ) );
                        error = true;
                }
                return !error;

Modified: 
trunk/extensions/DonationInterface/globalcollect_gateway/forms/js/lightbox1.js
===================================================================
--- 
trunk/extensions/DonationInterface/globalcollect_gateway/forms/js/lightbox1.js  
    2011-11-06 23:59:56 UTC (rev 102212)
+++ 
trunk/extensions/DonationInterface/globalcollect_gateway/forms/js/lightbox1.js  
    2011-11-07 00:02:20 UTC (rev 102213)
@@ -191,9 +191,6 @@
        }
        
        function validateAmount(){
-               var minimums = {
-                       'USD' : 1
-               };
                var error = true;
                var amount = $( "input[name='amount']" ).val(); // get the 
amount
                var otherAmount = amount // create a working copy
@@ -209,11 +206,11 @@
                // Check amount is at least the minimum
                var currency = 'USD'; // hard-coded for these forms and tests
                $( "input[name='currency']" ).val( currency );
-               if ( typeof( minimums[currency] ) == 'undefined' ) {
-                       minimums[currency] = 1;
+               if ( typeof( wgCurrencyMinimums[currency] ) == 'undefined' ) {
+                       wgCurrencyMinimums[currency] = 1;
                }
-               if ( amount < minimums[currency] || error ) {
-                       alert( 'You must contribute at least $1'.replace('$1', 
minimums[currency] + ' ' + currency ) );
+               if ( amount < wgCurrencyMinimums[currency] || error ) {
+                       alert( 'You must contribute at least $1'.replace('$1', 
wgCurrencyMinimums[currency] + ' ' + currency ) );
                        error = true;
                }
                return !error;

Modified: 
trunk/extensions/DonationInterface/globalcollect_gateway/forms/js/webitects.js
===================================================================
--- 
trunk/extensions/DonationInterface/globalcollect_gateway/forms/js/webitects.js  
    2011-11-06 23:59:56 UTC (rev 102212)
+++ 
trunk/extensions/DonationInterface/globalcollect_gateway/forms/js/webitects.js  
    2011-11-07 00:02:20 UTC (rev 102213)
@@ -72,93 +72,6 @@
        $( "#change-amount" ).show();
 }
 window.validateAmount = function() {
-
-       // If you change these, also change in currencyRates.inc.
-       var minimums = {
-               'AED': 4,
-               'ARS': 4,
-               'AUD': 1,
-               'BBD': 2,
-               'BDT': 76,
-               'BGN': 1.4,
-               'BHD': 0.4,
-               'BMD': 1,
-               'BND': 1.3,
-               'BOB': 7,
-               'BRL': 1.7,
-               'BSD': 1,
-               'BZD': 2,
-               'CAD': 1,
-               'CHF': 0.9,
-               'CLP': 494,
-               'CNY': 6,
-               'COP': 1910,
-               'CRC': 512,
-               'CZK': 18,
-               'DKK': 5,
-               'DOP': 38,
-               'DZD': 73,
-               'EEK': 11,
-               'EGP': 6,
-               'EUR': 0.7,
-               'GBP': 0.6,
-               'GTQ': 7.8,
-               'HKD': 7.7,
-               'HNL': 19,
-               'HRK': 5,
-               'HUF': 219,
-               'IDR': 8960,
-               'ILS': 3.6,
-               'INR': 49,
-               'JMD': 85,
-               'JOD': 0.7,
-               'JPY': 78,
-               'KES': 97,
-               'KRW': 1127,
-               'KYD': 0.8,
-               'KZT': 147,
-               'LBP': 1500,
-               'LKR': 110,
-               'LTL': 2.5,
-               'LVL': 0.5,
-               'MAD': 8.1,
-               'MKD': 45,
-               'MUR': 29,
-               'MVR': 15,
-               'MXN': 13,
-               'MYR': 3,
-               'NOK': 5.5,
-               'NZD': 1.2,
-               'OMR': 0.3,
-               'PAB': 1,
-               'PEN': 2.7,
-               'PHP': 43,
-               'PKR': 86,
-               'PLN': 3,
-               'PYG': 4190,
-               'QAR': 3.6,
-               'RON': 3.1,
-               'RUB': 30,
-               'SAR': 3.7,
-               'SEK': 6.5,
-               'SGD': 1.2,
-               'SVC': 8.7,
-               'THB': 30,
-               'TJS': 4.7,
-               'TND': 1.4,
-               'TRY': 1.7,
-               'TTD': 6,
-               'TWD': 30,
-               'UAH': 8,
-               'USD': 1,
-               'UYU': 19,
-               'UZS': 1760,
-               'VND': 21000,
-               'XAF': 470,
-               'XCD': 2.7,
-               'XOF': 476,
-               'ZAR': 7.8
-       };
        var error = true;
        var amount = $( 'input[name="amount"]' ).val(); // get the amount
        // Normalize weird amount formats.
@@ -174,11 +87,11 @@
 
        // Check amount is at least the minimum
        var currency_code = $( 'input[name="currency_code"]' ).val();
-       if ( typeof( minimums[currency_code] ) == 'undefined' ) {
-               minimums[currency_code] = 1;
+       if ( typeof( wgCurrencyMinimums[currency_code] ) == 'undefined' ) {
+               wgCurrencyMinimums[currency_code] = 1;
        }
-       if ( amount < minimums[currency_code] || error ) {
-               alert( 'You must contribute at least $1'.replace( '$1', 
minimums[currency_code] + ' ' + currency_code ) );
+       if ( amount < wgCurrencyMinimums[currency_code] || error ) {
+               alert( 'You must contribute at least $1'.replace( '$1', 
wgCurrencyMinimums[currency_code] + ' ' + currency_code ) );
                error = true;
        }
        return !error;

Added: trunk/extensions/DonationInterface/modules/validate.currencyMinimums.js
===================================================================
--- trunk/extensions/DonationInterface/modules/validate.currencyMinimums.js     
                        (rev 0)
+++ trunk/extensions/DonationInterface/modules/validate.currencyMinimums.js     
2011-11-07 00:02:20 UTC (rev 102213)
@@ -0,0 +1,86 @@
+// If you change these, also change in currencyRates.inc.
+window.wgCurrencyMinimums = {
+       'AED': 4,
+       'ARS': 4,
+       'AUD': 1,
+       'BBD': 2,
+       'BDT': 76,
+       'BGN': 1.4,
+       'BHD': 0.4,
+       'BMD': 1,
+       'BND': 1.3,
+       'BOB': 7,
+       'BRL': 1.7,
+       'BSD': 1,
+       'BZD': 2,
+       'CAD': 1,
+       'CHF': 0.9,
+       'CLP': 494,
+       'CNY': 6,
+       'COP': 1910,
+       'CRC': 512,
+       'CZK': 18,
+       'DKK': 5,
+       'DOP': 38,
+       'DZD': 73,
+       'EEK': 11,
+       'EGP': 6,
+       'EUR': 0.7,
+       'GBP': 0.6,
+       'GTQ': 7.8,
+       'HKD': 7.7,
+       'HNL': 19,
+       'HRK': 5,
+       'HUF': 219,
+       'IDR': 8960,
+       'ILS': 3.6,
+       'INR': 49,
+       'JMD': 85,
+       'JOD': 0.7,
+       'JPY': 78,
+       'KES': 97,
+       'KRW': 1127,
+       'KYD': 0.8,
+       'KZT': 147,
+       'LBP': 1500,
+       'LKR': 110,
+       'LTL': 2.5,
+       'LVL': 0.5,
+       'MAD': 8.1,
+       'MKD': 45,
+       'MUR': 29,
+       'MVR': 15,
+       'MXN': 13,
+       'MYR': 3,
+       'NOK': 5.5,
+       'NZD': 1.2,
+       'OMR': 0.3,
+       'PAB': 1,
+       'PEN': 2.7,
+       'PHP': 43,
+       'PKR': 86,
+       'PLN': 3,
+       'PYG': 4190,
+       'QAR': 3.6,
+       'RON': 3.1,
+       'RUB': 30,
+       'SAR': 3.7,
+       'SEK': 6.5,
+       'SGD': 1.2,
+       'SVC': 8.7,
+       'THB': 30,
+       'TJS': 4.7,
+       'TND': 1.4,
+       'TRY': 1.7,
+       'TTD': 6,
+       'TWD': 30,
+       'UAH': 8,
+       'USD': 1,
+       'UYU': 19,
+       'UZS': 1760,
+       'VND': 21000,
+       'XAF': 470,
+       'XCD': 2.7,
+       'XOF': 476,
+       'ZAR': 7.8
+};
\ No newline at end of file

Modified: 
trunk/extensions/DonationInterface/payflowpro_gateway/forms/js/lightbox1.js
===================================================================
--- trunk/extensions/DonationInterface/payflowpro_gateway/forms/js/lightbox1.js 
2011-11-06 23:59:56 UTC (rev 102212)
+++ trunk/extensions/DonationInterface/payflowpro_gateway/forms/js/lightbox1.js 
2011-11-07 00:02:20 UTC (rev 102213)
@@ -204,9 +204,6 @@
        }
        
        function validateAmount(){
-               var minimums = {
-                       'USD' : 1
-               };
                var error = true;
                var amount = $( "input[name='amount']" ).val(); // get the 
amount
                var otherAmount = amount // create a working copy
@@ -222,11 +219,11 @@
                // Check amount is at least the minimum
                var currency = 'USD'; // hard-coded for these forms and tests
                $( "input[name='currency']" ).val( currency );
-               if ( typeof( minimums[currency] ) == 'undefined' ) {
-                       minimums[currency] = 1;
+               if ( typeof( wgCurrencyMinimums[currency] ) == 'undefined' ) {
+                       wgCurrencyMinimums[currency] = 1;
                }
-               if ( amount < minimums[currency] || error ) {
-                       alert( 'You must contribute at least $1'.replace('$1', 
minimums[currency] + ' ' + currency ) );
+               if ( amount < wgCurrencyMinimums[currency] || error ) {
+                       alert( 'You must contribute at least $1'.replace('$1', 
wgCurrencyMinimums[currency] + ' ' + currency ) );
                        error = true;
                }
                return !error;

Modified: 
trunk/extensions/DonationInterface/payflowpro_gateway/forms/js/webitects_2_2step.js
===================================================================
--- 
trunk/extensions/DonationInterface/payflowpro_gateway/forms/js/webitects_2_2step.js
 2011-11-06 23:59:56 UTC (rev 102212)
+++ 
trunk/extensions/DonationInterface/payflowpro_gateway/forms/js/webitects_2_2step.js
 2011-11-07 00:02:20 UTC (rev 102213)
@@ -157,14 +157,10 @@
        $( "#change-amount" ).show();
 }
 function validateAmount() {
-       
-       // TODO: THIS NEEDS TO BE REPLACED WITH KALDARI'S CURRENCIES
-       var minimums = {
-               'USD' : 1,
-               'CAD' : 1
-       };
        var error = true;
        var amount = $( 'input[name="amount"]' ).val(); // get the amount
+       // Normalize weird amount formats.
+       // Don't mess with these unless you know what you're doing.
        amount = amount.replace( /[,.](\d)$/, '\:$10' );
        amount = amount.replace( /[,.](\d)(\d)$/, '\:$1$2' );
        amount = amount.replace( /[,.]/g, '' );
@@ -176,11 +172,11 @@
 
        // Check amount is at least the minimum
        var currency_code = $( 'input[name="currency_code"]' ).val();
-       if ( typeof( minimums[currency_code] ) == 'undefined' ) {
-               minimums[currency_code] = 1;
+       if ( typeof( wgCurrencyMinimums[currency_code] ) == 'undefined' ) {
+               wgCurrencyMinimums[currency_code] = 1;
        }
-       if ( amount < minimums[currency_code] || error ) {
-               alert( 'You must contribute at least $1'.replace( '$1', 
minimums[currency_code] + ' ' + currency_code ) );
+       if ( amount < wgCurrencyMinimums[currency_code] || error ) {
+               alert( 'You must contribute at least $1'.replace( '$1', 
wgCurrencyMinimums[currency_code] + ' ' + currency_code ) );
                error = true;
        }
        return !error;

Modified: 
trunk/extensions/DonationInterface/payflowpro_gateway/forms/js/webitects_2_3step.js
===================================================================
--- 
trunk/extensions/DonationInterface/payflowpro_gateway/forms/js/webitects_2_3step.js
 2011-11-06 23:59:56 UTC (rev 102212)
+++ 
trunk/extensions/DonationInterface/payflowpro_gateway/forms/js/webitects_2_3step.js
 2011-11-07 00:02:20 UTC (rev 102213)
@@ -174,14 +174,10 @@
        $( "#change-amount" ).show();
 }
 function validateAmount() {
-       
-       // TODO: THIS NEEDS TO BE REPLACED WITH KALDARI'S CURRENCIES
-       var minimums = {
-               'USD' : 1,
-               'CAD' : 1
-       };
        var error = true;
        var amount = $( 'input[name="amount"]' ).val(); // get the amount
+       // Normalize weird amount formats.
+       // Don't mess with these unless you know what you're doing.
        amount = amount.replace( /[,.](\d)$/, '\:$10' );
        amount = amount.replace( /[,.](\d)(\d)$/, '\:$1$2' );
        amount = amount.replace( /[,.]/g, '' );
@@ -193,11 +189,11 @@
 
        // Check amount is at least the minimum
        var currency_code = $( 'input[name="currency_code"]' ).val();
-       if ( typeof( minimums[currency_code] ) == 'undefined' ) {
-               minimums[currency_code] = 1;
+       if ( typeof( wgCurrencyMinimums[currency_code] ) == 'undefined' ) {
+               wgCurrencyMinimums[currency_code] = 1;
        }
-       if ( amount < minimums[currency_code] || error ) {
-               alert( 'You must contribute at least $1'.replace( '$1', 
minimums[currency_code] + ' ' + currency_code ) );
+       if ( amount < wgCurrencyMinimums[currency_code] || error ) {
+               alert( 'You must contribute at least $1'.replace( '$1', 
wgCurrencyMinimums[currency_code] + ' ' + currency_code ) );
                error = true;
        }
        return !error;


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to