Professional Documents
Culture Documents
Gram Rol Script
Gram Rol Script
click(function() {
var winWinRoll = $('#customSwitch12').prop("checked");
grecaptcha.ready(function() {
grecaptcha.execute('6LcQG_4UAAAAAIT1oxs25XjOXXcKwW1h1gkdxowr',
{action: 'roll'}).then(function(token) {
$.ajax({
url: '/roll',
type: 'POST',
data: {isWinWinRoll: winWinRoll, reCaptchaToken: token},
beforeSend: function() {
},
success: function(result) {
console.log(result);
$('#roll-button').attr('disabled', true);
$('#win-number').html('');
$('.captha').toggle();
let timerId = setInterval(function(){
var rand = Math.floor((Math.random() * 1000) +
1);
var r1 = 1000 - rand;
rand = rand + r1;
$('#win-gram').html(rand);
}, 40);
setTimeout(() =>
{ clearInterval(timerId);console.log('stop'); }, 3000);
progressUp(result['levelPoints']);
setTimeout(function(){
$('#win-number').html('Number: ' +
result['randomValue']);
setTimeout(function(){
$("#user-list li:last-child").remove();
}, 100);
},50);
}
$('#next-roll-time').html(time);
var interval = setInterval(function() {
timerFun($('#next-roll-time'));
}, 1000);
$('#next-roll-text').html('Next roll');
$('.cap4').toggle();
$('#total-rolls').html(Number($('#total-
rolls').html()) + Number(1));
if (result['wonAmount'] > 0) {
$('#total-won').html( ( Number($('#total-
won').html()) + Number(result['wonAmount']) ).toFixed(1) );
}
},3000);
},
error: function(reason) {
console.log(reason['responseJSON']['reason']);
$('#roll-button').attr('disabled', true);
Swal.fire({
title: "Error!",
text: reason['responseJSON']['reason'],
type: "error",
confirmButtonClass: 'btn btn-primary',
buttonsStyling: false,
});
}
});
});
});
});
function rand(1000){
return Math.ceil((max-min)*Math.random()+min);
}
$('#user-list .timeline-info').each(function() {
var nameLenght = allNames.length - 1;
var winNumb = 1000; // win number
var winWin = 2;
if (winWin == 1) {
if (winNumb <= 980) {
var winGram = 0.1;
} else if ((winNumb >= 981) && (winNumb <= 993) ) {
var winGram = 1;
} else if ((winNumb >= 994) && (winNumb <= 997) ) {
var winGram = 10;
} else if ((winNumb >= 998) && (winNumb <= 999) ) {
var winGram = 100;
} else if (winNumb == 1000 ) {
var winGram = 1000;
}
} else {
if ((winNumb >= 701) && (winNumb <= 850) ) {
var winGram = 1;
} else if ((winNumb >= 851) && (winNumb <=950) ) {
var winGram = 10;
} else if ((winNumb >= 951) && (winNumb <= 1000) ) {
var winGram = 100;
} else {
var winGram = 0.1;
}
}
$('p', this).html(allNames[rand(0,nameLenght)]);
$('span', this).html('Won ' + winGram + ' Gram - lucky number
is ' + winNumb);
/*Won 0.01 Gram - lucky number is 126*/
});
function userWin(){
setTimeout(function(){
$("#user-list li:first-child").slideToggle();
$("#user-list li:last-child").slideToggle();
setTimeout(function(){
$("#user-list li:last-child").remove();
}, 100);
},50);
};
setTimeout(function() {
(function() {
var x = rand(1000, 5000); //add user interval
//console.log(x);
userWin();
setTimeout(arguments.callee, x);
})()
}, 2000);