Template:2011FR/lp-form-forcepaypal-2



var amount = null;

function validateForm( form ) {

var minimums = { 'USD' : 1, 'GBP' : 1, // $1.26 'EUR' : 1, // $1.26 'AUD' : 2, // $1.35 'CAD' : 1, // $0.84 'CHF' : 1, // $0.85 'CZK' : 20, // $1.03 'DKK' : 5, // $0.85 'HKD' : 10, // $1.29 'HUF' : 200, // $0.97 'JPY' : 100, // $1 'NZD' : 2, // $1.18 'NOK' : 10, // $1.44 'PLN' : 5, // $1.78 'SGD' : 2, // $1.35 'SEK' : 10, // $1.28 'ILS' : 5 // $1.39 };

var error = true;

// Get amount selection for ( var i = 0; i < form.amount.length; i++ ) { if ( form.amount[i].checked ) { amount = form.amount[i].value; } }  if ( form.amountGiven.value != "" ) { var otherAmount = form.amountGiven.value; otherAmount = otherAmount.replace(/[,.](\d)$/, '\:$10'); otherAmount = otherAmount.replace(/[,.](\d)(\d)$/, '\:$1$2'); otherAmount = otherAmount.replace(/[\$,.]/g, ''); otherAmount = otherAmount.replace(/:/, '.'); form.amountGiven.value = otherAmount; amount = otherAmount; }

// Check amount is a real number error = ( amount == null || isNaN( amount ) || amount.value <= 0 ); // Check amount is at least the minimum var currency = form.currency_code.value; if ( typeof( minimums[currency] ) == 'undefined' ) { minimums[currency] = 1; } if ( amount < minimums[currency] || error ) { alert( ' '.replace('$1', minimums[currency] + ' ' + currency ) ); error = true; } return !error; }

function DefaultSubmit(formfield,Action) { var keycode; if (window.event) keycode = window.event.keyCode; else if (Action) keycode = Action.which; else return true;

if (keycode == 13) { redirectPayment; return false; } else return true; }

function redirectPayment(i) { var recurring = document.createElement("input"); recurring.type = "hidden"; recurring.name = "recurring_paypal"; recurring.id = "recurring-hidden"; recurring.value = "true"; document.paypalcontribution.appendChild(recurring);

//if i == 1 var paymentType ="cc"; var action_url = "https://payments.wikimedia.org/index.php/Special:PayflowProGateway?uselang= \x26masthead=\x26form_name=\x26text_template=\x26language=\x26ffname= " ; //TESLA TESTING //var action_url = "https://test-payments.tesla.usability.wikimedia.org/index.php/Special:PayflowProGateway?uselang= \x26masthead=\x26form_name=\x26text_template=\x26language=\x26ffname= " ; // Staging //var action_url = "https://payments4.wikimedia.org/index.php/Special:PayflowProGateway?uselang= \x26masthead=\x26form_name=\x26text_template=\x26language=\x26ffname= " ;

if (i==2) { paymentType = "pp"; document.paypalcontribution.removeChild(document.getElementById("recurring-hidden")); action_url="https://wikimediafoundation.org/wiki/Special:ContributionTracking/ "; }

if (i==3) { paymentType = "rpp"; action_url="https://wikimediafoundation.org/wiki/Special:ContributionTracking/ "; } document.paypalcontribution.action = action_url; document.paypalcontribution.utm_source.value = getQuerystring( 'utm_source' ) + '.' + getLandingPage + '.' + paymentType; if (validateForm(document.paypalcontribution)) { if(typeof(OWA) !== 'undefined'){OWATracker.shareStateByPost( document.paypalcontribution );} document.paypalcontribution.submit; } }         

 







function displayForcedChoice{ if(validateForm(document.paypalcontribution)) {   document.getElementById("floating-amount-field").value = amount; document.getElementById("floating-screen").style.display = "block";

var element = document.getElementById("floating-paypal"); element.style.display = "block"; } }

function hideForcedChoice{ document.getElementById("floating-screen").style.display = "none"; document.getElementById("floating-paypal").style.display = "none"; }

 { display: none; position: fixed; background-color: #ffffff; opacity: 0.70; filter:alpha(opacity=70); filter: “alpha(opacity=70)”; top: 0px; left: 0px; width: 100%; height: 100%; z-index: 1000; }
 * 1) floating-screen

{ background-color: #f6f6f6; border-width: 0.3em; border-style: solid; border-color: #999999; display: none; position: fixed; width: 20em; margin-left: -12em; margin-top: -10em; padding: 2em; border-radius: 0.5em; -moz-border-radius: 0.5em; -webkit-border-radius: 0.5em; /* opacity: 0.0; filter:alpha(opacity=0); filter: “alpha(opacity=0)”; top: 50%; left: 50%; z-index: 1001; }
 * 1) floating-paypal

.floating-div { padding: 0.5em; }

.button-div { padding: 0.2em; }

.floating-button{ height: 2em; width: 100%; }

{ float: right; margin-right: -1em; margin-top: -3.5em; }
 * 1) floating-cancel2

{ color: #777777; font-size: 0.8em; height: 2em; border-color: #999999; border-radius: 1em; -moz-border-radius: 1em; -webkit-border-radius: 1em; border-style: solid; border-width: 0.1em; }
 * 1) floating-button-cancel

{ color: #cc0000; font-size: 0.8em; background-color: #c5c5c5; border-width: 0.3em; border-style: solid; border-color: #999999; float: right; z-index: 1002; margin-top: -3.6em; margin-right: -1em; border-radius: 1em; -moz-border-radius: 1em; -webkit-border-radius: 1em; padding-left: 1em; padding-right: 1em; vertical-align: middle; text-align: center; }
 * 1) floating-cancel

background: #999999; color: #ff0000; }
 * 1) floating-cancel:hover {

{ font-size: 1.2em; font-weight: bold; }
 * 1) floating-title

{ font-size: 0.8em; }
 * 1) floating-body, #floating-secure

{ font-size: 0.8em; font-weight: bold; }
 * 1) floating-amount

border-color: #C5C5C5; border-style: solid; border-width: 1px; height: 1.5em; width: 4em; vertical-align: middle; text-align: center; }
 * 1) floating-amount-field{

}
 * 1) floating-button-monthly{

}
 * 1) floating-button-onetime{

<div id="floating-cancel" onclick="redirectPayment('2')"> No thanks X Make it monthly? Monthly donations are processed on the 13th of every month. You may cancel at any time. Donation amount: $<input type="text" id="floating-amount-field" value="" /> <input type="button" class="floating-button" id="floating-button-monthly" value="Sure, make it monthly" onclick="redirectPayment('3')"; /> <input type="button" class="floating-button" id="floating-button-ontime" value="No, make a one-time donation" onclick="redirectPayment('2')"; /> Your credit card will be securely processed.

* *  * <p style="margin-top: 1em;">

<script type="text/javascript"> function getQuerystring( key ) { key = key.replace( /[\[]/, '\\\[' ).replace( /[\]]/, '\\\]' ); var regex = new RegExp( '[\\?&]' + key + '=([a-zA-Z0-9\_\-]*)' ); var qs = regex.exec( window.location.search ); return qs == null ? '' : qs[1]; }

function getLandingPage { var path = " ";

if( path == "default") { pathArray = window.location.pathname.split( '/' ); return pathArray[2]; } else return path; }

function updateCC( currency ) { if ( ( currency == 'AUD' ) || ( currency == 'CAD' ) || ( currency == 'EUR' ) ||    (currency == 'GBP' ) || ( currency == 'JPY' ) || ( currency == 'USD' ) ) { document.getElementById('cc-donate-button').style.display = " "; } else { document.getElementById('cc-donate-button').style.display = "none"; } }

document.paypalcontribution.utm_medium.value = getQuerystring( 'utm_medium' ); document.paypalcontribution.utm_campaign.value = getQuerystring( 'utm_campaign' ); document.paypalcontribution.referrer.value = document.referrer;

( function( $ ) { $(document).ready(function{ var currency = $("#input_currency_code").val; updateCC(currency); }) } )( jQuery );