Professional Documents
Culture Documents
Free Roll
Free Roll
$('#customSwitch12').on('change',function(){
var winWinRoll = $(this).prop("checked");
var winWinAwards = [[1, 500, 0.0], [501, 993, 0.1], [994, 997,
1.0], [998, 999, 10.0], [1000, 1000, 100.0]];
var notWinWinAwards = [[1, 500, -10.0], [501, 700, -1.0], [701,
850, 1.0], [851, 950, 10.0], [951, 1000, 100.0]];
if (winWinRoll == true) {
$('.win-price td:last-child').each(function(){
var price = $(this).html().split(' ');
$(this).html(coefficientTrue[i] +' '+ price[1]);
i++;
});
$('.win-price td:first-child').each(function(){
$(this).html(luckyNumberTrue[j]);
j++;
})
} else {
$('.win-price td:last-child').each(function(){
var price = $(this).html().split(' ');
$(this).html( coefficientFalse[i] + ' ' + price[1]);
++i;
});
$('.win-price td:first-child').each(function(){
$(this).html(luckyNumberFalse[j]);
j++;
})
}
});
$('#customSwitch12').change()
console.log($('#next-roll-time').html());
var timeToNextRoll = $('#next-roll-time');
if (timeToNextRoll.html() == '0.0') {
timeToNextRoll.html('Time to Roll!');
timeToNextRoll.replaceWith('<h3 class="text-bold-700" id="next-
roll-time">Time to Roll!</h3>');
$('#win-gram').html(' ');
$('#win-number').html(' ');
$('#next-roll-text').html(' ');
$('#roll-button').attr('disabled', false);
$('#customSwitch12').attr('disabled', false);
$('.captha').toggle();
} else {
}, 1000);
}
$('#roll-button').click(function() {
$('#roll-button').attr('disabled', true);
$('#customSwitch12').attr('disabled', true);
var winWinRoll = $('#customSwitch12').prop("checked");
grecaptcha.ready(function() {
grecaptcha.execute('6LcctggbAAAAAGZB1qUdpE1C3rJvaaQZb3aeUqCN',
{action: 'roll'}).then(function(token) {
$.ajax({
url: '/roll',
type: 'POST',
data: {isWinWinRoll: winWinRoll, reCaptchaToken: token},
beforeSend: function() {
},
success: function(result) {
console.log(result);
$('#win-number').html('');
$('.captha').toggle();
let timerId = setInterval(function(){
var rand = Math.floor((Math.random() * 1000) +
1);
var r1 = 1000 - rand ;
rand = r1;
$('#win-gram').html(rand);
}, 40);
setTimeout(() =>
{ clearInterval(timerId);console.log('stop'); }, 3000);
progressUp(result['levelPoints']);
setTimeout(function(){
$('#win-number').html('Number: ' + 1000);
setTimeout(function(){
$("#user-list li:first-
child").slideToggle();
$("#user-list li:last-
child").slideToggle();
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 (100 > 0) {
$('#total-won').html( ( Number($('#total-
won').html()) + Number(100) ).toFixed(1) );
}
},3000);
},
error: function(reason) {
console.log(reason['responseJSON']['reason']);
$('#roll-button').attr('disabled', true);
$('#customSwitch12').attr('disabled', true);
Swal.fire({
title: "Error!",
text: reason['responseJSON']['reason'],
type: "error",
confirmButtonClass: 'btn btn-primary',
buttonsStyling: false,
});
}
});
});
});
});
$('#user-list .timeline-info').each(function() {
var nameLenght = allNames.length - 1;
var winWinAwards = [[1, 500, 0.0], [501, 993, 0.1], [994, 997,
1.0], [998, 999, 10.0], [1000, 1000, 100.0]];
var notWinWinAwards = [[1, 500, -10.0], [501, 700, -1.0], [701,
850, 1.0], [851, 950, 10.0], [951, 1000, 100.0]];
if (winGram < 0) {
winGram = winWinAwards[0][2];
winNumb = rand(winWinAwards[0][0], winWinAwards[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(){
var winWinAwards = [[1, 500, 0.0], [501, 993, 0.1], [994, 997,
1.0], [998, 999, 10.0], [1000, 1000, 100.0]];
var notWinWinAwards = [[1, 500, -10.0], [501, 700, -1.0], [701,
850, 1.0], [851, 950, 10.0], [951, 1000, 100.0]];
var winWin = 2;
if (winWin == 1) {
if (winNumb >= winWinAwards[0][0] && winNumb <=
winWinAwards[0][1]) {
var winGram = winWinAwards[0][2];
} else if (winNumb >= winWinAwards[1][0] && winNumb <=
winWinAwards[1][1]) {
var winGram = winWinAwards[1][2];
} else if (winNumb >= winWinAwards[2][0] && winNumb <=
winWinAwards[2][1]) {
var winGram = winWinAwards[2][2];
} else if (winNumb >= winWinAwards[3][0] && winNumb <=
winWinAwards[3][1]) {
var winGram = winWinAwards[3][2];
} else if (winNumb >= winWinAwards[4][0] && winNumb <=
winWinAwards[4][1]) {
var winGram = winWinAwards[4][2];
}
} else {
if (winNumb >= notWinWinAwards[0][0] && winNumb <=
notWinWinAwards[0][1]) {
var winGram = notWinWinAwards[0][2];
} else if (winNumb >= notWinWinAwards[1][0] && winNumb <=
notWinWinAwards[1][1]) {
var winGram = notWinWinAwards[1][2];
} else if (winNumb >= notWinWinAwards[2][0] && winNumb <=
notWinWinAwards[2][1]) {
var winGram = notWinWinAwards[2][2];
} else if (winNumb >= notWinWinAwards[3][0] && winNumb <=
notWinWinAwards[3][1]) {
var winGram = notWinWinAwards[3][2];
} else if (winNumb >= notWinWinAwards[4][0] && winNumb <=
notWinWinAwards[4][1]) {
var winGram = notWinWinAwards[4][2];
}
}
if (winGram < 0) {
winGram = winWinAwards[0][2];
winNumb = rand(winWinAwards[0][0], winWinAwards[0][1]);
}
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);
});
</script>