function vkAuth(url){
window.location = 'https://oauth.vk.com/authorize?client_id=7814147&display=page&redirect_uri=' + url + '&response_type=code';
// function listener(event){
// try{
// if (!event.isTrusted || event.origin !== "https://musor.cash") return;
// console.log(event.data)
// Cookies.set('token', event.data);
// window.location.reload();
// window.removeEventListener("message", listener, false)
// }catch(ex){console.log(ex)}
// }
// window.addEventListener("message", listener, false);
}
var gameChangedAudio = new Audio();
gameChangedAudio.preload = 'auto';
gameChangedAudio.src = './files/gameChanged.mp3';
function recalc(){
$('#MinRange').html(Math.floor(($('#BetPercent').val() / 100) * 999999));
$('#MaxRange').html(999999 - Math.floor(($('#BetPercent').val() / 100) * 999999));
$('#BetProfit').html(((100 / $('#BetPercent').val()) * $('#BetSize').val()).toFixed(2));
}
function plusGames(item){
if(item.profit > 0 || item.won > 0){
var res = 'success';
}else{
var res = "danger";
}
if(item.chance < 33){
var prog = 'danger';
}else if(item.chance >= 33 && item.chance <= 66){
var prog = 'warning';
}else{
var prog = 'success';
}
if(item.gameType == 1){
var goal = item.goal1 + ' - ' + item.goal2;
}else if(item.gameType == 2){
var goal = item.goal1 + " волков";
item.number = item.number + " волков";
}
$("#response").prepend('
 + '.png) | ' + item.player_name +' | ' + item.number + ' | ' + goal + ' | ' + item.amount.toFixed(2) + ' | | ' + item.won || item.profit +' |
');
}
function newMessage(data){
var adm = '';
var isAdm = '';
if(admin){
adm = '';
}
if(data.admin){
isAdm = "color: #EB3349;"
}
return $(".chatBlock").append('');
}
$(function() {
pickGame(Cookies.get("game") || 0, true);
window.odometerOptions = {
auto: true,
selector: '.userBalance',
};
window.history.replaceState(null, null, window.location.pathname);
recalc();
var centrifuge = new Centrifuge("wss://musor.store:8443/connection/websocket", {
debug: true
});
window.socket = centrifuge;
$('#chat').on('shown.bs.collapse', function () {
var el = document.getElementById('chatBlock');
el.scrollTop = el.scrollHeight - el.clientHeight;
})
$("#main-menu-navigation li").click(function() {
if ($(this).attr('id') !== 'setPop' && $(this).attr('id') !== 'exit'){
$("#main-menu-navigation li").removeClass("active");
$(this).toggleClass("active");
}
})
if(Cookies.get('token')){
$.ajax({
type: 'GET',
url: '/api/getSocketAuth',
headers: {
'x-token': Cookies.get('token')
},
success: function(data) {
window.socket.setToken(data.data);
window.socket.connect();
window.socket.subscribe("online", (message) => {
$("#online").html(message.data);
})
window.socket.subscribe("games", (message) => {
plusGames(message.data);
$("#response").html($("#response > tr").slice(0,20))
})
window.socket.subscribe("chat", (message) => {
if(message.data.action == "new_message"){
newMessage(message.data.data);
var el = document.getElementById('chatBlock');
if(el.scrollTop + el.clientHeight > el.scrollHeight - 200){
el.scrollTop = el.scrollHeight - el.clientHeight;
}
$("#chatBlock").html($("#chatBlock > .item").slice(-50));
}else if (message.data.action == "delete") {
$('[player-id="' + message.data.data +'"]').remove();
}
})
try{
window.socket.subscribe("balance#" + accountID, (message) => {
$('.userBalance').attr('myBalance', message.data.data.balance);
updateBalance(0, message.data.data.balance);
})
}catch(ex){}
}
});
}else{
$.ajax({
type: 'GET',
url: '/api/getSocket',
success: function(data) {
window.socket.setToken(data.data);
window.socket.connect();
window.socket.subscribe("online", (message) => {
$("#online").html(message.data);
})
window.socket.subscribe("games", (message) => {
plusGames(message.data);
$("#response").html($("#response > tr").slice(0,20))
})
}
});
}
$.ajax({
type: 'GET',
url: '/api/lastGames',
success: function(data) {
data.data = data.data.reverse();
for (var i = 0; i < data.data.length; i++){
plusGames(data.data[i]);
}
$("#response").html($("#response > tr").slice(0,20))
}
});
$.ajax({
type: 'GET',
url: '/api/chat',
success: function(data) {
data.data = data.data.reverse();
for (var i = 0; i < data.data.length; i++) {
newMessage(data.data[i]);
}
var el = document.getElementById('chatBlock');
el.scrollTop = el.scrollHeight - el.clientHeight;
}
});
});
function likes() {
$('#loader').css('display', 'block');
if($('.g-recaptcha-response').val() == ''){
$('#error_likes').show();
$('#loader').css('display', 'none');
return $('#error_likes').html("Хуле галочку не поставил");
}
$.ajax({
type: 'POST',
url: '/api/likes',
contentType: "application/json",
beforeSend: function() {
$('#error_likes').hide();
$('#succes_likes').hide();
$('#likes').html('');
$('#loader').css('display', 'block');
grecaptcha.reset();
},
headers: {
'x-token': Cookies.get('token')
},
data: JSON.stringify({
recaptcha_response: $('.g-recaptcha-response').val(),
}),
success: function(data) {
$('#likes').html('Заюзать плюшку');
$("#succes_likes").show();
$('#loader').css('display', 'none');
updateBalance(data.balanceOld, data.balance);
$('#succes_likes').html(data.text);
},
error: function(data){
$('#likes').html('Заюзать плюшку');
$('#error_likes').show();
$('#loader').css('display', 'none');
return $('#error_likes').html(data.responseJSON.error || "Произошла залупа");
}
});
}
function promo() {
$('#loader').css('display', 'block');
if($('.g-recaptcha-response').val() == ''){
$('#error_promo').show();
$('#loader_promo').css('display', 'none');
return $('#error_promo').html("Хуле галочку не поставил");
}
$.ajax({
type: 'POST',
url: '/api/bonus/promocode/activate',
contentType: "application/json",
beforeSend: function() {
$('#error_promo').hide();
$('#succes_promo').hide();
$('#promoText').html('');
$('#loader_promo').css('display', 'block');
grecaptcha.reset();
},
headers: {
'x-token': Cookies.get('token')
},
data: JSON.stringify({
promocode: $("#promo").val(),
captcha: $('.g-recaptcha-response').val(),
}),
success: function(data) {
$('#promoText').html('Заюзать промик');
$("#succes_promo").show();
$('#loader_promo').css('display', 'none');
updateBalance(0, data.balance);
$('#succes_promo').html(data.text);
},
error: function(data){
$('#promoText').html('Заюзать плюшку');
$('#error_promo').show();
$('#loader_promo').css('display', 'none');
return $('#error_promo').html(data.responseJSON.error || "Произошла залупа");
}
});
}
function likesNew() {
$.ajax({
type: 'POST',
url: '/api/likesNew',
contentType: "application/json",
beforeSend: function() {
$('#error_likes').hide();
$('#succes_likes').hide();
$('#likes2').html('');
$('#loader2').css('display', 'flex');
grecaptcha.reset();
},
headers: {
'x-token': Cookies.get('token')
},
data: JSON.stringify({
recaptcha_response: 'asd',
}),
success: function(data) {
$('#likes2').html('Получить пизды');
$("#succes_likes").show();
$('#loader2').css('display', 'none');
updateBalance(data.balanceOld, data.balance);
$('#succes_likes').html(data.text);
},
error: function(data){
$('#likes2').html('Получить пизды');
$('#error_likes').show();
$('#loader2').css('display', 'none');
return $('#error_likes').html(data.responseJSON.error || "Произошла залупа");
}
});
}
function withdraw() {
if ($('#WithdrawSize').val() == '' || $('#walletNumber').val() == '' || $('#hide_search').val() == '') {
$('#error_withdraw').show();
return $('#error_withdraw').html('Заполняй все нах');
}
$.ajax({
type: 'POST',
url: '/api/payout',
beforeSend: function() {
$('#withdrawB').html('');
$('#error_withdraw').hide();
$('#succes_withdraw').hide();
$('#loader').css('display', '');
},
headers: {
'x-token': Cookies.get('token'),
'Content-Type': 'application/json'
},
data: JSON.stringify({
system_id: parseInt($('#hide_search').val()),
amount: parseFloat($('#WithdrawSize').val()),
wallet: $('#walletNumber').val()
}),
success: function(data) {
$('#withdrawB').html('Отжать');
$('#loader').css('display', 'none');
$('#emptyHistory').hide();
$('#succes_withdraw').show();
updateBalance(data.oldBalance, data.balance);
$("#withdrawTable").prepend('' + data.payout.created_at + ' | ' + data.payout.wallet + ' | ' + parseFloat(data.payout.amount.toFixed(2)) +' | Жди епта |
');
},
error: function(data){
$('#withdrawB').html('Отжать');
$('#loader').css('display', 'none');
$('#error_withdraw').show();
return $('#error_withdraw').html(data.responseJSON.error);
}
});
}
function withdrawSelect() {
$('#walletNumber').val('');
var e = $('#hide_search').val();
if (e == 1 || e == 6) {
$('#walletNumber').attr('placeholder', '+79123456789');
}
if (e == 3) {
$('#walletNumber').attr('placeholder', '412107XXXX785577');
}
if (e == 4) {
$('#walletNumber').attr('placeholder', '412107XXXX785577');
}
if (e == 5) {
$('#walletNumber').attr('placeholder', '220207XXXX785577');
}
if (e == 7) {
$('#walletNumber').attr('placeholder', 'P1000000');
}
}
function bet(type, demo) {
if($('#BetSize').val() > 15000){
$('#succes_bet').css('display', 'none')
$('#error_bet').html('Настоящий волк не ставит больше 15К');
$('#checkBet').css('display', 'none');
return $('#error_bet').css('display', '');
}
if($('#BetSize').val() < 1){
$('#succes_bet').css('display', 'none')
$('#error_bet').html('Чё как лох копейки ставишь');
$('#checkBet').css('display', 'none');
return $('#error_bet').css('display', '');
}
if ($('#BetPercent').val() > 95 || $('#BetPercent').val() < 1) {
$('#succes_bet').css('display', 'none');
$('#error_bet').html('Указывай бля от 1 до 95');
$('#checkBet').css('display', 'none');
return $('#error_bet').css('display', '');
}
if(demo){
var url = '/api/demo/bet';
}else{
var url = '/api/bet';
}
$.ajax({
type: 'POST',
url: url,
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');
},
headers: {
'x-token': Cookies.get('token'),
'Content-Type': 'application/json'
},
data: JSON.stringify({
type: parseInt(type),
betSize: parseFloat($('#BetSize').val()),
betPercent: parseFloat($('#BetPercent').val()) / 100,
}),
success: function(data) {
$('#buttonMax').css('pointer-events', '');
$('#buttonMin').css('pointer-events', '');
$('#betLoad').css('display', 'none');
$('#checkBet').css('display', '');
$('#checkBet').attr('href', 'game/?id=' + data.id);
if (data.type == 'win') {
$('#succes_bet').css('display', '');
$('#error_bet').css('display', 'none');
$("#succes_bet").html("Отжал " + data.profit + " ");
}
if (data.type == 'lose') {
$('#succes_bet').css('display', 'none');
$('#error_bet').css('display', '');
$("#error_bet").html("Не отжал " + data.number);
}
$("#hashBet").html(data.newHash);
sss();
$('.userBalance').attr('myBalance', data.balance);
updateBalance(data.oldBalance, data.balance);
},
error: function(data){
console.log(data)
$('#buttonMax').css('pointer-events', '');
$('#buttonMin').css('pointer-events', '');
$('#betLoad').css('display', 'none');
$('#error_bet').html(data.responseJSON.error || "Произошла залупа");
return $('#error_bet').css('display', '');
}
});
}
function updateProfit() {
$('#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 sss() {
$('#hashBet').fadeOut('slow', function() {
$('#hashBet').fadeIn('slow', function() {
});
});
}
$('#BetPercent').keyup(function() {
$('#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));
});
$('#BetSize').keyup(function() {
$('#MinRange').html(Math.floor(($('#BetPercent').val() / 100) * 999999));
$('#MaxRange').html(999999 - Math.floor(($('#BetPercent').val() / 100) * 999999));
$('#BetProfit').html(((100 / $('#BetPercent').val()) * $('#BetSize').val()).toFixed(2));
});
function updateBalance(start, end) {
var el1 = document.querySelector('#main .userBalance');
od1 = new Odometer({
el: el1,
value: start,
duration: 1000,
format: '( ddd),dd'
});
od1.update(end);
try{
var el2 = document.querySelector('#mines .userBalance');
od2 = new Odometer({
el: el2,
value: start,
duration: 1000,
format: '( ddd),dd'
});
od2.update(end);
}catch(ex){}
try{
var el3 = document.querySelector('#jackpot .userBalance');
od3 = new Odometer({
el: el3,
duration: 1000,
format: '( ddd),dd'
});
od3.update(end);
}catch(ex){}
}
function validateWithdrawSize(inp) {
inp.value = inp.value.replace(/[,]/g, '.')
.replace(/[^\d,.]*/g, '')
.replace(/([,.])[,.]+/g, '$1')
.replace(/^[^\d]*(\d+([.,]\d{0,2})?).*$/g, '$1');
}
function validateBetPercent(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');
recalc();
}
function validateBetSize(inp) {
inp.value = inp.value.replace(/[,]/g, '.')
.replace(/[^\d,.]*/g, '')
.replace(/([,.])[,.]+/g, '$1')
.replace(/^[^\d]*(\d+([.,]\d{0,2})?).*$/g, '$1');
recalc();
}
function deposit() {
if ( $('#depositSize').val() == ''){
$('#error_deposit').show();
return $('#error_deposit').html('Введи скок');
}
if (!$.isNumeric($('#depositSize').val())){
$('#error_deposit').show();
return $('#error_deposit').html('Введи норм бля скок');
}
$.ajax({
type: 'POST',
url: '/api/deposit',
headers: {
'x-token': Cookies.get('token'),
'Content-Type': 'application/json'
},
data: JSON.stringify({
amount: parseFloat($("#depositSize").val())
}),
success: function(data) {
document.location.href = data.data;
},
error: function(data) {
$("#error_deposit").show();
$("#error_deposit").html(data.responseJSON.error || "Произошла залупа");
}
});
}
function changeName() {
if ( $('#depositSize').val().length < 2 || $('#depositSize').val().length > 15){
$('#error_deposit').show();
return $('#error_deposit').html('Кликуха должна быть от 3 до 15 букв.');
}
$.ajax({
type: 'POST',
url: '/api/name',
beforeSend: function() {
$('#nameB').html('');
$('#error_name').hide();
$('#success_name').hide();
$('#loader').css('display', '');
},
headers: {
'x-token': Cookies.get('token'),
'Content-Type': 'application/json'
},
data: JSON.stringify({
name: $("#nameChange").val()
}),
success: function(data) {
$('#nameB').html('Сменить кликуху');
$('#loader').css('display', 'none');
$('#emptyHistory').hide();
$('#error_name').hide();
$('#success_name').show();
$("#myName").html($("#nameChange").val());
},
error: function(data) {
$('#loader').css('display', 'none');
$('#success_name').hide();
$("#error_name").show();
$("#error_name").html(data.responseJSON.error || "Произошла залупа");
$('#nameB').html('Сменить кликуху');
}
});
}
function demoBalanceReset(){
$.ajax({
type: 'POST',
url: '/api/demo/reset',
headers: {
'x-token': Cookies.get('token')
},
success: function(data) {
$('.userBalance').attr('myBalance', data.balance);
updateBalance(data.oldBalance, data.balance);
try{
updateBalanceMines(data.oldBalance, data.balance);
}catch(ex){}
}
});
}
function removePayout(id){
$.ajax({
type: 'POST',
url: '/api/removePayout',
headers: {
'x-token': Cookies.get('token'),
'Content-Type': 'application/json'
},
data: JSON.stringify({
id: id
}),
success: function(data) {
updateBalance(data.oldBalance, data.balance);
$('[payout-id="' + id + '"] .tag').html('Отъебись');
$('[payout-id="' + id +'"] .tag').addClass('tag-danger');
$('[payout-id-action="' + id + '"]').remove();
}
});
}
var chatTimer = 0;
function sendMessage(){
if($("#chatInput").val().length < 3 || $("#chatInput").val().length > 200) return;
if(chatTimer > 0) return;
$.ajax({
type: 'POST',
url: '/api/chat',
headers: {
'x-token': Cookies.get('token'),
'Content-Type': 'application/json'
},
data: JSON.stringify({
text: $("#chatInput").val()
}),
success: function(data) {
$("#chatInput").val('');
chatTimer = 5;
$('.send').html(chatTimer);
var int = setInterval(function(){
if(chatTimer == 1){
$('.send').html('');
clearInterval(int);
chatTimer = 0;
}else{
chatTimer--;
$('.send').html(chatTimer);
}
}, 1000);
}
});
}
function deleteMessage(id){
$.ajax({
type: 'POST',
url: '/api/deleteMessage',
headers: {
'x-token': Cookies.get('token'),
'Content-Type': 'application/json'
},
data: JSON.stringify({
id: id
})
})
}
function chatBan(id){
$.ajax({
type: 'POST',
url: '/api/chatBan',
headers: {
'x-token': Cookies.get('token'),
'Content-Type': 'application/json'
},
data: JSON.stringify({
id: id
})
})
}
var menuTimeout = null;
function pickGame(game, type){
gameChangedAudio.play();
var games = ['jackpot', 'main', 'mines'];
for (var i = 0; i < games.length; i++) {
$("#" + games[i]).hide();
if(i != game){
$(".games .item:nth-child(" + (i + 1) + ") img").attr('src', './files/menu/' + (i + 1) + '.png');
$(".games .item:nth-child(" + (i + 1) + ")").css('background', 'white');
$(".games .item:nth-child(" + (i + 1) + ")").css('color', '#404E67');
}else{
$(".games .item:nth-child(" + (i + 1) + ") img").attr('src', './files/menu/' + (i + 1).toString() + (i + 1).toString() + '.png');
$(".games .item:nth-child(" + (i + 1) + ")").css('background', 'linear-gradient(to right, #a7b2bf, #7a8694)');
$(".games .item:nth-child(" + (i + 1) + ")").css('color', 'white');
}
$("#" + games[i] + " .loader").remove();
clearTimeout(menuTimeout);
}
if(!type){
$("#" + games[game]).css('position', 'relative');
$("#" + games[game] + " .card").append('');
}
Cookies.set("game", game);
$("#" + games[game]).show();
menuTimeout = setTimeout(function(){
$("#" + games[game] + " .loader").remove();
}, 900);
}
VK.Widgets.CommunityMessages("vk_community_messages", 169192929);