$(document).ready(function() {
var socket = io.connect(':8080');
socket.on('updateBalance', function(data) {
if(USER_ID == data.id) updateBalance(data.balance, data.balance_new); if(USER_ID == data.id) $('#balanceVal').val(data.balance_new);
});
socket.on('online', function(data) {
$('#online').text(data);
});
socket.on('message', function(msg) {
if(USER_ID == msg.user) {
$.wnoty({
position : 'top-right',
type: msg.type,
message: msg.msg
});
}
});
socket.on('dice', function (data) {
var html = '<tr><td class="text-truncate ">'+ data.username +'</td><td class="text-truncate ' + (data.win ? 'text-success' : 'text-danger') + '" style="font-weight:600;">'+ data.num +'</td><td class="text-truncate ">'+ data.range +'</td><td class="text-truncate ">'+ parseFloat(data.sum).toFixed(2) +'</td><td class="text-xs-center font-small-2"><div class="progress"><div class="progress-bar bg-'+ (data.perc < 20 ? 'danger' : (data.perc >= 20 && data.perc < 49 ? 'warning' : 'success')) +'" role="progressbar" style="width: '+ data.perc +'%" aria-valuenow="'+ data.perc +'" aria-valuemin="0" aria-valuemax="100"></div></div></td><td class="text-truncate ' + (data.win ? 'text-success' : 'text-danger') + '" style="font-weight:600;">'+ (data.win ? data.win_sum : 0) +'</td></tr>';
$('#response').prepend(html);
if($('#response tr').length >= 14) $('#response tr:nth-child(15)').remove();
});
socket.on('jackpot.newBet', function(data) {
var bet = '';
data.bets.forEach(function (info) {
bet += '<li>';
bet += '<div class="user">';
bet += '<div class="ava"><div style="height: 50px; background: #' + info.color + ';" class="token-balance-icon"><div class="user-photo" style="font-size:20px">' + info.username + '</div></div></div>';
bet += '<div class="info">';
bet += '<div class="nickname">' + info.name + '</div>';
bet += '<div class="points">Поставил: ' + info.sum + ' <i class="fas fa-coins"></i></div>';
bet += '</div>';
bet += '<div class="detail">';
bet += '<div class="percent">' + info.chance + '%</div>';
bet += '<div class="tickets"><i class="fas fa-ticket-alt"></i> #' + info.from + ' - #' + info.to + '</div>';
bet += '</div>';
bet += '</div>';
bet += '</li>';
});
var chances = '';
for(var i = 0; i < data.chances.length; i++) {
chances += '<li title="' + data.chances[i].username + '"><div style="height: 50px; background: #' + data.chances[i].color + ';" class="token-balance-icon"><div class="user-photo" style="font-size:20px">' + data.chances[i].name + '</div></div><span>' + data.chances[i].chance + '%</span></li>';
chances += '</li>';
}
$('#roombank').text(data.game.price);
$('#gamebank').text(data.game.price);
$('#players').text(data.chances.length);
$('#bets').html(bet);
$('#chances').html(chances);
});
socket.on('jackpot.timer', function(data) {
var sec = data.sec,
min = data.min,
time = data.time,
timer = data.timer;
if(sec < 10) sec = '0' + sec;
if(min < 10) min = '0' + min;
$('#timeline').css({width: (time/timer)*100+'%'})
$('#time').text(min+':'+sec);
});
socket.on('jackpot.ngTimer', function(data) {
if(data.ngtime < 10) data.ngtime = '0' + data.ngtime;
$('#time').text('00:'+data.ngtime);
$('#timeline').css({width: (data.ngtime/15)*100+'%'})
});
socket.on('jackpot.slider', function(data) {
$('#chouser').slideDown();
var members = '';
for(var i = 0; i < data.members.length; i++) members += '<div style="height: 50px; background: #' + data.members[i].color + ';" class="token-balance-icon"><div class="user-photo" style="font-size:20px">' + data.members[i].name + '</div></div>';
$('#carousel').html(members);
$('#carousel').css({
transform: 'translate3d(-' + data.ml + 'px, 0px, 0px)',
transition: 7000 + 'ms cubic-bezier(0.32, 0.64, 0.45, 1)'
});
setTimeout(function () {
$('#winnerName').text(data.winner.name);
$('#winnerSum').text(data.winner.sum);
$('#winnerChance').text(data.winner.chance+'%');
$('#winnerTicket').text(data.winner.ticket);
$('#winnerBox').slideDown();
}, 7200);
});
socket.on('jackpot.newGame', function(data) {
$('#carousel').removeAttr('style');
$('#carousel').html('');
$('#chouser').slideUp();
$('#winnerBox').slideUp();
$('#time').text(data.time[0]+':'+data.time[1]);
$('#roombank').text('0');
$('#gamebank').text('0');
$('#bets').html('');
$('#chances').html('');
$('#roundId').html('#'+data.game.id);
$('#timeline').css({width: '100%'});
$('#hash').text(data.game.hash);
});
socket.on('hilo.newBet', function(data) {
var html = '';
data.bets.forEach(function (bet) {
html += '<li>';
html += '<div class="user">';
html += '<div class="ava"><div style="height: 50px; background: linear-gradient(45deg, #1c65c9 0%, #2c80ff 100%);" class="token-balance-icon"><div class="user-photo" style="font-size:20px">'+ bet.name +'</div></div></div>';
html += '<div class="info">';
html += '<div class="nickname">'+ bet.username +'</div>';
html += '<div class="points">Поставил: '+ parseFloat(bet.sum).toFixed(2) +' N на '+ bet.type +'</div>';
html += '</div>';
html += '<div class="detail">';
html += '<div class="percent">'+ bet.multipler +'x</div>';
html += '<div class="tickets">'+ parseFloat(bet.win).toFixed(2) +' N</div>';
html += '</div>';
html += '</div>';
html += '</li>';
});
$('#hilo_bets').html(html);
$('.count_hi').html(data.betsCount.hi);
$('.count_lo').html(data.betsCount.lo);
$('.count_red').html(data.betsCount.red);
$('.count_black').html(data.betsCount.black);
$('.count_small').html(data.betsCount.small);
$('.count_big').html(data.betsCount.big);
$('.count_ka').html(data.betsCount.ka);
$('.count_a').html(data.betsCount.a);
$('.count_joker').html(data.betsCount.joker);
});
socket.on('hilo.timer', function(data) {
var time = data.time*(304.844/data.total);
$('#hilo_timer').css({
'stroke-dashoffset' : time
})
});
socket.on('hilo.newGame', function(data) {
$('.betButton').attr('disabled', false);
$('.betButton').removeClass('item_darken');
$('#hilo_hash').html(data.game.hash);
$('.hilo-flipper').removeAttr('style');
$('.hilo-flipper').css({
'transform' : 'rotateY(180deg) scale(1)'
});
$('.hilo-flipper').removeClass('flip');
$('.hilo-card-region .hilo-deck-card').removeAttr('style');
$('#hilo_bets').html('');
$('.count_hi').html(0);
$('.count_lo').html(0);
$('.count_red').html(0);
$('.count_black').html(0);
$('.count_small').html(0);
$('.count_big').html(0);
$('.count_ka').html(0);
$('.count_a').html(0);
$('.count_joker').html(0);
});
socket.on('hilo.getFlip', function(data) {
$('.betButton').attr('disabled', true);
$('.betButton').addClass('item_darken');
$('.hilo-flipper').removeClass('flip');
$('#hilo_timer').css({
'stroke-dashoffset' : 304.844
});
var stroke = '#ffffff';
var stroke_back = 'rgba(255, 255, 255, 0.4)';
if(data.hilo.section == 'red') {
var stroke = '#fb0f42';
var stroke_back = 'rgba(251, 15, 66, 0.4)';
}
if(data.hilo.section == 'black') {
var stroke = '#000000';
var stroke_back = 'rgba(0, 0, 0, 0.4)';
}
if(data.history) {
setTimeout(function() {
$('.hilo-card-region .hilo-deck-card').animate({
transform: 'scale(0.2)',
left: '0',
top: '0'
}, 1100, function() {
$(this).animate({
opacity: '0'
}, function() {
$(this).removeAttr('style');
});
});
}, 1000);
setTimeout(function() {
if(data.history.card_sign == 'hi') var type = '<img src="/assets/img/hilo-card-arrow.png" class="hilo-history-feed-sign hilo-history-feed__comparison-sign_hi">';
else if(data.history.card_sign == 'lo') var type = '<img src="/assets/img/hilo-card-arrow.png" class="hilo-history-feed-sign hilo-history-feed__comparison-sign_lo">';
else if(data.history.card_sign == 'eq') var type = '<img src="/assets/img/hilo-card-eq.png" class="hilo-history-feed-sign hilo-history-feed__comparison-sign_eq">';
else var type = '';
var html = '';
html += '<div class="hilo-history-card hilo-card hilo-card_sm hilo-card_'+ data.history.card_section +'">';
html += '<div class="hilo-card-num">'+ data.history.card_name +'</div>';
html += '<div class="hilo-history-feed">'+ type +'</div>';
html += '</div>';
$('.hilo-history').prepend(html);
setTimeout(() => {
$('.card-front').removeClass('hilo-card_red');
$('.card-front').removeClass('hilo-card_black');
$('.card-front').removeClass('hilo-card_joker');
$('.card-front').addClass('hilo-card_'+data.hilo.section);
$('.card-front .hilo-sign').html(data.hilo.name);
$('#timer_back').attr({ stroke: stroke_back});
$('#hilo_timer').attr({ stroke: stroke});
}, 260);
}, 2100);
}
setTimeout(function() {
$('.card-front').addClass('hilo-card_'+data.hilo.section);
$('.card-front .hilo-sign').html(data.hilo.name);
$('#timer_back').attr({ stroke: stroke_back});
$('#hilo_timer').attr({ stroke: stroke});
$('.hilo-flipper').addClass('flip');
$('.hilo-game .factor_hi').html(data.hilo.hi+'x');
$('.hilo-game .factor_lo').html(data.hilo.lo+'x');
$('.hilo-game .probability_hi').html(data.hilo.hi_perc+'%');
$('.hilo-game .probability_lo').html(data.hilo.lo_perc+'%');
$('.hilo-statistics-colors-ratio .ratio__red').html(data.stats.red_perc+'%');
$('.hilo-statistics-colors-ratio .ratio__red').css({width: data.stats.red_perc+'%'});
$('.hilo-statistics-colors-ratio .ratio__black').html(data.stats.black_perc+'%');
$('.hilo-statistics-colors-ratio .ratio__black').css({width: data.stats.black_perc+'%'});
$('.card_stat_2 .hilo-statistics__card-label span').html(data.stats.cards.two.count);
$('.card_stat_3 .hilo-statistics__card-label span').html(data.stats.cards.three.count);
$('.card_stat_4 .hilo-statistics__card-label span').html(data.stats.cards.four.count);
$('.card_stat_5 .hilo-statistics__card-label span').html(data.stats.cards.five.count);
$('.card_stat_6 .hilo-statistics__card-label span').html(data.stats.cards.six.count);
$('.card_stat_7 .hilo-statistics__card-label span').html(data.stats.cards.seven.count);
$('.card_stat_8 .hilo-statistics__card-label span').html(data.stats.cards.eight.count);
$('.card_stat_9 .hilo-statistics__card-label span').html(data.stats.cards.nine.count);
$('.card_stat_J .hilo-statistics__card-label span').html(data.stats.cards.J.count);
$('.card_stat_Q .hilo-statistics__card-label span').html(data.stats.cards.Q.count);
$('.card_stat_K .hilo-statistics__card-label span').html(data.stats.cards.K.count);
$('.card_stat_A .hilo-statistics__card-label span').html(data.stats.cards.A.count);
$('.card_stat_JOKER .hilo-statistics__card-label span').html(data.stats.cards.JOKER.count);
$('.card_stat_2 .hilo-statistics__card-frequency-progress').css({height: data.stats.cards.two.perc+'px'});
$('.card_stat_3 .hilo-statistics__card-frequency-progress').css({height: data.stats.cards.three.perc+'px'});
$('.card_stat_4 .hilo-statistics__card-frequency-progress').css({height: data.stats.cards.four.perc+'px'});
$('.card_stat_5 .hilo-statistics__card-frequency-progress').css({height: data.stats.cards.five.perc+'px'});
$('.card_stat_6 .hilo-statistics__card-frequency-progress').css({height: data.stats.cards.six.perc+'px'});
$('.card_stat_7 .hilo-statistics__card-frequency-progress').css({height: data.stats.cards.seven.perc+'px'});
$('.card_stat_8 .hilo-statistics__card-frequency-progress').css({height: data.stats.cards.eight.perc+'px'});
$('.card_stat_9 .hilo-statistics__card-frequency-progress').css({height: data.stats.cards.nine.perc+'px'});
$('.card_stat_J .hilo-statistics__card-frequency-progress').css({height: data.stats.cards.J.perc+'px'});
$('.card_stat_Q .hilo-statistics__card-frequency-progress').css({height: data.stats.cards.Q.perc+'px'});
$('.card_stat_K .hilo-statistics__card-frequency-progress').css({height: data.stats.cards.K.perc+'px'});
$('.card_stat_A .hilo-statistics__card-frequency-progress').css({height: data.stats.cards.A.perc+'px'});
$('.card_stat_JOKER .hilo-statistics__card-frequency-progress').css({height: data.stats.cards.JOKER.perc+'px'});
}, 2400);
});
$('.betButton').click(function(e) {
var type = $(this).data('type');
var sum = $('#amount_hilo').val();
$.ajax({
url: '/hilo/newBet',
type: 'post',
data: {
type: type,
sum: sum
},
success: function(data) {
$.wnoty({
position : 'top-right',
type: data.type,
message: data.msg
});
}
});
});
$('.input-number-actions .number-actions').on('click', function (event) {
let value = parseFloat($('#amount_hilo').val()) || 0,
all = parseFloat($('#balanceVal').val()),
thisMethod = $(this).attr('data-method'),
thisValue = parseFloat($(this).attr('data-value'));
switch(thisMethod) {
case 'plus' :
value += thisValue;
break;
case 'divide' :
value = parseInt((value/2).toFixed(0));
break;
case 'clear' :
value = '';
break;
case 'last' :
value = localStorage.getItem('last');;
break;
case 'all' :
value = all;
break;
case 'multiply' :
value = parseInt(value*2).toFixed(0);
break;
}
$('#amount_hilo').val(value);
});
$('.makeBet').on('click', function() {
var value = $('#amount').val();
localStorage.setItem('last', value);
$.post('/newBet',{sum: value});
});
$('.bet-input .upper a').on('click', function(event) {
let value = parseFloat($('#amount').val()) || 0,
all = $('#money').val(),
thisMethod = $(this).attr('data-method'),
thisValue = parseFloat($(this).attr('data-value'));
switch(thisMethod) {
case 'plus' :
value += thisValue;
break;
case 'divide' :
value = parseInt((value/thisValue).toFixed(0));
break;
case 'clear' :
value = '';
break;
case 'last' :
value = localStorage.getItem('last');;
break;
case 'all' :
value = all;
break;
case 'multiply' :
value *= thisValue;
break;
}
$('#amount').val(value);
});
$('.ajax_reset').submit(function(e) {
$.ajax({
url : $(this).attr('action'),
type : $(this).attr('method'),
data : $(this).serialize(),
success : function(data) {
$('#error_resetPass').hide();
$('#succes_resetPass').hide();
if(data.success) {
$('#succes_resetPass').show();
$('#succes_resetPass').html(data.msg);
}
},
error : function(err) {
var error = JSON.parse(err.responseText);
$('#error_resetPass').show();
$('#error_resetPass').html(error.errors.password[0]);
}
})
e.preventDefault();
});
$('#BetSize, #BetPercent').on('change keydown paste input', function() {
calc();
});
$('#WithdrawSize, #hide_search').on('change keydown paste input', function() {
calcWithdraw();
});
$('#hide_search').on('change keydown paste input', function() {
var des;
if($(this).val() == 'qiwi') des = '+7953155XXXX';
if($(this).val() == 'payeer') des = 'P1000000';
if($(this).val() == 'yandex') des = '410011499718000';
if($(this).val() == 'visa') des = '412107XXXX785577';
$('#walletNumber').attr('placeholder', des);
});
$('#checkDiceModal').on('hidden.bs.modal', function () {
$('.showTable').hide();
});
$('.chances').kinetic({
filterTarget: function(target, e){
if (!/down|start/.test(e.type)){
return !(/area|a|input/i.test(target.tagName));
}
}
});
$(document).on('click', '#checkHash', function() {
var hash = $('#gameHash').val();
$.ajax({
type: 'POST',
url: '/action/check',
beforeSend: function() {
$('#error_check').css('display', 'none');
$('.showTable').slideUp();
},
data: {
hash: hash
},
success: function(data) {
if(data.success) {
$('#checkTable').html('<tr><td>'+ data.info.id +'</td><td>'+ data.info.created_at +'</td><td class="text-truncate text-'+ (data.info.win ? 'success' : 'danger') +'" style="font-weight:600;">'+ data.info.number +'</td><td>'+ data.info.range +'</td><td class="text-truncate text-'+ (data.info.win ? 'success' : 'danger') +'" style="font-weight:600;">'+ (data.info.win ? data.info.win_sum : 0) +'</td></tr>');
$('.showTable').slideDown();
}
if(!data.success) {
$('#error_check').html(data.msg);
return $('#error_check').css('display', 'block');
}
}
});
});
$('.promoButton').click(function() {
var code = $('.promoCode').val();
$.ajax({
url : 'ref/activate',
type : 'post',
data : {
code : code
},
success : function(data) {
$.wnoty({
position : 'top-right',
type: data.type,
message: data.msg
});
return false;
},
error : function(data) {
console.log(data.responseText);
}
});
});
$(document).on('click', '#butPromo', function() {
$.ajax({
type: 'POST',
url: '/action/bonus',
beforeSend: function() {
$('#error_promo').css('display', 'none');
},
data: {
recapcha: $('#bonus .g-recaptcha-response').val()
},
success: function(data) {
grecaptcha.reset();
if(!data.success) {
$('#error_promo').html(data.msg);
return $('#error_promo').css('display', 'block');
} else {
$('#error_promo').css('display', 'none');
}
}
});
});
$(document).on('click', '#withB', function() {
$.ajax({
type: 'POST',
url: '/withdraw',
beforeSend: function() {
$('#error_withdraw').css('display', 'none');
$('#succes_withdraw').css('display', 'none');
},
data: {
system: $('#hide_search').val(),
wallet: $('#walletNumber').val(),
sum: $('#WithdrawSize').val()
},
success: function(data) {
if(data.success) {
$('#succes_withdraw').html(data.msg);
$('#succes_withdraw').css('display', 'block');
$('#withdrawT').prepend('<tr style="cursor:default" id="'+ data.res.id +'_his"><td class="cancel"><i class="ft-x" style="color:red;cursor:pointer;margin-left: -1px;font-size: 14px;font-style: normal;" onclick="removeWithdraw('+ data.res.id +')" data-toggle="tooltip" data-placement="top" title="Отменить" data-original-title="Отменить вывод">x</i></td><td> '+ data.res.id +'</td><td> '+ data.res.created_at +'</td><td><img src="/assets/img/pays/'+ data.res.system +'.png"> '+ data.res.wallet +'</td><td>'+ data.res.value +' N</td><td class="status"><div class="tag tag-warning">Ожидание</div></td></tr>')
} else {
$('#error_withdraw').html(data.msg);
return $('#error_withdraw').css('display', 'block');
}
}
});
});
$(document).on('click', '#buttonMin, #buttonMax', function() {
var type = $(this).data('bet');
if ($('#BetSize').val() < 1){
$('#error_bet').html('Ставка от 1 N');
return $('#error_bet').css('display', '');
}
if ($('#BetSize').val() > 100000){
$('#error_bet').html('Можно ставить не больше 100000 N');
return $('#error_bet').css('display', '');
}
if ($('#userBalance').html() < $('#BetSize').val()) {
$('#error_bet').html('Недостаточно средств');
return $('#error_bet').css('display', '');
}
if ($('#BetPercent').val() > 95 || $('#BetPercent').val() < 1) {
$('#error_bet').html('% Шанс от 1 до 95');
return $('#error_bet').css('display', '');
}
$.ajax({
type: 'POST',
url: '/action/play',
beforeSend: function() {
$('#checkBet').css('display', 'none');
$('#error_bet').css('display', 'none')
$('#succes_bet').css('display', 'none')
$('#betLoad').css('display', '');
$('#buttonMax').css('pointer-events', 'none');
$('#buttonMin').css('pointer-events', 'none');
},
data: {
type: type,
sum: $('#BetSize').val(),
perc: $('#BetPercent').val(),
},
success: function(data) {
$('#buttonMax').css('pointer-events', '');
$('#buttonMin').css('pointer-events', '');
$('#betLoad').css('display', 'none');
if(data.success) {
$('#checkBet').css('display', '');
$('#checkBet').attr('href', 'game/?hash=' + data.hash);
if(data.win) {
$('#succes_bet').css('display', 'block');
$("#succes_bet").html("Выиграли <b>" + data.win_sum + " </b>");
}
if(!data.win) {
$('#error_bet').css('display', 'block');
$("#error_bet").html("Выпало " + data.num);
}
$("#hashBet").html(data.hash);
$('#gameHash').val(data.check);
slide();
}
if(!data.success) {
$('#error_bet').html(data.msg);
return $('#error_bet').css('display', 'block');
}
}
});
});
});
function slide() {
$('#hashBet').fadeOut('slow', function() {
$('#hashBet').fadeIn('slow');
});
}
function validateBetSizeD(inp) {
inp.value = inp.value.replace(/[,]/g, '.')
.replace(/[^\d,.]*/g, '')
.replace(/([,.])[,.]+/g, '$1')
.replace(/^[^\d]*(\d+([.,]\d{0,2})?).*$/g, '$1');
calc();
}
function validateBetPercentD(inp) {
if (inp.value > 95) {
inp.value = 95;
}
inp.value = inp.value.replace(/[,]/g, '.')
.replace(/[^\d,.]*/g, '')
.replace(/([,.])[,.]+/g, '$1')
.replace(/^[^\d]*(\d+([.,]\d{0,2})?).*$/g, '$1');
calc();
}
function calc() {
$('.BetProfit').html(((100 / $('#BetPercent').val()) * $('#BetSize').val()).toFixed(2));
$('#MinRange').html(Math.floor(($('#BetPercent').val() / 100) * 999999));
$('#MaxRange').html(999999 - Math.floor(($('#BetPercent').val() / 100) * 999999));
}
function updateBalance(start, end) {
var el = document.getElementById('userBalance');
od = new Odometer({
el: el,
value: start
});
od.update(end);
var elMob = document.getElementById('userBalanceMob');
odelMob = new Odometer({
el: elMob,
value: start
});
odelMob.update(end);
}
function removeWithdraw(id) {
$.ajax({
type: 'GET',
url: '/withdraw/cancel/' + id,
success: function(data) {
if(data.success) {
$('#'+ data.id +'_his .cancel').html('');
$('#'+ data.id +'_his .status').html('<div class="tag tag-danger">Отменено</div>');
}
}
});
}
function calcWithdraw() {
var system = $('#hide_search').val();
var min = 150;
if(system == 'visa') var min = 1500;
$('#minSum').html(min);
}