Skip to content

Instantly share code, notes, and snippets.

@ajvpot
Created March 17, 2013 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajvpot/5182386 to your computer and use it in GitHub Desktop.
Save ajvpot/5182386 to your computer and use it in GitHub Desktop.
<script type="text/rocketscript">
$(function() {
$('#lr').css('opacity', '0.4');
var price = 9.00;
var paymenttype = 'paypal';
var one_month = 9.00;
var lifetime = 3;
var sixty_seconds = 1.00;
var concurrent_attack = 20.00;
$('#buy').change(function() {
length = (($('#length').val() - 60) / 60) * sixty_seconds;
concurrent_attacks = ($('#attacks').val() - 1) * concurrent_attack;
if ($('#subscription').val() == "1") {
$('#price').text('$' + (length + concurrent_attacks + one_month));
price = (length + concurrent_attacks + one_month);
} else {
$('#price').text('$' + (((concurrent_attacks + one_month) * lifetime) + length));
price = (((concurrent_attacks + one_month) * lifetime) + length);
}
});
$('.payment').click(function() {
var paymenttypes = ['#paypal', '#lr'];
for (var i = 0; i < paymenttypes.length; i++) {
if ($(paymenttypes[i]).attr('id') == $(this).attr('id')) {
$(paymenttypes[i]).css('opacity', '1.0');
$('#payment').val(paymenttypes[i].substring(1));
} else
$(paymenttypes[i]).css('opacity', '0.4');
}
paymenttype = $(this).attr('id');
});
$('#processpayment').click(function() {
var username = $('#username').val();
var password = $('#password').val();
var cpassword = $('#cpassword').val();
var subscription = $('#subscription').val();
var attacks = $('#attacks').val();
var length = $('#length').val();
if (username == '') {
$('#paymentresponse').html('<font color="red">You must enter an username.</font>');
return false;
}
if (password == '') {
$('#paymentresponse').html('<font color="red">You must enter a password.</font>');
return false;
}
if (cpassword == '') {
$('#paymentresponse').html('<font color="red">You must confirm your password.</font>');
return false;
}
if (password != cpassword) {
$('#paymentresponse').html('<font color="red">Your passwords do not match.</font>');
return false;
}
var data = 'username='+username+'&password='+password+'&cpassword='+cpassword+'&subscription='+subscription+'&attacks='+attacks+'&price='+price+'&paymenttype='+paymenttype+'&length='+length;
$.ajax({
type: 'POST',
data: data,
url: 'ajax/processpayment.php',
success: function(response) {
$('#paymentresponse').html(response);
}
});
return false;
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment