function unsubscribe(){ var unsub_data = {"email":"", "tag":""}; unsub_data.email = pinup.getCookie("pinup-unsubscribe_hash") || ""; unsub_data.tag = pinup.getCookie("pinup-tag") || "*"; if (unsub_data.email!=""){ initPopup("popupSubCancel"); $("#popup_subcancel_accept_btn").forceClick(function(){ removePopup(); hash = pinup.getCookie("pinup-unsubscribe_hash"); tag = pinup.getCookie("pinup-tag") || "*"; $.removeCookie("pinup-unsubscribe_hash", { path: '/' }); $.removeCookie("pinup-tag", { path: '/' }); $.ajax({ url: '/ajax/players/unsubscribe', type: 'POST', data: { "hash": hash, "tag": tag, }, timeout: 15000, success: function(result) { if (result.error == null) { initNotice(getLoc("popup_mainJS_successful_unsubscribe")) } else { initNotice(result.error.message1 + ' ' + result.error.message2); } } }); }); $("#popup_subcancel_close_btn").forceClick(function(){ removePopup(); $.removeCookie("pinup-unsubscribe_hash", { path: '/' }); $.removeCookie("pinup-tag", { path: '/' }); }); $(".js--popup__close").forceClick(function(){ removePopup(); $.removeCookie("pinup-unsubscribe_hash", { path: '/' }); $.removeCookie("pinup-tag", { path: '/' }); }); } }; function removePopup(){ $.each($('div.popup'), function(idx, item) { item.remove(); }); $('body').removeClass('page_shadow'); }; function checkUnsubCookie(){ var email = pinup.getCookie("pinup-unsubscribe_hash") || ""; if (email!=""){ unsubscribe() }; }; window.checkTournament = function(tournamentsID) { if (!$.isArray(tournamentsID)) { return false } if (tournamentsID.length === 0) { return false } for (i = 0; i < tournamentsID.length; i++) { var tournament = window.tournaments[tournamentsID[i]]; if (tournament !== undefined) { var now = new Date(); if (tournament.timeStart <= now && tournament.timeEnd > now) { return true } } } return false }; $(function() { console.log("index.js: start") checkUnsubCookie(); var $popup = $('#popup'); var $content = $('#main_content'); var filter = { page: "", pageAllGames: 1 }; function getUrlVars() { var vars = [], hash; var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); for(var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); vars.push(hash[0]); vars[hash[0]] = hash[1]; } return vars; } filter.host = $(location).attr('host'); // window.onload = function() { setTimeout(function(){ var anc = window.location.hash.replace("#", ""); filter.gamesystem = window.gamesystem; filter.gametype = window.gametype; filter.count = "default"; if (isMob) { filter.count = "mob"; } if (anc != "") { location.href = "#"; location.hash = "#"; var res = anc.split("_") switch (res[0]) { case "cashboxdeposit": setTimeout(function(){ $(window).scrollTo('#body'); window.defaultSum = 0; window.OpenCashboxDeposit("casino"); setTimeout(function(){ if (!$('.cashbox__item--active')[0]) { handleCashItemOur($('.cashbox__item')[0], 'popup') } }, 250); }, 5000); break; case "registration": if (!window.isAuthorization) { if (res.length==2){ switch (res[1]){ case "mob": case "mob/": $.when(window.OpenPopupRegistration(true)).then(function(){ $('#popup_reg_typeEmail').removeClass('popup__nav-item--active'); $('#popup_reg_typePhone').addClass('popup__nav-item--active'); $('#popup_reg_email_inputEmail').css('display', 'none'); $('#popup_reg_email_inputPassword').css('display', 'none'); $('#popup_reg_typeSoc').css('display', 'none'); $('#popup_reg_phone_header').css('display', 'block'); $('#popup_reg_phone_div_inputPhone').css('display', 'block'); $('#popup_reg_email_buttonRegistration').css('display', 'none'); $('#popup_reg_phone_buttonRegistration').css('display', 'block'); }); break; case "email": case "email/": $.when(window.OpenPopupRegistration(true)).then(function(){ $('#popup_reg_typeEmail').addClass('popup__nav-item--active'); $('#popup_reg_typePhone').removeClass('popup__nav-item--active'); $('#popup_reg_email_inputEmail').css('display', 'block'); $('#popup_reg_email_inputPassword').css('display', 'block'); $('#popup_reg_typeSoc').css('display', 'block'); $('#popup_reg_phone_header').css('display', 'none'); $('#popup_reg_phone_div_inputPhone').css('display', 'none'); $('#popup_reg_email_buttonRegistration').css('display', 'block'); $('#popup_reg_phone_buttonRegistration').css('display', 'none'); window.EnterForSubmit('#reg_email', '#popup_reg_email_buttonRegistration'); window.EnterForSubmit('#reg_password', '#popup_reg_email_buttonRegistration'); }); break; }; } else { window.OpenPopupRegistration(); }; } break; case "authorization": if (!window.isLogin) { $('#popup').empty(); $('#body').addClass('page_shadow'); $('#popup').tplPrepend('popup-auth', window.st); } break; case "registerMobile": initNotice(getLoc('popup_indexJs_reg_data_send_by_sms')); break; case "recovery": $('#popup').empty(); $('#body').addClass('page_shadow'); $('#popup').tplPrepend('popup-restore-newpassword', null); $('#popup_newpassword_hash').val(res[1]); break; case "cards": filter.gamesystem = "Карточные"; break; case "roulette": filter.gamesystem = "Рулетки"; break; case "notemail": $('#popup').empty().tplAppend('popup-verifi-email', null); $('#saveEmailButtonSlot').forceClick(function() { var data = new.html Object(); data.email = $('#email-verif-slot').val(); $.ajax({ url: '/ajax/players/saveEmail', type: 'POST', data: data, timeout: 15000, success: function(result) { if (result.error != null) { initNotice(result.error.message1 + " " + result.error.message2); return } window.email = data.email; $('body').removeClass('page_shadow'); $('#content').removeClass('contain_blur'); $('#popup').empty(); } }); }); break; case "verifiProfile": $('#popup').empty().tplAppend('popup-verifi-profile', window.player); SelectsItems(); handleInputDateFocus('.popup .fullreg__input-checkdate'); $('#saveProfileButtonSlot').forceClick(function() { if (!window.CheckBirthday("#profile-birthday-verif-slot", true)) { return } data = Object()%3b.html data.email = $('#profile-email-verif-slot').val(); data.firstname = $('#profile-name-verif-slot').val(); data.lastname = $('#profile-lastname-verif-slot').val(); data.sex = $('#profile-sex-verif-slot')[0].dataset.property; data.birthday = $('#profile-birthday-verif-slot').val(); $.ajax({ url: '/ajax/players/saveProfile', type: 'POST', data: data, timeout: 15000, success: function(result) { if (result.error != null) { if (result.error.message2 === "invalid_birthday") { initNotice(getLoc("popup_registrationHtml_scriptJs_birthday_error")) return } else { initNotice(result.error.message1 + " " + result.error.message2); return } } window.player.email = data.email; window.player.firstname = data.firstname; window.player.lastname = data.lastname; window.player.sex = data.sex; window.player.birthday = data.birthday; $('body').removeClass('page_shadow'); $('#content').removeClass('contain_blur'); $('#popup').empty(); }, }); }); break; case "cashbox": setTimeout(function() { $(window).scrollTo('#body'); }, 100); window.defaultSum = 0; window.OpenCashboxDeposit("casino"); setTimeout(function() { if (!$('.cashbox__item--active')[0]) { handleCashItemOur($('.cashbox__item')[0], 'popup') } }, 250); break; default: filter.gamesystem = res[0]; filter.gametype = res[1]; } } else { var popup = getUrlVars()["popup"]; if (popup == "registration") { window.OpenPopupRegistration(); } else if (popup == "bonusChoice") { loadPopupBonusChoice(); } } $.when(LoadPageAndStat()).then(function(){ $("#preloader").css("display", "none"); }); }, 299); function LoadPageAndStat(){ loadPageMain(); start(); } function loadPageMain() { startLastWin(); var timerlastwinUpdate = setInterval(function() { lastwinUpdate(); }, 15000); checkCookieGameSystem(); if (window.location.pathname.indexOf('/live') !== -1) { filter.isPage = "live"; } if (window.location.pathname.indexOf('/tvbet') !== -1) { filter.isPage = "tvgames"; } loadGames(); } function start() { loadGameSystems(); } function loadPopupBonusChoice() { $.ajax({ url: '/ajax/bonus/getBonusChoiceParamsPopup', type: 'POST', timeout: 15000, success: function(result) { if (result.error === null) { $(".hourBonusLine").css('display','none'); $('.layout').removeClass('page--alarm'); $('body').addClass('page_shadow'); $('#popup').empty(); $('#popup').tplAppend('popup-bonusChoice', result); var bonusChoice = { bonusChoice: 'no', }; $('.popup_bonusChoiceInfo').forceClick(function() { bonusChoice.bonusChoice = $(this).data('choice'); $.ajax({ url: '/ajax/bonus/getInfoBonus', type: 'POST', data: bonusChoice, timeout: 15000, success: function(result) { console.log(result); if (result.error === null) { $('#bonus-modal-sport').show(); $('#bonus-modal-sport').empty(); $('#bonus-modal-sport').append(result.info.html) } else { initNotice(result.error.message1 + " " + result.error.message2); } }, }); }); $('.close_and_show_yellowline').forceClick(function() { if (window.timeBonus && window.timeBonus > 0 && !getCookie('yellowLine')) { $(".hourBonusLine").css('display','block'); $('.layout').addClass('page--alarm'); } }); $('.popup_bonusChoiceSet').forceClick(function() { bonusChoice.bonusChoice = $(this).data('choice'); $.ajax({ url: '/ajax/bonus/set', type: 'POST', data: bonusChoice, timeout: 15000, success: function(result) { if (result.error === null) { if (result.action === "cashbox") { window.bonusChoiceParams.priority = bonusChoice.bonusChoice; window.defaultSum = 0; window.OpenCashboxDeposit("casino"); setTimeout(function(){ if (!$('.cashbox__item--active')[0]) { handleCashItemOur($('.cashbox__item')[0], 'popup') } }, 250); } else if (result.action === "registration") { if (result.license) { window.location.replace("/registration"); } else { window.OpenPopupRegistration(); } } } else { initNotice(result.error.message1 + " " + result.error.message2); } }, }); }); if ($(window).width() < 1024) { $(".bonus-page__list").addClass('owl-carousel') $(".bonus-page__list").owlCarousel({ stagePadding: 30, loop: false, margin: 20, rewind: true, responsive: { 0: { stagePadding: 30, items: 1 }, 375: { stagePadding: 50, items: 1 }, 411: { items: 1, stagePadding: 30 }, 768: { items: 2, stagePadding: 30 } } }); } } else { window.defaultSum = 0; window.OpenCashboxDeposit("casino"); setTimeout(function(){ if (!$('.cashbox__item--active')[0]) { handleCashItemOur($('.cashbox__item')[0], 'popup') } }, 250); } }, }); } $(window).on("hashchange", function(){ switch (window.location.hash){ case "#registration": if (!window.isLogin) { window.OpenPopupRegistration(); // $.when(window.OpenPopupRegistration()).then(window.MaskPhone("#popup_reg_countryinfo")); } break; case "#authorization": if (!window.isLogin) { $('#popup').empty(); $('#body').addClass('page_shadow'); $('#popup').tplPrepend('popup-auth', window.st); } break case "#unsubscribe": unsubscribe(); break; default: break; } }); var timerId; var oldText = ''; $('#search_games').keyup(function() { if (window.location.pathname.indexOf('/live') !== -1) { filter.isPage = "live"; } if (window.location.pathname.indexOf('/tvbet') !== -1) { filter.isPage = "tvgames"; } if (oldText !== $('#search_games').val()) { if (timerId) { clearTimeout(timerId); } timerId = setTimeout(function() { filter.searchGame = $('#search_games').val(); loadGames(); }, 300); oldText = $('#search_games').val(); } }); //На мобильной версии не работает keyup, здесь не работает this... $(document).on('input paste', '#search_games_mob', function() { if (window.location.pathname.indexOf('/live') !== -1) { filter.isPage = "live"; } if (window.location.pathname.indexOf('/tvbet') !== -1) { filter.isPage = "tvgames"; } if (oldText !== $('#search_games_mob').val()) { if (timerId) { clearTimeout(timerId); } timerId = setTimeout(function() { filter.searchGame = $('#search_games_mob').val(); loadGames(); }, 300); oldText = $('#search_games_mob').val(); } }); $('#change_favoritegame').forceClick(function() { if (window.isLogin) { request = ''; filter.gameId = $(this).data("id") if ($(this).data("type")) { request = '/ajax/players/delFavoriteGame' $(this).removeClass('active') $(this).data('type', false) } else { if (window.wsExists){ window.sendGoogleEvent('Игры','Добавил игру в избранное'); }; request = '/ajax/players/addFavoriteGame' $(this).addClass('active') $(this).data('type', true) } $.ajax({ url: request, type: 'POST', data: filter, timeout: 15000, success: function(result) { console.log("result: ",result); if (result.error != null) { initNotice(result.error.message1 + " " + result.error.message2); } }, }); } else { window.pinup.openNonAuth(); } }); $('#top_week').forceClick(function() { $.ajax({ url: '/ajax/index/topWeek', type: 'POST', timeout: 15000, success: function(result) { $('#last_win').removeClass('main__header-link--active'); $('#top_month').removeClass('main__header-link--active'); $('#top_week').addClass('main__header-link--active'); $('#middle_slider').empty(); $('#middle_slider').removeClass('owl-carousel'); $('#middle_slider').addClass('games__list'); $('#middle_slider').addClass('owl-carousel'); $('#middle_slider').tplAppend('item-main-wins', result.games); var $owl = $('.winners--common'); $owl.trigger('destroy.owl.carousel'); $owl.html($owl.find('.owl-stage-outer').html()).removeClass('owl-loaded'); $owl.owlCarousel({ items: 5, margin: 0, loop: true, nav: false, autoplay: true, autoplayTimeout: 4000, autoplaySpeed: 2000 }); }, }); }); $('#last_win').forceClick(function() { startLastWin(); }); $('#top_month').forceClick(function() { $.ajax({ url: '/ajax/index/topMonth', type: 'POST', timeout: 15000, success: function(result) { $('#top_week').removeClass('main__header-link--active'); $('#last_win').removeClass('main__header-link--active'); $('#top_month').addClass('main__header-link--active'); $('#middle_slider').empty(); $('#middle_slider').removeClass('owl-carousel'); $('#middle_slider').addClass('owl-carousel'); $('#middle_slider').tplAppend('item-main-wins', result.games); var $owl = $('.winners--common'); $owl.trigger('destroy.owl.carousel'); $owl.html($owl.find('.owl-stage-outer').html()).removeClass('owl-loaded'); $owl.owlCarousel({ items: 5, margin: 0, loop: true, nav: false, autoplay: true, autoplayTimeout: 4000, autoplaySpeed: 2000 }); }, }); }); $('#empty_input_search').forceClick(function() { filter.searchGame = ''; loadGames() }); $('#change_games, #change_games_mob').forceClick(function(event) { event.preventDefault ? event.preventDefault() : (event.returnValue = false); filter.gamesystem = $(this).data("id"); filter.gametype = $(this).data("type"); filter.pageAllGames = 1; filter.count = "default"; setCookieGameSystem(filter.gamesystem); if (window.location.pathname.indexOf('/live') !== -1) { filter.isPage = "live"; if (filter.gamesystem === 'all') { filter.gamesystem = 'live'; filter.gametype = 'gametype'; } } if (window.location.pathname.indexOf('/tvbet') !== -1) { filter.isPage = "tvgames"; if (filter.gamesystem === 'all') { filter.gamesystem = 'tvgames'; filter.gametype = 'gametype'; } } if (filter.gamesystem === 'favorite' && !window.isLogin) { $('#popup').empty(); $('#body').addClass('page_shadow'); ga('send', 'event', 'Открыть попап', 'Открытие окна регистрации'); $('#popup').tplAppend('popup-reg', window.st); return } if (filter.gamesystem === 'favorite' && window.isMob) { if ((window.location.pathname.indexOf('/live') !== -1)) { $('.sidebar__item--live-dillers').attr('hidden', false); } if (window.location.pathname.indexOf('/tvbet') !== -1) { $('.sidebar__item--tv-games').attr('hidden', false); } $('.sidebar__item--casino').attr('hidden', false); } if (window.isMob) { filter.count = 'mob'; } clearGameSelect(); $(this).addClass('main__header-link--active'); loadGames(); }); $('#button_all_games').forceClick(function() { filter.count = "all"; filter.pageAllGames = 1; loadGames(); }); var loadingAllGames = false; $(window).scroll(function () { if ($(window).scrollTop() + $(window).height() + 600 >= $(document).height()) { if (!loadingAllGames) { filter.pageAllGames++; loadingAllGames = true; loadGames(); } } }); function loadGames() { $.ajax({ url: '/ajax/index/changeGameList', type: 'POST', data: filter, timeout: 15000, success: function(result) { console.log("filter: ", filter); console.log("result: ", result); var checkAllGames = filter.count === 'all'; if (filter.searchGame !== '' && filter.searchGame !== undefined && filter.count !== 'all') { $('#game_list').empty(); } if (checkAllGames && Array.isArray(result.games) ) { if (result.games != null) { $('#game_list').tplAppend('item-main-game', result.games); } if (result.more) { $('#button_all_games').css("display", "block") } else { $('#button_all_games').css("display", "none") } loadingAllGames = false; return } else if (checkAllGames) { loadingAllGames = true; return } $('#game_list').empty(); if (result.games != null) { $('#game_list').tplAppend('item-main-game', result.games); } if (result.more) { $('#button_all_games').css("display", "block") } else { $('#button_all_games').css("display", "none") } favBut(); }, }); } function checkCookieGameSystem() { gameSystem = pinup.getCookie('pinup-gameSystem'); if (gameSystem !== null && gameSystem !== '' && (window.location.pathname.length === 1 || window.location.pathname.length === 4)) { filter.gamesystem = gameSystem; filter.gametype = 'gamesystem'; if (filter.gamesystem === 'all' || filter.gamesystem === 'new' || filter.gamesystem === 'favorite' || filter.gamesystem === 'table') { filter.gametype = 'select'; } if (filter.gamesystem === 'Слоты' || filter.gamesystem === 'Рулетки' || filter.gamesystem === 'Карточные') { filter.gametype = 'gametype'; } // if (filter.gamesystem === 'blackjack' || filter.gamesystem === 'poker' || filter.gamesystem === 'roulette') { // filter.gametype = 'gamesubtype'; // } pinup.deleteCookie('pinup-gameSystem'); } } function setCookieGameSystem(gameSystem) { if (window.location.pathname.length === 1 || window.location.pathname.length === 4) { pinup.setCookie('pinup-gameSystem', gameSystem, '1'); } } function startLastWin() { $.ajax({ url: '/ajax/index/lastwin', type: 'POST', timeout: 15000, success: function(result) { $('#middle_slider').removeClass('slick-initialized'); $('#middle_slider').removeClass('slick-slider'); $('#top_week').removeClass('main__header-link--active'); $('#top_month').removeClass('main__header-link--active'); $('#last_win').addClass('main__header-link--active'); $('#middle_slider').empty(); $('#middle_slider').addClass('owl-carousel'); $('#middle_slider').tplAppend('item-main-lastwin', result.lastwin); var $owl = $('.winners--common'); $owl.trigger('destroy.owl.carousel'); $owl.html($owl.find('.owl-stage-outer').html()).removeClass('owl-loaded'); $owl.owlCarousel({ items: 5, margin: 0, loop: true, nav: false, autoplay: true, responsiveClass:true, autoplayTimeout: 4000, autoplaySpeed: 2000 }); }, }); } function lastwinUpdate() { if ($('#top_month').hasClass('main__header-link--active') || $('#top_week').hasClass('main__header-link--active')) { return } $.ajax({ url: '/ajax/index/lastwin', type: 'POST', timeout: 15000, success: function(result) { var i = 0; var lengh = result.lastwin.length; $('.winners--common').trigger('stop.owl.autoplay'); $('.winners--common').find('.owl-stage').children().each(function(index) { if (i >= lengh) { return } if (!$(this).hasClass('active')) { $(this).html(`