Revision 82494 of "Template:2010/Donate-nowGB-DDTest2" on foundationwiki

<html>
<form id="wmh_paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="[email protected]" />
<input type="hidden" name="item_name" value="Donation to Wikimedia UK" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="return" value="http://uk.wikimedia.org/wiki/Thanks" />
<input type="hidden" name="custom" value="" />
<input type="hidden" name="Payer_reference" value="" /> <!-- for Direct Debit -->
<p style="font-weight: bold;">Select your gift amount</p>
<div id="amount-box" style="font-size: 100%; padding: 0; margin-left: -5px; "> 
<table id="amount-table" style="background-color: #CCE7CD;">
  <tr>
    <td style="white-space:nowrap;">
      <label><input type="radio" name="amount" value="5.00" />£5</label>
    </td>
    <td style="white-space:nowrap;">
      <label><input type="radio" name="amount" value="10.00" />£10</label>
    </td>
    <td style="white-space:nowrap;">
      <label><input type="radio" name="amount" value="20.00" />£20</label>
    </td>
  </tr>
  <tr>
    <td style="white-space:nowrap;">
      <label><input type="radio" name="amount" value="50.00" />£50</label>
    </td>
    <td style="white-space:nowrap;">
      <label><input type="radio" name="amount" value="100.00" />£100</label>
    </td>
    <td style="white-space:nowrap;">
      <label><input type="radio" name="amount" value="200.00" />£200</label>
    </td>
    <td style="white-space:nowrap;">
      <label><input type="radio" name="amount" value="" id="wmh_obutton" /></html>{{{donate-amount-other|Other}}}<html>: £</label>
      <input size="2" name="customAmount" onfocus="this.form.wmh_obutton.checked=true;" onchange="this.form.wmh_obutton.value = this.form.wmh_otext.value" id="wmh_otext" />
    </td>
  </tr>
</table>
</div>
<br />


<b>Frequency:</b><br />
<input type="radio" value="O" name="frequency_type" id="frequency-type-O" onchange="updateButtons()" checked="true" />
<label for="frequency-type-O">One-time</label>

<input type="radio" value="M" name="frequency_type" id="frequency-type-M" onchange="updateButtons()" />
<label for="frequency-type-M">Monthly</label>

<input type="radio" value="Q" name="frequency_type" id="frequency-type-Q" onchange="updateButtons()" />
<label for="frequency-type-Q">Quarterly</label>
<br />
<br />

<input type="button" id="paypal-donate-button" value="</html>{{{paypal-label|Donate via PayPal/Credit Card}}}<html>" style="margin: 0 auto;" onclick="submitForm('PayPal');" />
<input type="button" id="directdebit-donate-button" value="Donate by Direct Debit" style="margin: 0 auto;" onclick="submitForm('DirectDebit');" />

<br />
<br />
<div class="donate-body-small"><input type="checkbox" style="margin:0;" name="email-opt" id="input_email" checked="checked" />&nbsp;&nbsp;<label for="input_email"></html>{{{email-option|I agree to receive occasional updates from <br/>Wikimedia UK.}}}<html></label></div> 

<div style="text-align:center">*&nbsp;&nbsp;*&nbsp;&nbsp;*</div>
<div class="donate-body-small"></html>{{{privacy-policy-text|<html>Your personal data is subject to our <a href="http://uk.wikimedia.org/wiki/Donor_Privacy_Policy" title="Donor Privacy Policy">privacy policy</a></html>. <br/>For more information on other ways to give, <br/><html> <a target="_new" href="http://uk.wikimedia.org/wiki/Other_Ways_to_Give"> click here</a></html>.}}}<html></div>
</form>


<script type="text/javascript">
var wmh_paypal = document.getElementById('wmh_paypal');
var wmh_obutton = document.getElementById('wmh_obutton');
var wmh_otext = document.getElementById('wmh_otext');

</script>
</html>

{{{chapter-text|}}}

<html>
<script type="text/javascript">

function updateButtons() {
  if (document.getElementById('frequency-type-O').checked) {
      $('#paypal-donate-button').show();
      $('#directdebit-donate-button').hide();
      wmh_paypal.action = 'https://www.paypal.com/cgi-bin/webscr';
  } else {
      $('#paypal-donate-button').hide();
      $('#directdebit-donate-button').show();
      wmh_paypal.action = 'http://donate.wikimedia.org.uk/dd/index.php';
  }
}

function submitForm(type) {
  
  // Validate
  var amount = null;
  for ( var i = 0; i < wmh_paypal.amount.length; i++ ) {
    if ( wmh_paypal.amount[i].checked ) {
      amount = wmh_paypal.amount[i].value;
    }
  }
  if (amount == null || amount < 1) {
    alert('You must contribute at least £1');
    return;
  }

  var check_email = document.getElementById('input_email'); 
  wmh_paypal.custom.value = getQuerystring( 'utm_medium' ) + '.' + getQuerystring( 'utm_campaign' ) + '.' + getQuerystring( 'utm_source' ) + '.' + getLandingPage() + '.' + check_email.checked;
  
  if (type == 'DirectDebit') {
      wmh_paypal.Payer_reference.value = getQuerystring( 'utm_medium' ) + '.' + getQuerystring( 'utm_campaign' ) + '.' + getQuerystring( 'utm_source' ) + '.' + getLandingPage();
      wmh_paypal.action = 'http://donate.wikimedia.org.uk/dd/index.php';
  } else {
      wmh_paypal.action = 'https://www.paypal.com/cgi-bin/webscr';
  }
  
  wmh_paypal.submit();
}

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 = "</html>{{{landing-page|default}}}<html>";

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

jQuery(document).ready( function( $ ) {
  updateButtons();
} );


</script>
</html><noinclude>
[[Category:Fundraising templates|{{PAGENAME}}]]
</noinclude>