Difference between revisions 107752 and 115067 on foundationwiki

{{proposed deletion}}

<html>
<style type="text/css">
#amount-box td {
  white-space: nowrap;
}
</style>
<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; height: 5em;"> 

  <table id="oneoff-amount-table" style="display: none;">
    <tr>
      <td>
        <label><input type="radio" name="amount" value="5.00" />£5</label>
      </td>
      <td>
        <label><input type="radio" name="amount" value="10.00" />£10</label>
      </td>
      <td>
        <label><input type="radio" name="amount" value="20.00" />£20</label>
      </td>
    </tr>
    <tr>
      <td>
        <label><input type="radio" name="amount" value="50.00" />£50</label>
      </td>
      <td>
        <label><input type="radio" name="amount" value="100.00" />£100</label>
      </td>
      <td>
        <label><input type="radio" name="amount" value="200.00" />£200</label>
      </td>
      <td>
        <label><input type="radio" name="amount" value="" id="other_button" /></html>Other<html>: £</label>
        <input size="2" name="customAmount" id="other_amount" onfocus="this.form.other_button.checked=true;" onchange="this.form.other_button.value = this.form.other_amount.value" />
      </td>
    </tr>
  </table>

  <table id="dd-amount-table" style="width: 70%;">
    <tr>
      <td>
        <label><input type="radio" name="amount" id="dd-amount-0" value="2.00" />£2</label>
      </td>
      <td>
        <label><input type="radio" name="amount" id="dd-amount-1" value="3.00" />£3</label>
      </td>
      <td>
        <label><input type="radio" name="amount" id="dd-amount-2" value="5.00" />£5</label>
      </td>
      <td>
        <label><input type="radio" name="amount" id="dd-amount-3" value="10.00" />£10</label>
      </td>
    </tr>
    <tr>
      <td colspan="4">
        <label><input type="radio" name="amount" value="" id="dd_other_button" /></html>Other<html>: £</label>
        <input size="2" name="customAmount" id="dd_other_amount" onfocus="this.form.dd_other_button.checked=true;" onchange="this.form.dd_other_button.value = this.form.dd_other_amount.value" />
      </td>
    </tr>  
  </table>

  <div id="dd-frequency" style="display: none;">
    Frequency:
    <input type="radio" value="M" name="frequency_type" id="frequency-type-M" checked="checked" />
    <label for="frequency-type-M">Monthly</label>

    <input type="radio" value="Q" name="frequency_type" id="frequency-type-Q" />
    <label for="frequency-type-Q">Quarterly</label>
  </div>

</div>

<br />

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

<div id="type-checkbox" class="donate-body-small">
  <!-- <input type="checkbox" name="dd-please" id="dd-please-checkbox" onchange="changeType()" /><label for="dd-please-checkbox">I'd prefer to make a regular donation</label><br /> -->
  <input type="checkbox" name="oneoff-please" id="oneoff-please-checkbox" onchange="changeType()" /><label for="oneoff-please-checkbox">I'd prefer to make a one off donation</label><br />
</div>

<div style="text-align:center">*&nbsp;&nbsp;*&nbsp;&nbsp;*</div>

<div class="donate-body-small">
  <input type="checkbox" name="email-opt" id="input_email" checked="checked" /><label for="input_email"></html>{{{email-option|I agree to receive occasional updates from <br/>Wikimedia UK.}}}<html></label>
  <br /><br />
  </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>

</html>

{{{chapter-text|}}}

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

function changeType() {
  if (document.getElementById('oneoff-please-checkbox').checked == false) {
      // DirectDebit mode
      $('#Make_your_donation_now').html('Make a regular donation');

      $('#oneoff-amount-table').hide();
      $('#dd-amount-table').show();
      
      $('#dd-frequency').show();
      
      $('#dd-donate-button').show();
      $('#paypal-donate-button').hide();
            
      wmh_paypal.action = 'http://donate.wikimedia.org.uk/dd/index.php';      
  } else {
      // Oneoff / PayPal mode
      $('#Make_your_donation_now').html('Make your donation now');
      
      $('#oneoff-amount-table').show();
      $('#dd-amount-table').hide();
      
      $('#dd-frequency').hide();
      
      $('#dd-donate-button').hide();
      $('#paypal-donate-button').show();
      
      wmh_paypal.action = 'https://www.paypal.com/cgi-bin/webscr';
  }
  
  // Reset selected
  for ( var i = 0; i < wmh_paypal.amount.length; i++ ) {
    wmh_paypal.amount[i].checked = ""
  }
  
}

function validateForm() {
  // 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 false;
  } else {
      return true;
  }

}

function submitForm(type) {  
  
  if ( validateForm() ) {
    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( $ ) {
  changeType()
} );
</script>
</html><noinclude>
[[Category:Fundraising templates|{{PAGENAME}}]]
[[Category:Maintained by Advancement department|{{PAGENAME}}]]
</noinclude>