// JavaScript Document let Blink = true; let canUseLovelyButton = true; let GettingInfoAboutGame = []; // лист игр, ожидающих обновления информации о начале следующего тиража // Запускать при запуске формы index function IndexOnLoad() { // .lovely-game .games-container if (!istmUserId()) { // Пользователь не вошел. Значок "любимой игры" не отображается const selectLovelyGame = document.querySelectorAll('.custom-checkbox'); const cardTextContent = document.querySelectorAll('.text-cont'); selectLovelyGame.forEach(el => { el.style.display = 'none'; }); } else { const lovelyGames = document.querySelector('.lovely-games'); if (lovelyGames) { const childsContainer = Array.from( lovelyGames.querySelectorAll('.games-container .game-card') ); if (childsContainer.length === 0) { lovelyGames.classList.add('d-none'); document.querySelector("[data-filter='8']").classList.add('d-none'); } } } $('document').ready(() => { $('.filters__wrapper .games__filter') .sort((a, b) => $(a).data('filter') - $(b).data('filter')) .appendTo('.filters__wrapper'); (async function () { const buttons = document.querySelectorAll('.wheel__banner-button'); const wheelStartButton = document.querySelector('.wheel__start'); await fontLoader('Panton', 'https://rpo.logycom.kz/tm/static/fonts/panton/panton_regular.woff'); await fontLoader( 'PantonExtra', 'https://rpo.logycom.kz/tm/static/fonts/panton/panton_extrabold.woff' ); document.fonts.ready.then(() => { const baner = document.querySelector('#anotherWheelBanner'); if ($('.active-menu').length == 0 && wheelSettings && wheelInterval === 0) { // Remove call open modal when page is loaded // wheelGame.openModal(); wheelGame.handeBannerModalOpen(baner); } if (baner) { baner.addEventListener('click', () => wheelGame.openModal()); } buttons.forEach(button => { if (wheelInterval == '0') { button.classList.add('enabled'); button.textContent = 'Крутить'; button.addEventListener('click', () => { wheelGame.handleCreateModal(); }); } else if (wheelInterval > 1) { wheelGame.setGrayScale(button); button.classList.add('waiting'); wheelGame.setTimer( button, element => { wheelGame.removeGrayScale(element) element.classList.remove('waiting'); element.classList.add('enabled'); element.textContent = 'Крутить'; wheelGame.openModal(); }, wheelInterval, undefined ); wheelGame.setTimer( wheelStartButton, element => { wheelGame.removeGrayScale(element) element.classList.remove('waiting'); element.classList.add('enabled'); element.textContent = 'Крутить'; wheelGame.openModal(); }, wheelInterval, undefined ); wheelGame.isSetWheelStartTimer = true; } else { button.textContent = 'Крутить'; } }); }); })(); // Cкрытие всех моментальных/быстротиражных лотерей $('.back-button').click(hideAllGames); }); const filters = Array.from(document.querySelectorAll('.games__filter')).filter(element => { if (element.dataset.filter === '0' || element.dataset.filter === '-1') { return false; } return element; }); if (filters.length === 0) { document.querySelector('.games__filters').classList.add('d-none'); } const filteredGames = document.querySelector('#filteredGames'); const filteredTitle = document.querySelector('#filteredTitle'); const allFilters = document.querySelectorAll('.games__filter'); // const buttonOpenMoreFilters = document.querySelector('#openMoreFilters'); // if (checkMobileDevice() && allFilters.length > 4) { // buttonOpenMoreFilters.style.display = 'block'; // allFilters.forEach((e, i) => { // if (i > 3 && !e.classList.contains('games__filter_more')) { // e.style.display = 'none'; // } // }) // } //Запоненость профиля if ($('#fProfileFull').length) { $('#fProfileFull1').html( $('#fProfileFull').html() == '0' ? 'Профиль, для зачисления выигрыша, не запонен' : 'Профиль, для зачисления выигрыша, запонен' ); $('#fProfileFull2').html( $('#fProfileFull').html() == '0' ? 'Заполнить' : 'Просмотреть' ); } // Фильтры $('div[data-filter]').on('click', function () { $('html, body').animate( { scrollTop: document.querySelector( `${checkMobileDevice() ? '#swiperMobile' : '#swiperDesktop'}` ).scrollHeight + document.querySelector('.cards-slider-wrapper').scrollHeight + 20, }, 500 ); const filterId = $(this).attr('data-filter'); if (filterId == -1) { allFilters.forEach((e, i) => { if (i > 2) { $(e).fadeIn(280); } }); // buttonOpenMoreFilters.style.display = 'none'; return; } else if (filterId == 0) { showMainGames(); } else { hideMainGames(); filteredTitle.textContent = this.textContent; filteredGames.innerHTML = ''; getFilteredGames(filterId, filteredGames); } $('div[data-filter]').each(function (i, a) { $(a).removeClass('active'); if (a.dataset.filter == filterId) { if (a.dataset.filter == 8) { $('.lovely-games').fadeOut(200); } else { $('.lovely-games').fadeIn(200); $(a).addClass('active'); } } }); }); function setHeaderBackground(background) { if (!background) return; const header = document.querySelector('.header'); return (header.style.background = background); } function getCurrentSlideTheme(swiper) { if (swiper.slides.length) { const dataBg = swiper.slides[swiper.activeIndex].querySelector('.card-image'); if (dataBg) { return dataBg.getAttribute('data-background'); } return false; } } // Слайдер var swiper = new Swiper('.swiper-container', { slidesPerView: 1, speed: 500, centeredSlides: true, grabCursor: true, loop: true, preloadImages: false, // Enable lazy loading lazy: { loadPrevNext: true }, pagination: { el: '.swiper-pagination', clickable: true, }, autoplay: { delay: 7000, disableOnInteraction: false, }, navigation: { nextEl: '.swiper__next', prevEl: '.swiper__prev', }, on: { slideChange: swiper => { if (checkMobileDevice()) { const currentBg = getCurrentSlideTheme(swiper); setHeaderBackground(currentBg); } }, init: swiper => { if (checkMobileDevice()) { const currentBg = getCurrentSlideTheme(swiper); setHeaderBackground(currentBg); } }, }, }); SetOnClick(); // Обработка таймеров ticTimer(); setInterval(ticTimer, 500); } const isMobileDevice = () => { return document.documentElement.clientWidth < 1024; } const resize = (element) => { const currentElement = document.querySelector(element); if (isMobileDevice()) { currentElement.style.transform = `scale(${getScale(currentElement)}) translate(-50%)`; currentElement.style.transformOrigin = "0 0 0"; } else { currentElement.style.transform = `translate(-50%, -50%) scale(${getScale(currentElement)})`; currentElement.style.transformOrigin = "unset"; } } const getScale = (element) => { let scale; const containerWidth = isMobileDevice() ? element.offsetWidth : 1440; const containerHeight = isMobileDevice() ? document.documentElement.clientHeight : 974; if (isMobileDevice()) { scale = document.documentElement.clientWidth / containerWidth; } else { if (document.documentElement.clientWidth >= containerWidth) scale = 1; scale = Math.min(document.documentElement.clientWidth / containerWidth, document.documentElement.clientHeight / containerHeight) } return scale; } function getChancesTitle(type, name) { if (type === 0) { return "Лото Бокс"; } else if (type === 1) { return name; } else if (type === 2) { return "крути ещё"; } else if (type === 3) { return "удача впереди"; } } function fixType(type) { // пока оставлю тут // цвета из wheelSettings поэтому типы надо переделать if (type === 0) return 6 else if (type === 1) return 3 else if (type === 2) return 1 else if (type === 3) return 0 } function sectionBall(type) { const _type = fixType(type); const _wheelSetting = JSON.parse(wheelSettings); const color = _wheelSetting.find((item) => item.type === _type).color; switch (type) { case 0: return `
` break; case 1: return `
` break; case 2: return `
` break; case 3: return `
` break; default: break; } } function showAllGames() { $('body').attr('data-scroll-position', window.pageYOffset); const targetBlockId = $(this).data('target'); $('.main').hide(); $('.container-main').hide(); $(`#${targetBlockId}`).show(); checkMobileDevice() && $('.header').addClass('dark-header'); window.scrollTo(0, 0); } function hideAllGames() { $('.main').show(); $('.container-main').show(); $('.moment-lottery-full').hide(); window.scroll(0, document.body.getAttribute('data-scroll-position')); checkMobileDevice() && $('.header').removeClass('dark-header'); } function setLovelyGame(event) { if (canUseLovelyButton) { canUseLovelyButton = false; const target = event.target; const gameId = target.getAttribute('data-lovely-id'); const targets = document.querySelectorAll(`[data-game-id="${gameId}"]`); if (!target.checked) { document .querySelectorAll(`[data-lovely-id="${target.dataset.lovelyId}"]`) .forEach(element => (element.checked = false)); } $.ajax({ url: 'https://rpo.logycom.kz/tm/threemen.dll/srvEx', async: true, type: 'GET', data: { srv: 'gameLovely', game: target.getAttribute('data-lovely-id'), lovely: target.checked, }, dataType: 'text', success: data => { if (target.checked) { targets.forEach(element => { if (element.querySelector('input[type="checkbox"]') !== null) { element .querySelector('input[type="checkbox"]') .setAttribute('checked', true); } }); target.setAttribute('checked', true); } else { targets.forEach(element => { if (element.querySelector('input[type="checkbox"]') !== null) { element .querySelector('input[type="checkbox"]') .removeAttribute('checked'); } }); target.removeAttribute('checked'); } document.querySelector('.lovely-games .games-container').innerHTML = ''; if (data !== '') { document.querySelector("[data-filter='8']").classList.remove('d-none'); document.querySelector('.lovely-games .games-container').innerHTML += data; document.querySelector('.lovely-games').classList.remove('d-none'); SetOnClick(); } else { document.querySelector("[data-filter='8']").classList.add('d-none'); document.querySelector('.lovely-games').classList.add('d-none'); } canUseLovelyButton = true; }, error: err => { showError(err ? err : 'Что-то пошло не так'); canUseLovelyButton = true; }, }); } } function ticTimer() { // Обеспечивает отображение текста таймеров Blink = !Blink; $('div[data-timer-id]').each(function () { var tmr = $(this); var dt = parseInt(tmr.attr('data-timer')); if (dt == -1) tmr.html(' '); // Нет информации о тираже else if (dt == -2) tmr.html('Тираж идет'); else if (dt == 0) { // Тираж вот сейчас идет. Надо перезапросить новое время setTimerTxt(tmr, 'Тираж идет', -2); // включим режим ожидания информации о тираже if (GettingInfoAboutGame.indexOf(tmr.attr('data-timer-id')) == -1) { GettingInfoAboutGame.push(tmr.attr('data-timer-id')); setTimeout( GetInfoAboutGame, 8000, { srv: 'gameDraw', gameid: tmr.attr('data-timer-id') }, tmr.attr('data-timer-id') ); } } else { // До тиража сколько то времени. Пишем текст if (Blink) dt--; var txt, ss = dt % 60; var dd = (dt - ss) / 60; var mm = dd % 60; dd = (dd - mm) / 60; var hh = dd % 24; dd = (dd - hh) / 24; /* Поменял С 20ю08ю2021 по просьбе АЛ if (dd !== 0) txt = '' + dd + ' дн ' + addZero(2, hh) + ' ч' else if (hh !== 0) txt = '' + hh + ' ч ' + addZero(2, mm) + ' м' else txt = '' + mm + ' м ' + addZero(2, ss) + ' с'; if (!Blink && dd == 0 && hh == 0 && mm == 0) setTimerTxt(tmr, ' ', dt); else setTimerTxt(tmr, 'Тираж через 500'.replace('500', txt), dt);*/ if (dd !== 0) txt = '' + dd + ' дн ' + addZero(2, hh) + ' ч'; else if (hh !== 0) txt = '' + hh + ' ч ' + addZero(2, mm) + ' м'; else txt = '' + mm + ' м ' + addZero(2, ss) + ' с'; if (!Blink && dd == 0 && hh == 0 && mm == 0) setTimerTxt(tmr, ' ', dt); else setTimerTxt( tmr, 'Тираж через 500'.replace('500', txt) + '', dt ); } }); // Обеспечивает сортировку блоков в зависимости от времени запуска $('div[data-sort]').each(function () { var area = $(this); if ( area.children().first().children().first().attr('data-for-sort') == -2 || area.children().first().children().first().children().first().attr('data-for-sort') == -2 ) { // Начался тираж. Нужно убирать в самый низ. Убираем по одной, что бы не зациклиться var s = area.html(), sp = ''; area.html( s.substring(s.indexOf(sp) + sp.length) + s.substring(0, s.indexOf(sp) + sp.length) ); SetOnClick(); } }); } function setTimerTxt(tmr, txt, time) { // Устанавливает текст и data-timer в таймере, а заодно и data-for-sort у блока, отвечающего за игру tmr.html(txt).attr('data-timer', time); tmr.parents().each(function () { if ($(this).data('for-sort')) { $(this).attr('data-for-sort', time); return false; } }); } let code = 6458; function SetOnClick() { // Привязывет обработчик к on click // Запуск игры $('div[data-game-id], .lovelyButton, .custom-checkbox, .show-all-lottery').off('click'); // выключил, что бы не назначалось несколько обработчиков на onclick этих элементов $('div[data-game-id]').on('click', function () { // может тут он назначает много обработчиков на нестираемые игры !!!!!!!!!!!!!!!!!!!!!!!!!!! if ($(this).attr('data-can-play') == '0') showError('Для игры в эту игру необходимо ввести номер телефона'); if ($(this).attr('data-can-play') == '1') showMsg('Скоро запуск'); if ($(this).attr('data-can-play') == '2') { window.location.href = 'https://rpo.logycom.kz/tm/threemen.dll/game?gameid=' + $(this).attr('data-game-id'); $(this).off('click'); } if ($(this).attr('data-can-play') == '3') window.open('https://rpo.logycom.kz/tm/threemen.dll/gamedemo?gameid=' + $(this).attr('data-game-id'), '_top'); if ($(this).attr('data-can-play') == '4') showWarn('Для покупки необходимо войти или зарегистрировать личный кабинет!'); if ($(this).attr('data-can-play') == '5') { window.location.href = 'https://rpo.logycom.kz/tm/threemen.dll/gamedemo?gameid=' + $(this).attr('data-game-id'); $(this).off('click'); } if ($(this).attr('data-can-play') == '6') window.open('https://rpo.logycom.kz/tm/threemen.dll/game?gameid=' + $(this).attr('data-game-id'), '_top'); }); $('.lovelyButton').click(setLovelyGame); $('.show-all-lottery').click(showAllGames); $('.custom-checkbox').click(function (e) { e.stopPropagation(); }); } function GetInfoAboutGame(message, gameId) { AsyncRecieveFromSrv(message, gameId, function (msg, message, gameId) { if (msg['status'] == 'OK' && msg['ticCount'] > 10) { var tmp = GettingInfoAboutGame.slice(0, GettingInfoAboutGame.indexOf(gameId)); // получили результат. сотрем из листа ожиданий GettingInfoAboutGame = tmp.concat( GettingInfoAboutGame.slice(GettingInfoAboutGame.indexOf(gameId) + 1) ); $('div[data-timer-id="' + gameId + '"]').each(function () { $(this).attr('data-timer', msg['ticCount']); }); } else setTimeout(GetInfoAboutGame, 3000, message, gameId); // подождем 1 секунды до даты нового тиража }); } $(function () { $('.winners__container a[data-hidden="textIsEmpty"]').each(function () { $(this).removeAttr('href'); }); }); function hideMainGames() { $('.filtered-games').show(); $('[data-games-main="1"').fadeOut(300); } function showMainGames() { $('[data-games-main="1"').fadeIn(100); $('.filtered-games').fadeOut(100); } function getFilteredGames(filterID, container) { $.ajax({ url: 'https://rpo.logycom.kz/tm/threemen.dll/srvEx', async: true, type: 'GET', data: { srv: 'gamesList', filterID: filterID }, dataType: 'text', success: data => { $(container).hide().fadeIn(300); container.innerHTML = data; }, error: err => { showError(err ? err : 'Что-то пошло не так'); }, }); } function setDefaultImage(el) { const gameId = el.parentNode.dataset.gameId; $(el).attr('src', 'https://rpo.logycom.kz/tm/threemen.dll/picture?bigGame=' + gameId); }