цвет заднего фона зеленый
});
$("#messageChat").focus(function(){ // задаем функцию при потере фокуса элементом
, или любым вложенным элементо
$(".panel_smiles").removeClass('open'); // устанавливаем элементу
цвет заднего фона зеленый
$(".panel_stickers").removeClass('open');
});
$(".chat_btn").click(function(){ // задаем функцию при нажатиии на элемент
")
class_dop = ''
if(bet[i].user_id == USER_ID){
class_dop = 'img_no_blur'
}
$('.usersJackpot').prepend('
\
\
\
'+(bet[i].chance).toFixed(2)+'%
\
\
')
}
})
socket.on('laravel_database_jackpotUpdateBet',e => {
e = $.parseJSON(e)
$('.betsJackpot').html('')
addInBets(e.jackpot)
e.info.forEach((e)=>{
userid = e.user_id
if(userid == USER_ID){
bet = e.bet
$('#inputCashHuntBet').val(bet)
}
})
})
socket.on('laravel_database_jackpotBet',e => {
e = $.parseJSON(e)
e = e.date
$('.JackpotPlay').show();
$('.waitJackpot').hide();
$('.bankGame').text((Number($('.bankGame').html()) + Number(e.bet)).toFixed(0))
color = hexToRgb("#"+e.color+"")
class_dop = ''
if(e.user_id == USER_ID){
class_dop = 'img_no_blur'
}
percent_circle = 290 + 25 - (Number(e.chance).toFixed(0) * 290 / 100)
$('.betsJackpot').prepend('
\
\
\

\
\
'+(e.login).split(' ')[0]+'\
'+Number(e.bet).toFixed(0)+'
\
\
\
\
\
Билеты\
'+e.tickets[0]+' - '+e.tickets[1]+'
\
\
\
\
'+(e.chance).toFixed(0)+'%
\
\
\
\
\
\
\
\
\
')
$('.betJackpot[data-user_id="'+e.user_id+'"] .percentBetUser svg circle').attr('stroke-dashoffset', percent_circle)
})
socket.on('JACKPOT_ANIMATION_START',e=>{
animationStart(e.avatarJackpot,e.plusJackpot,e.timerJackpotAnimate)
})
socket.on('JACKPOT_GET',e=>{
if(e.statusJackpot == 2){
$('#Jackpot').show();
$('#cashHunt').hide();
animationStart(e.avatarJackpot,e.plusJackpot,e.timerJackpotAnimate)
}
if(e.statusJackpot == 3){
$('.water').css('transition', e.timerCashHantJackpot+'s')
$('.water').addClass('animate')
$('.cashHantWrapper .hant').each(function(i,elem) {
img = e.cashHantJackpot[i]
$(this).html('

')
});
$('#cashHunt').show();
$('#Jackpot').hide();
}
})
function animationStart(avatarki,plus,time){
console.log(time)
$('.players.jackpot').html('')
$('.players.jackpot').css({'transition':'0s','transform':'translateX(0px)'})
$('.progress_block_jackpot').hide()
$('.blockRouletteJackpot').show()
for(let i=0;i
')
}
for(let i=0;i')
}
const px = 3800 + plus
$('.players.jackpot').css({'transition':'all '+time*1000+'ms cubic-bezier(0, 0, 0, 1) 0ms','transform':'translateX(-'+px+'px)'})
}
socket.on('JACKPOT_CLEAR',e => {
$('.bankGame').text(0)
$('.bankGame').text(0)
$('.chanceUser').text('0%')
$('.usersCount').html(0)
$('.progress_block_jackpot').show()
$('.blockRouletteJackpot').hide()
$('.JackpotPlay').hide();
$('.waitJackpot').show();
$('.betsJackpot').html('')
$('.usersJackpot').html('')
$('.JackpotWin').hide();
$('.chancesJackpot').html('')
$('.progress_jackpot').css('width', '100%')
$('.timeJackpot').text(30)
})
socket.on('JACKPOT_NOTIFICATION',e=>{
if(USER_ID == e.user_id){
updateBalance()
}
})
socket.on('JACKPOT_FINISH',e=>{
$('.JackpotWin').show();
$("#sw_win").html(Number(e.bank).toFixed(2));
$(".sw_percent").html(e.percent);
$("#sw_login").html((e.login).split(' ')[0]);
$("#sw_bet").html(e.bet);
$('#sw_avatar').attr('src', e.img)
$("#sw_ticket").html(e.random);
if(e.bank > $('#maxWin').html()){
$('#maxWin').html(e.bank)
}
$('#gamesToday').html(Number(Number($('#gamesToday').html()) + 1))
})
socket.on('CASHHUNT_FINISH',e=>{
$('.hant').addClass('show')
$('.cashHantWrapper .hant').each(function(i,elem) {
x = e.coefsHunt[i]
$(this).html('x'+x+'')
});
})
socket.on('CASHHUNT_END',e=>{
$('#Jackpot').show()
$('.water').removeClass('animate')
$('#cashHunt').hide()
})
socket.on('CASHHUNT_TIME',e=>{
$('.timerCashHunt').html(e.time)
})
socket.on('JACKPOT_BANK',e=>{
$('.bankGame').html(e.bank)
})
socket.on('KENO_TIME',e=>{
$('.timeKeno').html(e.time)
})
socket.on('KENO_CLEAR',e=>{
selectsKeno = []
$('.gameKeno').html('')
$('.keno__canvas-item .keno__canvas-number').show()
$('.keno__canvas-item .kenoBonus').hide()
$('.bankKeno').html(0)
$('.usersKeno').html(0)
$('.keno__mines').removeClass('keno__mines--win')
$('.keno__mines .keno__mines-win').hide();
undisable('.keno__cancel-select')
$('.keno__coeff-scroll').html('')
undisable('.keno__auto-select')
$('.keno__canvas-item').removeClass('blocked')
$('.keno__canvas-item').removeClass('keno__canvas-item--is-selected keno__canvas-item--is-revealed keno__canvas-item--has-hit')
})
socket.on('KENO_SELECT',e=>{
if ($('.keno__canvas-item:eq('+(e.item - 1)+')').hasClass('keno__canvas-item--is-selected')){
$('.keno__canvas-item:eq('+(e.item - 1)+')').addClass('keno__canvas-item--has-hit')
}else{
$('.keno__canvas-item:eq('+(e.item - 1)+')').addClass('keno__canvas-item--is-revealed')
}
})
socket.on('KENO_GET',e=>{
e.selectNumberKeno.forEach(async function(item, i, arr) {
if ($('.keno__canvas-item:eq('+(item - 1)+')').hasClass('keno__canvas-item--is-selected')){
$('.keno__canvas-item:eq('+(item - 1)+')').addClass('keno__canvas-item--has-hit')
}else{
$('.keno__canvas-item:eq('+(item - 1)+')').addClass('keno__canvas-item--is-revealed')
}
});
})
socket.on('KENO_BONUS',e=>{
numberBonusKeno = e.bonusKeno.number
coeffBonusKeno = e.bonusKeno.coeff
$('.keno__canvas-item:eq('+(numberBonusKeno - 1)+') .keno__canvas-number').hide()
$('.keno__canvas-item:eq('+(numberBonusKeno - 1)+') .kenoBonus').show()
$('.keno__canvas-item:eq('+(numberBonusKeno - 1)+') .kenoBonus div p').html('x'+coeffBonusKeno)
})
socket.on('laravel_database_updateKenoBank',e => {
e = $.parseJSON(e)
$('.bankKeno').html(Number(e.bank).toFixed(2))
$('.usersKeno').html(e.users)
$('.gameKeno').prepend(' \
\
\
\
| \
\
\
'+e.bet+'\
\
\
| \
\
\
'+e.numbers+'\
\
| \
\
\
'+(Number(e.win).toFixed(2))+' \
'+(Number(e.win).toFixed(2))+'\
\
| \
')
})
socket.on('laravel_database_kenoWin',e => {
e = $.parseJSON(e)
if(USER_ID == e.user_id){
$('.keno__mines').addClass('keno__mines--win')
$('.keno__mines .keno__mines-win').show();
$('.keno__mines .keno__mines-win b').html((Number(e.win).toFixed(0))+' Р');
}
})
function selectCashHunt(id, that) {
$.post('/jackpot/selecthunt',{_token: csrf_token, id}).then(e=>{
undisable('.hant')
if(e.success){
$('.hant').removeClass('active')
$(that).addClass('active')
}
if(e.error){
notification('error',e.error)
}
}).fail(e=>{
undisable('.hant')
notification('error',JSON.parse(e.responseText).message)
})
}
kenoCoefs = [
[5.92],
[3.6, 9.6],
[2.2, 5.3, 100],
[1.5, 3.24, 20, 200],
[1.1, 2.8, 7.5, 28, 780]
]
function selectKeno(id, that){
if(selectsKeno.indexOf(id) != -1){
const index = selectsKeno.indexOf(id);
if (index > -1) {
selectsKeno.splice(index, 1);
$(that).removeClass('keno__canvas-item--is-selected')
}
}else{
if (selectsKeno.length == 5){
return notification('error', 'Максимум 5 ячеек')
}
selectsKeno.push(id)
$(that).addClass('keno__canvas-item--is-selected')
}
updateKenoCoeff()
}
function updateKenoCoeff(){
$('.keno__coeff-scroll').html('')
if(selectsKeno.length > 0){
kenoIkses = kenoCoefs[selectsKeno.length - 1]
kenoIkses.forEach(async function(item, i, arr) {
$('.keno__coeff-scroll').append('\
'+item+'x\
'+(i + 1)+' hits\
')
});
}
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function clearKeno(that) {
selectsKeno.forEach(async function(item, i, arr) {
setTimeout(function(){
$('.keno__canvas-item:eq('+(item - 1)+')').removeClass('keno__canvas-item--is-selected')
}, 100 * ++i)
});
setTimeout(function(){
undisable(that)
$('.keno__coeff-scroll').html('')
}, selectsKeno.length * 100 + 100)
selectsKeno = []
}
function autoKeno(that){
$('.keno__canvas-item').removeClass('keno__canvas-item--is-selected')
selectsKeno = []
for (var i = 1; i <= 5; i++) {
randItem = rand(1, 41)
type = 'False'
while (type == 'False'){
if(selectsKeno.indexOf(randItem) != -1){
randItem = rand(1, 41)
}else{
break
}
}
selectsKeno.push(randItem)
}
selectsKeno.forEach(async function(item, i, arr) {
setTimeout(function(){
$('.keno__canvas-item:eq('+(item - 1)+')').addClass('keno__canvas-item--is-selected')
}, 100 * ++i)
});
setTimeout(function(){
undisable(that)
updateKenoCoeff()
}, 600)
}
function betKeno(that) {
audio.click.currentTime = 0;
audio.click.play();
selects = JSON.stringify(selectsKeno)
$.post('/keno/bet',{_token: csrf_token, selectsKeno: selects, bet: $('#sumBetKeno').val()}).then(e=>{
undisable(that)
if(e.success){
disable('.keno__cancel-select')
disable('.keno__auto-select')
$('.keno__canvas-item').addClass('blocked')
balanceUpdate(e.lastbalance, e.newbalance)
notification('success',e.success)
}
if(e.error){
notification('error',e.error)
}
}).fail(e=>{
undisable(that)
notification('error',JSON.parse(e.responseText).message)
})
}
function checkTheme() {
if (localStorage.getItem('theme') === 'dark') {
$('body').addClass('theme--dark');
$('#darkTheme').hide();
$('#lightTheme').show();
} else {
$('body').removeClass('theme--dark');
$('#darkTheme').show();
$('#lightTheme').hide();
localStorage.removeItem('theme');
}
}
// checkTheme()
$('#darkTheme').click(function(e){
e.preventDefault();
localStorage.setItem('theme', 'dark');
$('body').addClass('theme--dark');
$(this).hide();
$('#lightTheme').show();
});
$('#lightTheme').click(function(e){
e.preventDefault();
localStorage.removeItem('theme');
$('body').removeClass('theme--dark');
$(this).hide();
$('#darkTheme').show();
});
var audio = {
click: new Audio('sounds/click_0.mp3'),
boom: new Audio('sounds/boom_0.mp3'),
lose_0: new Audio('sounds/lose_0.mp3'),
};
Object.values(audio).forEach(audio => audio.preload = 'metadata');
audio.click.volume = 0.8;
audio.boom.volume = 0.8;
audio.lose_0.volume = 0.8;
// initial data
let countY = [0, 2];
let countX = [0, 1];
let updatedCountY = [0];
let updatedCountX = [0];
var bet_user = 0;
function crashBet(that){
const info = {
bet: Number($('#crashSum').val()),
auto: Number($('#crashAuto').val()),
_token: csrf_token
}
audio.click.currentTime = 0;
audio.click.play();
$.post('/crash/bet',info).then(e=>{
if(e.success){
bet_user = 1;
notification('success',e.success)
balanceUpdate(e.lastbalance, e.newbalance)
$('#btnCrash span').html('Ожидание игры...')
disable('#crashSum')
disable('#crashAuto')
}
if(e.error){
undisable(that)
notification('error',e.error)
}
})
}
function crashGive(that){
const info = {
_token: csrf_token
}
$.post('/crash/give',info).then(e=>{
if(e.success){
bet_user = 0;
notification('info', 'Забираем...')
// $('#btnCrash').html('Забираем...')
}
if(e.error){
undisable(that)
notification('error',e.error)
}
})
}
socket.on('laravel_database_crashBet',e=>{
e = $.parseJSON(e)
$('.crash__history-users').prepend(' \
\
\
\
'+Number(e.bet).toFixed(2)+'\
\
\
\
\
')
})
function startGameCoin(that) {
audio.click.currentTime = 0;
audio.click.play();
$.post('/coin/bet',{_token: csrf_token, bet: $('#coinSum').val()}).then(e=>{
undisable(that)
if(e.success){
disable('#coinSum')
$('#playCoin').show();
$('#startCoin').hide();
$('#coinCoeff').html('x'+Number(0).toFixed(2))
$('#coinStep').html(0)
$("#winCoin").html(Number(0 * $('#coinSum').val()).toFixed(2))
balanceUpdate(e.lastbalance, e.newbalance)
notification('success',e.success)
if(e.bonus == 1){
notification('success', 'Бонусная игра!')
$('.mines__bonus .x30__bonus-scroll').css({'transition':'0s','transform':'translateX(0px)'})
$('.mines__bonus .x30__bonus-scroll').html('')
$('.mines__bonus').show()
disable('.coinflip__place')
disable('#finishCoinBtn')
e.bonusCoin.forEach((e)=>{
$('.mines__bonus .x30__bonus-scroll').append('x'+e+'
')
})
x = (56*43) - (Number($('.mines__bonus').width())/2) + rand(10, 40)
betMine = Number($('#coinSum').val())
betNew = betMine * e.coeffBonusCoin
betNew = betNew.toFixed(2)
setTimeout(() => $('.mines__bonus .x30__bonus-scroll').css({'transition':'10s','transform':'translateX(-'+x+'px)'}), 200);
setTimeout(() => $('#coinSum').val(betNew),10000);
setTimeout(() => undisable('.coinflip__place'),10000);
setTimeout(() => notification('success', 'Поздравляем! Ваша ставка умножилась на '+e.coeffBonusCoin),10000);
setTimeout(() => undisable('#finishCoinBtn'),10000);
}
}else{
notification('error',e.mess)
}
}).fail(e=>{
undisable(that)
notification('error',JSON.parse(e.responseText).message)
})
}
function finishGameCoin(that){
$.post('/coin/finish',{_token: csrf_token}).then(e=>{
undisable(that)
if(e.success){
undisable('#coinSum')
$('#coinCoeff').html('x0.00')
$('#coinStep').html(0)
$("#winCoin").html(Number(0).toFixed(2))
$('#playCoin').hide();
$('#startCoin').show();
balanceUpdate(e.lastbalance, e.newbalance)
notification('success',e.success)
$('.mines__bonus').hide()
betMine = Number($('#coinSum').val())
betNew = betMine / e.coeffBonusCoin
betNew = betNew.toFixed(2)
$('#coinSum').val(betNew)
}else{
notification('error',e.mess)
}
}).fail(e=>{
undisable(that)
notification('error',JSON.parse(e.responseText).message)
})
}
function playCoinGame(that, type){
disable('#finishCoinBtn')
disable('.coinflip__place')
$(that).addClass('coinflip__place--active')
$.post('/coin/play',{_token: csrf_token, type}).then(e=>{
if(e.success){
if(e.off == 3){
notification('success', 'Бонусная игра!')
$('.mines__bonus .x30__bonus-scroll').css({'transition':'0s','transform':'translateX(0px)'})
$('.mines__bonus .x30__bonus-scroll').html('')
$('.mines__bonus').show()
disable('.coinflip__place')
disable('#finishCoinBtn')
e.bonusCoin.forEach((e)=>{
$('.mines__bonus .x30__bonus-scroll').append('x'+e+'
')
})
x = (56*43) - (Number($('.mines__bonus').width())/2) + rand(10, 40)
betMine = Number($('#coinSum').val())
betNew = betMine * e.coeffBonusCoin
betNew = betNew.toFixed(2)
setTimeout(() => $('.mines__bonus .x30__bonus-scroll').css({'transition':'10s','transform':'translateX(-'+x+'px)'}), 200);
setTimeout(() => $('#coinSum').val(betNew),10000);
setTimeout(() => $("#winCoin").html(Number(e.win).toFixed(2)),10000);
setTimeout(() => undisable('.coinflip__place'),10000);
setTimeout(() => notification('success', 'Поздравляем! Ваша ставка умножилась на '+e.coeffBonusCoin),10000);
setTimeout(() => undisable('#finishCoinBtn'),10000);
setTimeout(() =>{ undisable('#finishCoinBtn')
$(that).removeClass('coinflip__place--active')
},10000);
return
}
$('.coinflip__wrapper').removeClass('animated flip_1 flip_2')
setTimeout(() => {
$('.coinflip__wrapper').addClass('animated flip_'+e.type)
}, 100)
setTimeout(() => {
undisable(that)
undisable('.coinflip__place')
undisable('#finishCoinBtn')
$(that).removeClass('coinflip__place--active')
if(e.off == 1){
$('#coinCoeff').html('x0.00')
$('#coinStep').html(0)
$("#winCoin").html(Number(0).toFixed(2))
$('#playCoin').hide();
$('#startCoin').show();
undisable('#coinSum')
$('.mines__bonus').hide()
betMine = Number($('#coinSum').val())
betNew = betMine / e.coeffBonusCoin
betNew = betNew.toFixed(2)
$('#coinSum').val(betNew)
}else{
$('#coinCoeff').html('x'+Number(e.coeff).toFixed(2))
$('#coinStep').html(e.step)
$("#winCoin").html(Number(e.win).toFixed(2))
}
}, 1000)
}else{
undisable(that)
undisable('.coinflip__place')
undisable('#finishCoinBtn')
$(that).removeClass('coinflip__place--active')
notification('error',e.mess)
}
}).fail(e=>{
undisable(that)
undisable('.coinflip__place')
undisable('#finishCoinBtn')
$(that).removeClass('coinflip__place--active')
notification('error',JSON.parse(e.responseText).message)
})
}