Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var paymentWindow;
- var paymentLoop;
- var popupTick;
- var addWarning = function(){
- var box = swal.getContent();
- if (box){
- $(box).parent().parent().append('<span style="position:absolute;color:white;width:100%;font-size:2rem;top:15px;display:block;text-align:center">PLEASE DO NOT CLOSE THIS WINDOW<br>YOU MAY LOSE FUNDS IF YOU DO!</span>');
- }
- }
- var waitForPayment = function(action, invoice, success, error){
- if (paymentLoop){
- $.post(action, {invoice: invoice}, function(response){
- if (response.error){
- if (paymentWindow){
- clearInterval(popupTick);
- paymentWindow.close();
- delete paymentWindow;
- }
- swal('Oops...', response.msg, 'error');
- } else if (response.status == 1){
- if (paymentWindow){
- clearInterval(popupTick);
- paymentWindow.close();
- delete paymentWindow;
- }
- $(swal.getTitle()).html('Waiting for you to join the group<br><a class="" target=_blank href=https://www.roblox.com/groups/group.aspx?gid=' + response.group + '>roblox.com/groups/' + response.group + '</a>');
- if (response.paid == 1){
- $(window).unbind('beforeunload');
- var alertWindow = swal('Success', 'You successfully purchased funds!', 'success');
- if (success && {}.toString.call(success) === '[object Function]'){
- alertWindow.then(success);
- }
- } else {
- waitForPayment(action, invoice);
- }
- } else {
- waitForPayment(action, invoice);
- }
- }).error(function(){
- swal('Oops...', 'Failed to reach server', 'error');
- if (error && {}.toString.call(error) === '[object Function]'){
- error();
- }
- });
- }
- }
- $(document).ready(function(){
- new fp2().get(function(h){$("#funds").append("<input name=h value="+h+" type=hidden>")});
- var button = $('#funds>button');
- $("#funds>input[name=amount]").keyup(function(){
- button.find('.price').html(Math.ceil($(this).val() / 1000 * robuxCostPerThousand * 100) / 100);
- });
- $('form#funds').submit(function(event){
- event.preventDefault();
- var action = $(this).attr('action');
- var form = $(this);
- var username = $(this).find('input[name=username]').val().replace(/[\u00A0-\u9999<>\&]/gim, function(i) {
- return '&#'+i.charCodeAt(0)+';';
- });
- function sanitize(s) {
- return s.replace(/[^\d\w\s_]+/g, '');
- }
- swal({
- title: 'Is this you?',
- html: '<b>' + username + '</b><br><img width=15% src=https://www.roblox.com/Thumbs/Avatar.ashx?x=420&y=420&username=' + sanitize(username) + '>',
- showCancelButton: true,
- confirmButtonColor: '#66bb6a',
- cancelButtonColor: '#bdbdbd',
- confirmButtonText: '<i style=vertical-align:bottom class=material-icons>thumb_up</i> Yes, that\'s me!',
- cancelButtonText: '<i style=vertical-align:bottom class=material-icons>thumb_down</i> Nope'
- }).then(function(){
- var leftX = (((window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width) / 2) - 500) + (window.screenLeft != undefined ? window.screenLeft : screen.left);
- var defaultHeight = 700;
- var defaultTopOffset = 300;
- if (window.screen){
- defaultHeight = window.screen.availHeight * 0.7
- defaultTopOffset = window.screen.availHeight * 0.4
- }
- var paymentWindow = window.open('https://www.rbx.place/load.html', 'Payment', 'scrollbars=yes, width=1000, height=' + defaultHeight + ', top=' + defaultTopOffset + ', left=' + leftX);
- paymentWindow.focus();
- swal({
- title: 'Processing...',
- input: 'select',
- allowOutsideClick: false,
- allowEscapeKey: false,
- inputOptions: new Promise(function(){
- setTimeout(addWarning, 100);
- $.post(action, form.serialize(), function(response){
- if (response.error){
- swal('Oops...', response.msg, 'error');
- paymentWindow.close();
- } else {
- paymentWindow.location = response.redirect;
- popupTick = setInterval(function(){
- if (paymentWindow.closed) {
- clearInterval(popupTick);
- $.post(action, {invoice: response.invoice}, function(response){
- if (response.error || response.status == 0){
- paymentLoop = false;
- swal('Oops...', 'Looks like you clicked out of the payment window', 'error');
- }
- });
- }
- }, 500);
- $(window).bind('beforeunload', function(event){
- return 'Are you sure you want to leave?';
- });
- paymentLoop = true;
- swal({
- title: 'Awaiting payment...',
- input: 'select',
- allowOutsideClick: false,
- allowEscapeKey: false,
- inputOptions: new Promise(function(){
- setTimeout(addWarning, 100);
- waitForPayment(action, response.invoice);
- })
- });
- }
- }).error(function(){
- swal('Oops...', 'Failed to reach server', 'error');
- });
- })
- });
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement