Advertisement
Konark

JS for OFFV

May 22nd, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var preloader="<div class='loading'><div class='loader'></div></div>";
  2. window.vulcanNamespace = {};
  3. var xhr='';
  4.  
  5. $(function(){
  6.   // piwik test
  7.     var array = $('[data-piwik-event]');
  8.     array.each(function(index){
  9.         var item =  $(this)
  10.             ,eventName = item.attr('data-piwik-event').split(',');
  11.  
  12.         item.bind('click', function(){
  13.             _paq.push(['trackEvent', eventName[0], eventName[1], eventName[2]]);
  14.             console.log("Group: " + eventName[0] + ", " + "Event Name: " + eventName[2] + ", " + "Event Action: " + eventName[1]);
  15.         });
  16.     });
  17. //piwik
  18.  
  19.   $('.levels-table__item').on('touchend click', function(e) {
  20.     $('.levels-table__item').removeClass('levels-table__item_active');
  21.     $(this).addClass('levels-table__item_active');
  22.     $('.levels-table__arrow').removeClass('levels-table__arrow_active');
  23.     $(this).find('.levels-table__arrow').addClass('levels-table__arrow_active');
  24.   });
  25.  
  26.   $(".js-close-popup, [data-toggle='tab']").on('click', function(e) {
  27.     $('.payment__tooltip').removeClass("payment__tooltip_open");
  28.     //$(this).next('.payment__tooltip').toggleClass("payment__tooltip_open");
  29.   });
  30.  
  31.    $(".payitem").on('click', function(e) {
  32.     var $index=$(this).index(),
  33.         content = $('.payment__tooltip_open .pay-tooltip');
  34.  
  35.     $('.pay-tooltip__summ input[type="radio"]').on('click',function( i ) {
  36.       var volume_value = $(this).val();
  37.       $(this).parent().parent().find('.l_num').val(volume_value);
  38.       $(this).parent().parent().find('.input_summ_val').val(volume_value).focus();
  39.     });
  40.  
  41.     $('.js-input__inner').val('');
  42.     $('.pay-tooltip__note').hide();
  43.     $('.l_num').click().val('500');
  44.     $('.input_summ_val').val('500');
  45.     $('.input_summ_val').on('change, input', function () {
  46.       var volume_value = $(this).val();
  47.       $(this).parent().parent().find('.l_num').val(volume_value).click();
  48.     });
  49.  
  50.     $('.payment__tooltip').removeClass("payment__tooltip_open");
  51.     $(this).parent().parent().next('.payment__tooltip').toggleClass("payment__tooltip_open");
  52.    
  53.      var paysys=$(this).data("paysys");
  54.     if(paysys)
  55.       $(this).parents(".payment-form").attr('action','/engine/dir/pay/'+paysys+'/'+paysys+'.php');
  56.  
  57.      if($(this).find('input').val() === "qiwi_rub" || $(this).find('input').val() === "beeline_rub" || $(this).find('input').val() === "mts_rub" || $(this).find('input').val() === "megafon_rub" || $(this).find('input').val() === "tele2_rub") {
  58.       $('.pay-tooltip__phone').show();
  59.       $('.pay-tooltip').addClass('pay-tooltip_withphone');
  60.       //$('.pay-tooltip__phone_inner').mask("99999999999");
  61.       $('.pay-tooltip__phone_inner').attr('required', true);
  62.       $('.pay-tooltip__caption').removeAttr('id')
  63.       $('.pay-tooltip__caption').attr('id', 'other_payment_id');
  64.       document.getElementById("other_payment_id").textContent="Номер кошелька:";
  65.     } else if($(this).find('input').val() === "card_rub") {
  66.         $('.pay-tooltip__caption').attr('id', 'card_rub_id');
  67.         document.getElementById("card_rub_id").textContent="Номер карты:";
  68.         $('.pay-tooltip__summ').show();
  69.         $('.pay-tooltip__phone').hide();
  70.         $('.pay-tooltip').removeClass('pay-tooltip_withphone');
  71.         $('.pay-tooltip__phone_inner').attr('required', false);
  72.     } else {
  73.       $('.pay-tooltip__summ').show();
  74.       $('.pay-tooltip__phone').hide();
  75.       $('.pay-tooltip__caption').removeAttr('id')
  76.       $('.pay-tooltip__caption').attr('id', 'other_payment_id');
  77.       document.getElementById("other_payment_id").textContent="Номер кошелька:";
  78.       $('.pay-tooltip').removeClass('pay-tooltip_withphone');
  79.       $('.pay-tooltip__phone_inner').attr('required', false);
  80.     }
  81.  
  82.     if ($(this).find('input').val() === "qiwi_rub" && $(this).find('input').hasClass('payout')) {
  83.       $('.pay-tooltip__number').removeClass('pay-tooltip__number_withr');
  84.       $('.pay-tooltip__number').addClass('pay-tooltip__number_withplus');
  85.       $('.pay-tooltip__number_inner').removeClass('pay-tooltip__number_inner-noprefix');
  86.       $('.pay-tooltip__number_inner')
  87.           .attr({
  88.             required: true,
  89.             name: "account",
  90.             type: "tel",
  91.             placeholder: "70000000000",
  92.             maxlength: "14"
  93.           });
  94.     } else if ($(this).find('input').val() === "webmoney") {
  95.       $('.pay-tooltip__number').removeClass('pay-tooltip__number_withplus');
  96.       $('.pay-tooltip__number').addClass('pay-tooltip__number_withr');
  97.       $('.pay-tooltip__number_inner').removeClass('pay-tooltip__number_inner-noprefix');
  98.       $('.pay-tooltip__number_inner')
  99.           .attr({
  100.             required: true,
  101.             name: "account",
  102.             type: "text",
  103.             placeholder: "000000000000",
  104.             maxlength: "20"
  105.           });
  106.     } else if ($(this).find('input').val() === "pin") {
  107.      $('.pay-tooltip__summ').hide();
  108.       $('.pay-tooltip__pin_inner')
  109.           .attr({
  110.             required: true,
  111.             name: "pin",
  112.             type: "text",
  113.             placeholder: "0000000000",
  114.             maxlength: "10"
  115.           });
  116.       $('.pay-tooltip__pin').show();    
  117.     } else {
  118.       $('.pay-tooltip__summ').show();
  119.       $('.pay-tooltip__number').removeClass('pay-tooltip__number_withplus');
  120.       $('.pay-tooltip__number').removeClass('pay-tooltip__number_withr');
  121.       $('.pay-tooltip__number_inner').addClass('pay-tooltip__number_inner-noprefix');
  122.       $('.pay-tooltip__number_inner')
  123.           .attr({
  124.             required: true,
  125.             name: "account",
  126.             type: "text",
  127.             placeholder: "0000000000000",
  128.             maxlength: "20"
  129.           });
  130.     }
  131.  
  132.  
  133.  
  134.     $(this).find('.l_num').click();
  135.  
  136.  
  137.  
  138.     $('.js-input__inner').on("keyup, input", function(e) {
  139.       //if (e.keyCode != 37) {
  140.         if (this.value.match(/[^0-9]/g)) {
  141.           this.value = this.value.replace(/[^0-9]/g, '');
  142.         }
  143.      // }
  144.     });
  145.  
  146.  
  147.     if($index==0){
  148.       content.addClass('left').removeClass('right');
  149.     } else if($index==1){
  150.       content.removeClass('left').removeClass('right');
  151.     } else if($index==2){
  152.       content.removeClass('left').addClass('right');
  153.  
  154.     }
  155.  
  156.  
  157.   });
  158.  
  159.  
  160.   $('.slider_small').slick({
  161.     infinite: true,
  162.     slidesToShow: 8,
  163.     slidesToScroll: 1,
  164.     swipe: true,
  165.     draggable: true,
  166.     touchMove: true,
  167.     dots: false,
  168.     responsive: [
  169.       {
  170.         breakpoint: 1440,
  171.         settings: {
  172.           slidesToShow: 7,
  173.           slidesToScroll: 1,
  174.           dots: false
  175.         }
  176.       },
  177.       {
  178.         breakpoint: 1240,
  179.         settings: {
  180.           slidesToShow: 5,
  181.           slidesToScroll: 5,
  182.           dots: false
  183.         }
  184.       },
  185.       {
  186.         breakpoint: 1000,
  187.         settings: {
  188.           slidesToShow: 3,
  189.           slidesToScroll: 3,
  190.           dots: false
  191.         }
  192.       },
  193.       {
  194.         breakpoint: 768,
  195.         settings: {
  196.           slidesToShow: 3,
  197.           slidesToScroll: 2,
  198.           dots: false,
  199.           swipe: true,
  200.           draggable: true
  201.         }
  202.       }
  203.     ]
  204.   });
  205.  
  206.   $('.slider_info').slick({
  207.     infinite: true,
  208.     slidesToShow: 5,
  209.     slidesToScroll: 1,
  210.     dots: false,
  211.     autoplay: true,
  212.     autoplaySpeed: 1500
  213.   });
  214.  
  215.   $('.slider_tournament').slick({
  216.     infinite: true,
  217.     autoplay: false,
  218.     autoplaySpeed: 1500,
  219.     slidesToShow: 9,
  220.     slidesToScroll: 1,
  221.     dots: false,
  222.     responsive: [
  223.       {
  224.         breakpoint: 1240,
  225.         settings: {
  226.           slidesToShow: 7,
  227.           slidesToScroll: 1
  228.         }
  229.       },
  230.       {
  231.         breakpoint: 1000,
  232.         settings: {
  233.           slidesToShow: 6,
  234.           slidesToScroll: 1
  235.         }
  236.       },
  237.  
  238.       {
  239.         breakpoint: 768,
  240.         settings: {
  241.           slidesToShow: 3,
  242.           slidesToScroll: 2,
  243.           dots: false,
  244.           swipe: true,
  245.           draggable: true
  246.         }
  247.       }
  248.     ]
  249.   });
  250.  
  251.  
  252.   $('.slider_hero').slick({
  253.     dots: true,
  254.     arrows: false,
  255.     infinite: true,
  256.     autoplay: true,
  257.     autoplaySpeed: 5000,
  258.     speed: 500,
  259.     fade: true,
  260.     cssEase: 'linear',
  261.     responsive: [
  262.       {
  263.         breakpoint: 767,
  264.         settings: {
  265.           dots: false
  266.         }
  267.       }
  268.     ]
  269.   });
  270.  
  271.   $('.slider_hero').show();
  272.  
  273.   $('.slider_gameplay').not('.slick-initialized').slick({
  274.     infinite: true,
  275.     slidesToShow: 7,
  276.     slidesToScroll: 1,
  277.     dots: false
  278.   });
  279.  
  280.   $('.winsline').slick({
  281.     infinite: true,
  282.     slidesToShow: 5,
  283.     slidesToScroll: 1,
  284.     swipe: true,
  285.     dots: false,
  286.     arrows: false,
  287.     autoplay: true,
  288.     autoplaySpeed: 1500,
  289.     pauseOnFocus: true,
  290.     responsive: [
  291.       {
  292.         breakpoint: 1240,
  293.         settings: {
  294.           slidesToShow: 4,
  295.           slidesToScroll: 1,
  296.           pauseOnFocus: true
  297.         }
  298.       },
  299.       {
  300.         breakpoint: 999,
  301.         settings: {
  302.           slidesToShow: 3,
  303.           slidesToScroll: 1,
  304.           pauseOnFocus: true
  305.         }
  306.       },
  307.       {
  308.         breakpoint: 767,
  309.         settings: {
  310.           slidesToShow: 1,
  311.           slidesToScroll: 1,
  312.           pauseOnFocus: true
  313.         }
  314.       }
  315.     ]
  316.   });
  317.  
  318.   $('.winsline').show();
  319.  
  320.  
  321.   (function($) {
  322.     if ($(window).width() < 768) {
  323.       $('.leaderboard__slider').slick({
  324.         dots: true,
  325.         infinite: false,
  326.         arrows: false
  327.       });
  328.       $('.lottery-details__tickets').slick({
  329.         dots: true,
  330.         infinite: false,
  331.         arrows: false
  332.       });
  333.     }
  334.   })(jQuery);
  335.  
  336.   (function($) {
  337.     $('body').on('show', '.popup_tabs', function(){
  338.       if ($(window).width() < 768) {
  339.         $('.levels-table__table').ready(function(){
  340.           $('.levels-table__table').not('.slick-initialized').slick({
  341.             dots: true,
  342.             infinite: false,
  343.             arrows: false,
  344.             slidesToShow: 1,
  345.             slidesToScroll: 1
  346.           });
  347.           $('.levels-table__table').on('afterChange', function(event, slick, currentSlide, nextSlide){
  348.             var $dataId = $(slick.$slides[currentSlide]).data('target');
  349.             $(this).parent().find('.tab__content > div').removeClass('active');
  350.             $($dataId).addClass('active');
  351.           });
  352.         })
  353.       }
  354.     });
  355.   })(jQuery);
  356.  
  357.   // Tabs script
  358.  
  359.   //  needs adding .not('.slick-initialized') to work properly - in that case it is not initialized on already "slicked" slider
  360.  
  361.   $('.slider_small').not('.slick-initialized').slick({
  362.     infinite: true,
  363.     autoplay: true,
  364.     autoplaySpeed: 1500,
  365.     slidesToShow: 9,
  366.     slidesToScroll: 1,
  367.     dots: false
  368.   });
  369.  
  370.  
  371.  
  372.   // Gameplay scripts
  373.   $('.show__nav').on('click', function () {
  374.     $('.gameplay-nav-small').slideToggle();
  375.   });
  376.   $('.gameplay-nav__item').on('click', function() {
  377.  
  378.     $('.gameplay-nav').find('li').not($(this)).removeClass('gameplay-nav__item_active');
  379.     $('.gameplay__slider').not($($(this).data('target'))).removeClass('gameplay__slider_open').css('display', 'none');
  380.  
  381.     if ($(this).hasClass('gameplay-nav__item_active')) {
  382.       $(this).removeClass('gameplay-nav__item_active');
  383.       $($(this).data('target')).removeClass('gameplay__slider_open').css('display', 'none');
  384.     } else {
  385.       $(this).addClass('gameplay-nav__item_active');
  386.       $($(this).data('target')).addClass('gameplay__slider_open').css('display', 'block');
  387.     }
  388.   });
  389.  
  390.  
  391.  
  392.   $('.socials__item').on('click', function(){
  393.     $(this).toggleClass('socials__item_active');
  394.   });
  395.  
  396.   // Perfect scrollbar initialization
  397.  
  398.   (function($) {
  399.     if ($(window).width() > 700) {
  400.       $('.summary__content').not('.ps-container').perfectScrollbar({
  401.         theme: 'details',
  402.         suppressScrollX: true
  403.         // maxScrollbarLength: 213
  404.       });
  405.       $('.popup__gallery').not('.ps-container').perfectScrollbar({
  406.         theme: 'tabs',
  407.         suppressScrollX: true
  408.         // maxScrollbarLength: 213
  409.       });
  410.       $('.payment').not('.ps-container').perfectScrollbar({
  411.         theme: 'tabs',
  412.         suppressScrollX: true,
  413.         scrollXMarginOffset: 5
  414.         // maxScrollbarLength: 213
  415.       });
  416.  
  417.       $('.history').not('.ps-container').perfectScrollbar({
  418.         theme: 'tabs',
  419.         suppressScrollX: true
  420.         // maxScrollbarLength: 213
  421.       });
  422.  
  423.       $('.popup__history').not('.ps-container').perfectScrollbar({
  424.         theme: 'tabs',
  425.         suppressScrollX: true
  426.         // maxScrollbarLength: 213
  427.       });
  428.       $('.table-panel').not('.ps-container').perfectScrollbar({
  429.         theme: 'details',
  430.         suppressScrollX: true
  431.         // maxScrollbarLength: 213
  432.       });
  433.     }
  434.  
  435.   })(jQuery);
  436.  
  437.  
  438.   (function($) {
  439.     if ($(window).width() < 768) {
  440.       $('.main-nav').not('.ps-container').perfectScrollbar({
  441.         theme: 'hidden',
  442.         suppressScrollY: true,
  443.         scrollXMarginOffset: 5
  444.         // maxScrollbarLength: 213
  445.       });
  446.     }
  447.   })(jQuery);
  448.  
  449.   (function($) {
  450.     $('.header__wrap_scroll').not('.ps-container').perfectScrollbar({
  451.       theme: 'hidden',
  452.       suppressScrollY: true,
  453.       scrollXMarginOffset: 5
  454.       // maxScrollbarLength: 213
  455.     });
  456.   })(jQuery);
  457.  
  458.  
  459.   (function($) {
  460.     if ($(window).width() > 768) {
  461.       $('.modal_open .popup').not('.ps-container').not('.popup_tabs').perfectScrollbar({
  462.         theme: 'hidden'
  463.       });
  464.     }
  465.   })(jQuery);
  466.  
  467.   // Chosen Select styling
  468.  
  469.   $(".filter__select").chosen({disable_search: true});
  470.  
  471.   // Date picker - Zebra_Datepicker
  472.  
  473.  
  474.   $('input.datepicker_start').Zebra_DatePicker({
  475.     offset: [-150, 40],
  476.     default_position: 'below',
  477.     show_icon: false,
  478.     direction: true,
  479.     format: 'm/d/Y',
  480.     show_clear_date: false,
  481.     show_select_today: false,
  482.     pair: $('input.datepicker_end')
  483.   });
  484.  
  485.   $('input.datepicker_end').Zebra_DatePicker({
  486.     offset: [-150, 40],
  487.     default_position: 'below',
  488.     show_icon: false,
  489.     format: 'm/d/Y',
  490.     show_clear_date: false,
  491.     show_select_today: false,
  492.     direction: 1
  493.   });
  494.  
  495.   $('input.datepicker_birth').Zebra_DatePicker({
  496.     offset: [-280, 40],
  497.     days: ['Вс.', 'Пн.', 'Вт.', 'Ср.', 'Чт.', 'Пт.', 'Сб.'],
  498.     months: ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'],
  499.     default_position: 'below',
  500.     show_icon: false,
  501.     format: 'Y-m-d',
  502.     show_clear_date: false,
  503.     show_select_today: false
  504.   });
  505.  
  506.   // Lottery range input
  507.  
  508.   $('input.range__input').ionRangeSlider({
  509.     type: "double",
  510.     grid: true,
  511.     grid_snap: true,
  512.     min: 1,
  513.     max: 7,
  514.     from: 1,
  515.     step: 1,
  516.     to: 2,
  517.     from_fixed: true,
  518.     prefix: "x",
  519.     hide_from_to: true,
  520.     hide_min_max: true,
  521.     onStart: function (data) {
  522.       $('.irs-grid-text').each( function( index, element ){
  523.         $(this).removeClass('irs-grid-text_active');
  524.         if (index === data.to - 1) {
  525.           $(this).addClass('irs-grid-text_active');
  526.         }
  527.       });
  528.     },
  529.     onChange: function (data) {
  530.       var toValue = data.to;
  531.       //console.log(toValue);
  532.       $('.irs-grid-text').each( function( index, element ){
  533.         $(this).removeClass('irs-grid-text_active');
  534.         if (index === data.to - 1) {
  535.           $(this).addClass('irs-grid-text_active');
  536.         }
  537.       });
  538.     }
  539.   });
  540.  
  541.  
  542.   // Nav scripts
  543.  
  544.   var heroHeight = $('.hero__wrap').outerHeight();
  545.   var subnavHeight = $('.main-nav__subnav').outerHeight();
  546.  
  547.  
  548.   $(".main-nav__item_subnav").hover(
  549.       function() {
  550.         if(!$(this).hasClass('main-nav__item_active')) {
  551.           if (!$(".hero__nav").hasClass("hero__nav_sticky")) {
  552.             if ($('.main-nav').outerHeight() <= 50) {
  553.               $('.hero__wrap').animate({height: (subnavHeight + heroHeight) + "px"}, {queue: false, duration: 100});
  554.               $('.main-nav').attr('style', 'overflow: initial !important');
  555.             } else {
  556.               $('.hero__wrap').animate({height: (subnavHeight + heroHeight) + "px"}, {queue: false, duration: 100});
  557.             }
  558.           }
  559.         }
  560.       }, function() {
  561.         if(!$(this).hasClass('main-nav__item_active')) {
  562.           if ($('.main-nav').outerHeight() <= 50) {
  563.             $('.hero__wrap').animate( { height: heroHeight + "px" }, { queue:false, duration:100 });
  564.             $('.main-nav').attr('style', 'overflow: hidden !important');
  565.           } else {
  566.             $('.hero__wrap').animate( { height: heroHeight + "px" }, { queue:false, duration:100 });
  567.           }
  568.         }
  569.       }
  570.   );
  571.  
  572.   (function($) {
  573.     $('.main-nav').attr('style', 'overflow: auto !important');
  574.     if ($(".main-nav__item_subnav").hasClass('main-nav__item_active')) {
  575.       var heroHeight = $('.hero__wrap').outerHeight();
  576.       var heroSubnav = $('.main-nav__subnav').outerHeight();
  577.  
  578.       $('.hero__wrap').css('height', heroHeight + heroSubnav);
  579.       $('.main-nav').attr('style', 'overflow: initial !important');
  580.  
  581.     }
  582.   })(jQuery);
  583.  
  584.   // top nav sticky script
  585.  
  586.   $(function(){
  587.     var alertPanel = $(".alert-panel").height();
  588.     var header = $(".header").height();
  589.     var hero = $(".hero").height();
  590.     var heightSum;
  591.     if (alertPanel !== undefined) {
  592.       heightSum = alertPanel + header + hero;
  593.     } else {
  594.       heightSum = header + hero;
  595.     }
  596.     var window_width = $(window).width();
  597.     if ($('.main-nav li').width() >= window_width) {
  598.       $('.hero__nav').addClass('hero__nav_scroll');
  599.     }
  600.     $(window).scroll(function() {
  601.       var scroll = getCurrentScroll();
  602.  
  603.       if ( window_width > 768) {
  604.         if ( scroll >= heightSum - 78) {
  605.           $('.hero__nav').addClass('hero__nav_sticky');
  606.         }
  607.         else {
  608.           $('.hero__nav').removeClass('hero__nav_sticky');
  609.         }
  610.  
  611.         if ( scroll >= 1 && scroll < heightSum - (78+43) && $('.alert-panel').is(':visible')) {
  612.           $('header').css({'margin-top':alertPanel});
  613.           $('.alert-panel').addClass('hero__nav_sticky');
  614.         }
  615.         else {
  616.           $('header').css({'margin-top':0});
  617.           $('.alert-panel').removeClass('hero__nav_sticky');
  618.         }
  619.       }
  620.  
  621.  
  622.     });
  623.     function getCurrentScroll() {
  624.       return window.pageYOffset || document.documentElement.scrollTop;
  625.     }
  626.   });
  627.   $(function () {
  628.     if (window.location.hash != undefined) {
  629.       if (window.location.hash == '#registration') {
  630.         $('#registration-modal').show();
  631.         var link = window.location.href;
  632.         link = link.replace(window.location.hash, '');
  633.         history.pushState({}, '', link);
  634.       }
  635.       if (window.location.hash == '#login') {
  636.         $('#login-modal').show();
  637.         var link = window.location.href;
  638.         link = link.replace(window.location.hash, '');
  639.         history.pushState({}, '', link);
  640.       }
  641.     }
  642.   });
  643.  
  644.   $(document).on('click','[data-toggle="modal"]',function(e){
  645.     e.preventDefault();
  646.     if ($(this).data('tab') == '#cashier'){
  647.       $(window).scrollTop(0);
  648.     }
  649.  
  650.     $('.modal,.popup').hide();
  651.     var $id=$(this).attr('href');
  652.     if($id==undefined){
  653.       $id=$(this).data('target');
  654.     }
  655.  
  656.     $($id).show();
  657.  
  658.     $('html').addClass('modal_open');
  659.  
  660.     if ($(window).width() < 768) {
  661.       $('.modal_open .popup').not('.ps-container').not('.popup_tabs').perfectScrollbar({
  662.         theme: 'hidden'
  663.       });
  664.     }
  665.  
  666.     if($(this).data('tab')!=undefined){
  667.       $($(this).data('tab')).parent().find('>div').removeClass('active');
  668.       $($(this).data('tab')).addClass('active');
  669.       $('.tab__item[href="'+$(this).data('tab')+'"]').parent().find('.tab__item').removeClass('tab__item_active');
  670.       $('.tab__item[href="'+$(this).data('tab')+'"]').addClass('tab__item_active');
  671.  
  672.  
  673.  
  674.     }
  675.   });
  676.   window.getTimeRemaining = function(endtime) {
  677.     var today=(new Date()).toUTCString();
  678.     endtime = (new Date(endtime*1000)).toUTCString();
  679.     var t = Date.parse(endtime) - Date.parse(today);
  680.     var seconds = Math.floor( (t/1000) % 60 );
  681.     var minutes = Math.floor( (t/1000/60) % 60 );
  682.     var hours = Math.floor( (t/(1000*60*60)) % 24 );
  683.     var days = Math.floor( t/(1000*60*60*24) );
  684.     return {
  685.       'total': t,
  686.       'days': days,
  687.       'hours': hours,
  688.       'minutes': minutes,
  689.       'seconds': seconds
  690.     };
  691.   };
  692.  
  693.   function initializeClock(id, endtime){
  694.     var clock = document.getElementById(id);
  695.     var timeinterval = setInterval(function(){
  696.       var t = getTimeRemaining(endtime);
  697.       if(t.days<0){t.days=0}
  698.       if(t.hours<0){t.hours=0}
  699.       if(t.minutes<0){t.minutes=0}
  700.       if(t.seconds<0){t.seconds=0}
  701.  
  702.       if(t.hours<10 && t.hours>=0){t.hours='0'+t.hours}
  703.       if(t.minutes<10 && t.minutes>=0){t.minutes='0'+t.minutes}
  704.       if(t.seconds<10 && t.seconds>=0){t.seconds='0'+t.seconds}
  705.  
  706.       clock.innerHTML = ' <div class="timer__cell">' + t.days + '</div> ' +
  707.           '<div class="timer__cell timer__cell_empty"></div> ' +
  708.           '<div class="timer__cell">'+ t.hours + '</div>' +
  709.           ' <div class="timer__cell">:</div> ' +
  710.           '<div class="timer__cell">' + t.minutes + '</div> ' +
  711.           '<div class="timer__cell">:</div> ' +
  712.           '<div class="timer__cell">' + t.seconds + '</div> ';
  713.       if(t.total<=0){
  714.         clearInterval(timeinterval);
  715.       }
  716.     },1000);
  717.   }
  718.   function initializeJackpot(id, jackpot){
  719.    
  720.     var jack = document.getElementById(id);
  721.     var numbers = (jackpot+ '').split('',-4);
  722.     var $j=numbers.reverse();
  723.     var timeinterval = setInterval(function(){
  724.       $j[0]=parseInt($j[0])+randomInteger(0,5);
  725.       if($j[0]>=10){
  726.         $j[0]=parseInt($j[0])-10;
  727.         $j[1]=parseInt($j[1])+1;
  728.         if($j[1]>=10){
  729.           $j[1]=10-$j[1];
  730.           $j[2]=parseInt($j[2])+1;
  731.           if($j[2]>=10){
  732.             $j[2]=10-$j[2];
  733.             $j[3]=parseInt($j[3])+1
  734.           }
  735.         }
  736.       }
  737.       if($j[0]<0){
  738.         $j[0]=0;
  739.         $j[1]=parseInt($j[1])-1;
  740.         if($j[1]<0){
  741.           $j[1]=0;
  742.           $j[2]=parseInt($j[2])-1;
  743.           if($j[2]<0){
  744.             $j[2]=0;
  745.             $j[3]=parseInt($j[3])-1;
  746.           }
  747.         }
  748.       }
  749.       $(jack).find('.js-countdown__item:last').html($j[0]);
  750.       //console.log($(jack).find('.js-countdown__item').length);
  751.       $(jack).find('.js-countdown__item').eq(parseInt($(jack).find('.js-countdown__item').length)-2).html($j[1]);
  752.       $(jack).find('.js-countdown__item').eq(parseInt($(jack).find('.js-countdown__item').length)-3).html($j[2]);
  753.       $(jack).find('.js-countdown__item').eq(parseInt($(jack).find('.js-countdown__item').length)-4).html($j[3]);
  754.  
  755.  
  756.     },3000);
  757.   }
  758.   function randomInteger(min, max) {
  759.     var rand = min + Math.random() * (max - min)
  760.     rand = Math.round(rand);
  761.     return rand;
  762.   }
  763.   $(function () {
  764.  
  765.     function randomInteger(min, max) {
  766.       var rand = min + Math.random() * (max - min)
  767.       rand = Math.round(rand);
  768.       return rand;
  769.     }
  770.  
  771.  
  772.     $('.js-close-popup').on('click', function (e) {
  773.       e.preventDefault();
  774.       var popup = $(this).parents('.popup');
  775.       if (popup.length != 0)  {
  776.         var Class = popup.attr('class').split(' ');
  777.         var ClassName = Class[1];
  778.  
  779.       } else {
  780.         var ClassName = 'modal';
  781.       }
  782.       $("." + ClassName).hide();
  783.  
  784.       $('.modal').hide();
  785.       //$('.overflow').hide();
  786.       $('html').removeClass('modal_open');
  787.     });
  788.     $('.alert-panel__icon .icon_cross').on('click', function (e) {
  789.       e.preventDefault();
  790.       $('.alert-panel').hide();
  791.     });
  792.     $('.notify-panel__icon .icon_cross').on('click', function (e) {
  793.       e.preventDefault();
  794.       $('.notify-panel').hide();
  795.     });
  796.     $.each($('[data-toggle="timer"]'),function(){
  797.       initializeClock($(this).attr("id"), $(this).data('time'))
  798.     });
  799.  
  800.     $.each($('[data-toggle="jackpot"]'),function(){
  801.       initializeJackpot($(this).attr("id"), $(this).data('jack'))
  802.     });
  803.   });
  804.  
  805.   function showRegistrationPopup(){
  806.     $('.modal,.popup').hide();
  807.  
  808.     $('#registration-confirm').show();
  809.     $('html').addClass('modal_open');
  810.     if ($(window).width() < 768) {
  811.       $('.modal_open .popup').not('.ps-container').perfectScrollbar({
  812.         theme: 'hidden'
  813.       });
  814.     }
  815.       $('#registration-confirm #bonus').val($('#registration-modal [name="bonus"]:checked').val());
  816.       $('#registration-confirm .registration__image img').attr('src',$('#registration-modal [name="bonus"]:checked').prev('label').find('img').attr('src'));
  817.   }
  818.  
  819.   if(!$('#registration-modal [name="bonus"]').data("binding"))
  820.   $('#registration-modal [name="bonus"]').on('change',function(e){
  821.    
  822.     e.preventDefault();
  823.     showRegistrationPopup();
  824.     $('html').addClass('modal_open');
  825.   });
  826.  
  827.  
  828.   $(document).on('submit','form[data-type="ajax"]',function(e){
  829.     e.preventDefault();
  830.     var $type=$(this).attr('method');
  831.     var $action=$(this).attr('action');
  832.     var $data=$(this).serialize();
  833.     var $answer=$(this).data('answer');
  834.     var $form=$(this);
  835.     $.ajax({
  836.       type:$type,
  837.       url:$action,
  838.       data:$data,
  839.       dataType:'json',
  840.       beforeSend:function(){
  841.         $form.find('.modal__error').hide();
  842.         $form.find('.pay-tooltip__note').hide();
  843.         $form.closest('.modal,.popup').append(preloader);
  844.       },
  845.       success:function(data){
  846.         $('.loading').remove();
  847.         if(!data.success){
  848.           $('[type="password"]').val('');
  849.           if($.type(data.error)=='object'){
  850.             $form.find('.modal__error .modal__note_important,.pay-tooltip__note .error__info').html('');
  851.             $.each(data.error,function($key,$value){
  852.               $form.find('.modal__error .modal__note_important,.pay-tooltip__note .error__info').append($value + "<br/>");
  853.             });
  854.           } else {
  855.             $form.find('.modal__error .modal__note_important,.pay-tooltip__note .error__info').html(data.error);
  856.           }
  857.           $form.find('.modal__error').show();
  858.           $form.find('.pay-tooltip__note').show();
  859.         } else {
  860.           if(data.uid!=undefined && _ggcounter!=undefined){
  861.             _ggcounter.push({
  862.               event: "login",
  863.               uid: data.uid,
  864.               callback: function(){
  865.               }
  866.             });
  867.           }
  868.           if(data.form!=undefined){
  869.             $('body').append(data.form);
  870.             $('#'+data.form_id).submit();
  871.           } else {
  872.             if($answer!=undefined){
  873.               $('.modal,.popup').hide();
  874.               $($answer).show();
  875.             } else {
  876.               window.location.reload();
  877.             }
  878.  
  879.           }
  880.         }
  881.       }
  882.     });
  883.  
  884.   });
  885.  
  886.   $(document).on('submit','form.payment-form',function(e){
  887.     e.preventDefault();
  888.     var $type=$(this).attr('method');
  889.     var $action=$(this).attr('action');
  890.     var $data=$(this).serialize();
  891.     var $answer=$(this).data('answer');
  892.     var $form=$(this);
  893.     $.ajax({
  894.       type:$type,
  895.       url:$action,
  896.       data:$data,
  897.       dataType:'json',
  898.       beforeSend:function(){
  899.         $form.find('.pay-tooltip__note').hide();
  900.         $form.closest('.modal,.popup').append(preloader);
  901.       },
  902.       success:function(data){
  903.         $('.loading').remove();
  904.         if(data.result!='ok'){
  905.           if($.type(data.message)=='object'){
  906.             $form.find('.pay-tooltip__note .error__info').html('');
  907.             $.each(data.message,function($key,$value){
  908.               $form.find('.pay-tooltip__note .error__info').append($value + "<br/>");
  909.             });
  910.           } else {
  911.             $form.find('.pay-tooltip__note .error__info').html(data.message);
  912.           }
  913.           $form.find('.pay-tooltip__note').show();
  914.         } else {
  915.  
  916.           if(data.form!=undefined){
  917.             $('body').append(data.form);
  918.             $('#'+data.form_id).submit();
  919.           } else {
  920.             if ($answer != undefined) {
  921.               $('.modal,.popup').hide();
  922.               $($answer).show();
  923.             } else {
  924.               window.location.reload();
  925.             }
  926.           }
  927.         }
  928.       }
  929.     })
  930.   });
  931.   $(function () {
  932.     $(".activate-bonus").on('click', function (e) {
  933.       e.preventDefault();
  934.       if(xhr!=''){
  935.         xhr.abort();
  936.       }
  937.       var id= $(this).data('id');
  938.       xhr =$.post('/engine/ajax/activate_bonus.php', {'id': id}, function (data) {
  939.         xhr='';
  940.         if (data.status && data.is_deposit) {
  941.           $('#bonus-img').attr('src', data.image);
  942.           $('#bonus-deposit-sum').html(data.deposit);
  943.           console.log($('.min'));
  944.           $('.min').html(data.deposit);
  945.           $('.deposit-campaign-id').val(data.campaign_id);
  946.           $('#deposit-for-bonus-modal .aside__promo-table .table__body').html('');
  947.           $('#deposit-for-bonus-modal input[name=bonus_id]').val(id);
  948.           $.each(data.winners, function ($key, $item) {
  949.             var $row = "<tr class='table__row'><td class='table__cell'>" + ($key + 1) + "</td><td class='table__cell'>" + $item.login + "</td><td class='table__cell'>" + Math.round($item.win) + "</td></tr>";
  950.             $('#deposit-for-bonus-modal .aside__promo-table .table__body').append($row);
  951.           });
  952.           $('#cabinet-modal').hide();
  953.           $('#deposit-for-bonus-modal').show();
  954.           $('html').addClass('modal_open');
  955.         } else {
  956.           if(!data.status){
  957.             $('#cabinet-modal').hide();
  958.             $('#have_active_bonus .popup__content .popup__title').html(data.error);
  959.             $('#have_active_bonus').show();
  960.           } else {
  961.             window.location.reload();
  962.           }
  963.         }
  964.         $(window).scrollTop(0);
  965.       }, 'json')
  966.     });
  967.   });
  968.  
  969.   $(document).on('click','button[data-type="ajax"]',function(e){
  970.     e.preventDefault();
  971.     var $success=$(this).data('success');
  972.     var $fail=$(this).data('fail');
  973.     console.log ($(this).data('target'));
  974.     $.post($(this).data('target'),{},function(data){
  975.       if(data.success){
  976.         $($success).show();
  977.       } else {
  978.         $($fail).show();
  979.       }
  980.     },'json')
  981.   });
  982.   (function () {
  983.     $('.popup_favoritesAdded .js-close-popup').on('click', function(){
  984.       $('button[data-success =".popup_favoritesAdded"]').hide()
  985.     })
  986.   })();
  987.   $(document).on('submit','#search-form',function(e){
  988.     e.preventDefault();
  989.     $.ajax({
  990.       type:"GET",
  991.       data:{'page':$("#page").val(),'group':$("#gamegroup").val(),'type':'html','q':$("#search-form input").val()},
  992.       url:'/engine/ajax/game_list.php',
  993.       success:function(data){
  994.         if($("#search-form input").val()!=''){
  995.           history.pushState({q: $("#search-form input").val()}, '', window.location.pathname+'/?q='+$("#search-form input").val());
  996.         } else {
  997.           history.pushState({}, '', window.location.pathname);
  998.         }
  999.  
  1000.         $('.main_gallery').html(data);
  1001.       }
  1002.     })
  1003.   });
  1004.  
  1005.   $(document).on('keyup','#search-form input',function(e){
  1006.     e.preventDefault();
  1007.     if(xhr!=''){
  1008.       xhr.abort();
  1009.     }
  1010.     xhr =$.ajax({
  1011.       type:"GET",
  1012.       data:{'page':$("#page").val(),'group':$("#gamegroup").val(),'type':'html','q':$("#search-form input").val()},
  1013.       url:'/engine/ajax/game_list.php',
  1014.       success:function(data){
  1015.         xhr='';
  1016.         if($("#search-form input").val()!=''){
  1017.           history.pushState({q: $("#search-form input").val()}, '', window.location.pathname.replace(new RegExp("[/]+$", "g"), "")+'/?q='+$("#search-form input").val());
  1018.         } else {
  1019.           history.pushState({}, '', window.location.pathname);
  1020.         }
  1021.  
  1022.         $('.main_gallery').html(data);
  1023.       }
  1024.     });
  1025.   });
  1026.   (function ($) {
  1027.     $.each(['show', 'hide'], function (i, ev) {
  1028.       var el = $.fn[ev];
  1029.       $.fn[ev] = function () {
  1030.         this.trigger(ev);
  1031.         return el.apply(this, arguments);
  1032.       };
  1033.     });
  1034.   })(jQuery);
  1035.  
  1036.   $('#registration-modal').on('show', function(){
  1037.     $('[name="bonus"]').prop('checked',false);
  1038.   });
  1039.   $('#soc_registration-modal').on('show', function(){
  1040.     $('[name="bonus"]').prop('checked',false);
  1041.   });
  1042.   $('.modal,.popup').on('show', function(){
  1043.     $('.modal__error').hide();
  1044.     $('.pay-tooltip__note').hide();
  1045.     if ($('.tab-profile__form').length >= 1) {
  1046.       $('.tab-profile__form')[0].reset();
  1047.       $('.js-input__inner_tel').on('change keyup input click',function(){
  1048.         if (this.value.match(/[^0-9]/g)) {
  1049.           this.value = this.value.replace(/[^0-9]/g, '');
  1050.         }
  1051.  
  1052.       });
  1053.     }
  1054.  
  1055.   });
  1056.  
  1057.   $(document).on('click','[data-verification]',function(e){
  1058.     e.preventDefault();
  1059.     var $type=$(this).data('verification');
  1060.     if(xhr!=''){
  1061.       xhr.abort();
  1062.     }
  1063.     xhr =$.ajax({
  1064.       type:"POST",
  1065.       data:{'val':$("#profileform-"+$type).val(),'type':$type},
  1066.       url:'/engine/ajax/activate.php',
  1067.       dataType:'json',
  1068.       success:function(data){
  1069.         xhr='';
  1070.         $('.loading').remove();
  1071.         if(!data.success){
  1072.           $("#profile").find('.modal__error .modal__note_important').html(data.error);
  1073.           $("#profile").find('.modal__error').show();
  1074.         } else {
  1075.           if ($type == 'phone') {
  1076.             var timeinterval = setInterval(function() {
  1077.               var $time = getTimeRemaining(data.time);
  1078.  
  1079.               if ($time.seconds <= 0 && $time.minutes <= 0) {
  1080.                 $('.clock-timer__counter').text('0:00');
  1081.                 clearInterval(timeinterval);
  1082.               } else {
  1083.                 $('.clock-timer__counter').text($time.minutes + ':' + $time.seconds);
  1084.               }
  1085.             }, 100);
  1086.             $('.popup_phoneVerification').show();
  1087.           }
  1088.           if($type=='email'){
  1089.             $('.popup_emailVerification').show();
  1090.           }
  1091.          }
  1092.       }
  1093.     })
  1094.   });
  1095.  
  1096.   $(document).on('click','.disabled',function(e){
  1097.     e.preventDefault();
  1098.     if($(this).data('target')!=undefined){
  1099.       $('.modal,.popup').hide();
  1100.       $($(this).data('target')).show();
  1101.     }
  1102.     $(this).removeClass('disabled');
  1103.   });
  1104. });
  1105. $(function () {
  1106.   $('.vipclub__row .vipclub__item').on('click', function () {
  1107.     var infoBlock = $($(this).data('target'));
  1108.     var padding_for = infoBlock.height() + 76;
  1109.     $('.vipclub__row').not(infoBlock.parent()).css('padding-bottom', '0');
  1110.     $('.vipclub__info').not(infoBlock).removeClass('vipclub__info_open');
  1111.  
  1112.     if(infoBlock.hasClass('vipclub__info_open')) {
  1113.  
  1114.       infoBlock.removeClass('vipclub__info_open');
  1115.       infoBlock.parent().css('padding-bottom', 0);
  1116.  
  1117.     } else  {
  1118.  
  1119.       infoBlock.addClass('vipclub__info_open');
  1120.       infoBlock.parent().css('padding-bottom', padding_for);
  1121.  
  1122.       if ($(this).is(':first-child')) {
  1123.         infoBlock.find('.vipclub__arrow').removeClass('vipclub__arrow_right');
  1124.         infoBlock.find('.vipclub__arrow').addClass('vipclub__arrow_left');
  1125.       } else if ($(this).is(':nth-last-child(2)')) {
  1126.         infoBlock.find('.vipclub__arrow').removeClass('vipclub__arrow_left');
  1127.         infoBlock.find('.vipclub__arrow').addClass('vipclub__arrow_right');
  1128.       } else {
  1129.         infoBlock.find('.vipclub__arrow').removeClass('vipclub__arrow_left vipclub__arrow_right');
  1130.       }
  1131.     }
  1132.   });
  1133. });
  1134.  
  1135. $(function(){
  1136.   $('[data-toggle="tab"]').on('click tap swipe', function(e) {
  1137.     e.preventDefault();
  1138.     var $id = $(this).attr('href'),
  1139.         $viewport = $('html, body');
  1140.     if ($id == undefined) {
  1141.       $id = $(this).data('target');
  1142.     }
  1143.  
  1144.  
  1145.     if ($(this).hasClass('levels-table__item') && $(window).width() > 768) {
  1146.  
  1147.       $viewport.stop().animate({ scrollTop: $(".levels-table").offset().top}, 'slow', function(){
  1148.         $viewport.off("scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove");
  1149.       });
  1150.       $viewport.bind("scroll mousedown DOMMouseScroll mousewheel keyup", function(e){
  1151.         if ( e.which > 0 || e.type === "mousedown" || e.type === "mousewheel"){
  1152.           $viewport.stop().unbind('scroll mousedown DOMMouseScroll mousewheel keyup'); // This identifies the scroll as a user action, stops the animation, then unbinds the event straight after (optional)
  1153.         }
  1154.       });
  1155.  
  1156.     }
  1157.  
  1158.     $($id).parent().find('>div').removeClass('active');
  1159.     $($id).addClass('active');
  1160.     //hide error message from server
  1161.     $('.modal__error').hide();
  1162.  
  1163.     if($(this).data('remote')!=undefined && $(this).data('remote')!=''){
  1164.       var $content=$(this).data('content');
  1165.       $.post($(this).data('remote'),{},function(data){
  1166.         var $response=$(data).find($content);
  1167.         var $html=$response.html();
  1168.         $($id).html($html);
  1169.       });
  1170.     }
  1171.     if (!$(this).hasClass('levels-table__item')) {
  1172.       if($(this).hasClass('lottery__tabitem')){
  1173.         $(this).parent().find('.lottery__tabitem').removeClass('lottery__tabitem_active');
  1174.         $(this).addClass('lottery__tabitem_active');
  1175.       } else {
  1176.         $(this).parent().find('.tab__item').removeClass('tab__item_active');
  1177.         $(this).addClass('tab__item_active');
  1178.       }
  1179.     }
  1180.   });
  1181.   /*$('.levels-table__item[data-toggle="tab"]').on('swipe', function(e) {
  1182.    e.preventDefault();
  1183.    $(this).click();
  1184.  
  1185.    $(this).parent().find('>div').removeClass('active');
  1186.    $(this).addClass('active');
  1187.    if($(this).data('remote')!=undefined && $(this).data('remote')!=''){
  1188.    var $content=$(this).data('content');
  1189.    $.post($(this).data('remote'),{},function(data){
  1190.    var $response=$(data).find($content);
  1191.    var $html=$response.html();
  1192.    $($id).html($html);
  1193.    });
  1194.    }
  1195.    });*/
  1196. });
  1197.  
  1198.  
  1199. $(function () {
  1200.   // window.vulcanNamespace.resetStarHandlers =  function() {
  1201.   $(document).off('click','[data-toggle]');
  1202.   $(document).on('click','[data-toggle]',function(e){
  1203.     e.preventDefault();
  1204.  
  1205.     var $el = $(this);
  1206.     if ($el.attr('data-toggle') == 'add-fav') {
  1207.       $.get('/engine/ajax/add_to_favorites.php',{'id':$(this).data('id')},function(data){
  1208.         if(data.success){
  1209.           //$('.popup_favoritesAdded').css('position', 'fixed').show();
  1210.           //$('.overflow').show();
  1211.           $el.addClass('in_favorites');
  1212.           $el.attr('data-toggle','remove-fav');
  1213.           $el.attr('title','Удалить из избранного');
  1214.         } else {
  1215.           $('.popup_favoritesAddedFail').css('position', 'fixed').show();
  1216.           $('html').addClass('modal_open');
  1217.           $el.removeClass('in_favorites');
  1218.         }
  1219.       },'json')
  1220.     } else if ($el.attr('data-toggle') == 'remove-fav') {
  1221.       $.get('/engine/ajax/remove_favorites.php',{'id':$el.data('id')},function(data){
  1222.         $el.removeClass('in_favorites');
  1223.         $el.attr('data-toggle','add-fav');
  1224.         $el.attr('title','Добавить в избранное');
  1225.       },'json')
  1226.     }
  1227.   });
  1228.  
  1229.  
  1230.   // };
  1231.   //window.vulcanNamespace.resetStarHandlers();
  1232. });
  1233. function user_ajax(form,action){
  1234.  
  1235.   data=$(form).serialize();
  1236.   $(form).closest('.modal,.popup').append(preloader);
  1237.   error_box= $(form).find('.modal__error .modal__note_important').empty();
  1238.   $.post('/engine/ajax/user.php',data+'&action='+action,function(res){
  1239.     $('.loading').remove();
  1240.     if(res.success==true)
  1241.     {
  1242.       if(res.txt){
  1243.         $(form).find('.modal__error .modal__note_important').html('');
  1244.         //$(form).find('.modal__error .modal__note_accent').html(res.txt);
  1245.         $(form).find('.modal__error').show();
  1246.       }
  1247.       //setTimeout (function(){ window.location.reload()}, 3000);
  1248.       window.location.reload();
  1249.     }
  1250.     else
  1251.     {
  1252.       if(res.error){
  1253.         error_box.html(res.error);
  1254.         $(form).find('.modal__error').show();
  1255.       }
  1256.     }
  1257.   },'json');
  1258.   return false;
  1259. }
  1260. function decimalAdjust(type, value, exp) {
  1261.   // Если степень не определена, либо равна нулю...
  1262.   if (typeof exp === 'undefined' || +exp === 0) {
  1263.     return Math[type](value);
  1264.   }
  1265.   value = +value;
  1266.   exp = +exp;
  1267.   // Если значение не является числом, либо степень не является целым числом...
  1268.   if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) {
  1269.     return NaN;
  1270.   }
  1271.   // Сдвиг разрядов
  1272.   value = value.toString().split('e');
  1273.   value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp)));
  1274.   // Обратный сдвиг
  1275.   value = value.toString().split('e');
  1276.   return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp));
  1277. }
  1278.  
  1279. // Десятичное округление к ближайшему
  1280. if (!Math.round10) {
  1281.   Math.round10 = function(value, exp) {
  1282.     return decimalAdjust('round', value, exp);
  1283.   };
  1284. }
  1285. $(document).on('change keyup input click','#exchange-input',function(){
  1286.   if (this.value.match(/[^0-9]/g)) {
  1287.     this.value = this.value.replace(/[^0-9]/g, '');
  1288.   }
  1289.   var $value=$(this).val()*$(this).data('cours');
  1290.   $('#exchange-output').val(Math.round10($value,-2));
  1291.   $('#exchange-input').val($(this).val()*1);
  1292.  
  1293. });
  1294. $(document).on('change keyup input click','#exchange-output',function(){
  1295.  
  1296.     this.value = this.value.replace(/[^\d\.]/g, '');
  1297.  
  1298.   var $value=$(this).val()/$(this).data('cours');
  1299.   $('#exchange-input').val(Math.round10($value,-2));
  1300.   $('#exchange-output').val($(this).val()*1);
  1301. });
  1302.  
  1303. // script fro scroll to top button
  1304.  
  1305. $(document).ready(function(){
  1306.   var calculateSize = function($el) {
  1307.  
  1308.     var width = $el.width();
  1309.     var height = $el.height();
  1310.     var maxWidth = $el.parent().parent().width();
  1311.     var maxHeight = $el.parent().parent().height();
  1312.     var proportions = 3 / 4;
  1313.  
  1314.     if (maxHeight / maxWidth < proportions) {
  1315.       height = Math.floor(maxHeight);
  1316.       width = Math.floor(height / proportions);
  1317.     } else {
  1318.       width = Math.floor(maxWidth);
  1319.       height = Math.floor(width * proportions);
  1320.     }
  1321.  
  1322.     $el.css({
  1323.       width: width + 'px',
  1324.       height: height + 'px',
  1325.       display: 'block'
  1326.     })
  1327.     return {
  1328.       width: width,
  1329.       height: height
  1330.     };
  1331.   }
  1332.   setTimeout(function(){
  1333.     calculateSize($('.gameplay__canvas_inner object'));
  1334.   }, 100);
  1335.  
  1336.   // validation
  1337.   $('form button.validate').click(function(e){
  1338.     e.preventDefault();
  1339.     var $form = $(this).closest('form');
  1340.     // $form.find('.modal__note_important');
  1341.     var hasErrors = false;
  1342.     $form.find('.modal__error').hide();
  1343.     $form.find('.modal__note_important').html('');
  1344.     $(this).closest('form').find('[required][type="checkbox"]').each(function(index, el) {
  1345.       if (!$(el)[0].checked) {
  1346.         hasErrors = true;
  1347.         $form.find('.modal__error').show();
  1348.         $form.find('.modal__note_important').append($(el).attr('data-error-message'));
  1349.       }
  1350.     });
  1351.     if (!hasErrors) {
  1352.       $form.submit();
  1353.     }
  1354.   });
  1355.  
  1356.   $(window).resize(function() {
  1357.     calculateSize($('.gameplay__canvas_inner object'));
  1358.   });
  1359.   $(window).scroll(function () {
  1360.     if ($(this).scrollTop() > 0) {
  1361.       $('.scroller').fadeIn();
  1362.     }
  1363.     else {
  1364.       $('.scroller').fadeOut();
  1365.     }
  1366.   });
  1367.   $('.popup_tournamentGames').scroll(function () {
  1368.     if ($(this).scrollTop() > 0) {
  1369.       $('.scroller').fadeIn();
  1370.     }
  1371.     else {
  1372.       $('.scroller').fadeOut();
  1373.     }
  1374.   });
  1375.   $('.scroller').click(function () {
  1376.     $('body,html').animate({
  1377.       scrollTop: 0
  1378.     }, 400);
  1379.     if ($('.popup_tournamentGames').css('display') == 'block') {
  1380.       $('.popup_tournamentGames').animate({
  1381.         scrollTop: 0
  1382.       }, 400);
  1383.     }
  1384.     return false;
  1385.   });
  1386.  
  1387.  
  1388. });
  1389. function searchGame(text){
  1390.   if(text==''){
  1391.     $('.popup__gallery .main__item.preview').show();
  1392.     return true;
  1393.   }
  1394.   var search=text.toLowerCase();
  1395.   $.each($('.popup__gallery .main__item.preview'),function(){
  1396.     var $title=$(this).find('.preview__title').html().toLowerCase();
  1397.     $('.popup__gallery').perfectScrollbar('update');
  1398.     if($title.indexOf(search)<0){
  1399.       $(this).hide();
  1400.     } else {
  1401.       $(this).show();
  1402.     }
  1403.   })
  1404. }
  1405.  
  1406. // Script for xs header
  1407.  
  1408. $(function(){
  1409.   $('.js-userpanel-button').on('click', function(){
  1410.     $(this).toggleClass('user-toppanel__button_close');
  1411.     $(this).toggleClass('js-userpanel-button-close');
  1412.     $('.header__panel').toggleClass('open');
  1413.     $('.header').toggleClass('header_panel-open');
  1414.     $('.header__wrap').toggleClass('header__wrap_scroll');
  1415.     $('.header__wrap_scroll').not('.ps-container').perfectScrollbar({
  1416.       theme: 'hidden',
  1417.       suppressScrollY: true,
  1418.       scrollXMarginOffset: 5
  1419.       // maxScrollbarLength: 213
  1420.     });
  1421.     $('.header__toppanel').toggleClass('open');
  1422.     $('body, html').toggleClass('hidden');
  1423.   });
  1424. });
  1425.  
  1426. $(function(){
  1427.   $('.js-toppanel-button').on('click', function(){
  1428.     $(this).toggleClass('toppanel__button_close');
  1429.     $(this).toggleClass('js-toppanel-button-close');
  1430.     $('.js-mobilenav-dropdown').toggleClass('open');
  1431.     $('.header__toppanel').toggleClass('open');
  1432.     $('body, html').toggleClass('hidden');
  1433.   });
  1434. });
  1435.  
  1436.  
  1437. // Promo details script for xSmall screen
  1438.  
  1439. $(function(){
  1440.   $('.js-promo-details-button').on('click', function(){
  1441.     $('.promo-details__dropdown').slideToggle('fast').toggleClass('active');
  1442.   });
  1443. });
  1444. //$(function() {
  1445.   //if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) {
  1446.     //$('html').addClass('Sa');
  1447.   //}
  1448. //});
  1449.  
  1450. // Popup_gameplayGallery Close button positioning on mobile devices
  1451.  
  1452. //$(function() {
  1453. // $('.popup_gameplayGallery')
  1454. //     .find('.popup__close')
  1455. //     .css('top', $('.popup_gameplayGallery').find('.popup__content').height() + 80);
  1456. //});
  1457.  
  1458. $(function(){
  1459.   if($('.finecountdown').length>0)
  1460.     {
  1461.     $('.finecountdown').each(function(){
  1462.   var suma=$(this).data('sum').toString();
  1463.   var i=k=0;
  1464.  
  1465.   $(this).empty();
  1466.   for(i=suma.length-1; i>=0; --i)
  1467.     {
  1468.     if($(this).hasClass('countdown')==true)
  1469.       {
  1470.       $(this).prepend('<span class="countdown__item js-countdown__item">'+suma[i]+'</span>');
  1471.       if(++k%3==0 && k>0 && k<=suma.length-1)
  1472.         $(this).prepend('<span class="countdown__divider"></span>');
  1473.       }
  1474.     else
  1475.       {
  1476.       $(this).prepend('<span class="js-countdown__item">'+suma[i]+'</span>');
  1477.       if(++k%3==0 && k>0 && k<=suma.length-1)
  1478.         $(this).prepend(' , ');
  1479.       }
  1480.    
  1481.    
  1482.     }
  1483.   });
  1484.   }
  1485. });
  1486.  
  1487. function get_cookie ( cookie_name )
  1488. {
  1489.   var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
  1490.  
  1491.   if ( results )
  1492.     return ( unescape ( results[2] ) );
  1493.   else
  1494.     return null;
  1495. }
  1496.  
  1497. function delete_cookie ( cookie_name )
  1498. {
  1499.   var cookie_date = new Date ( );  // Текущая дата и время
  1500.   cookie_date.setTime ( cookie_date.getTime() - 1 );
  1501.   document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
  1502. }
  1503.  
  1504. function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
  1505. {
  1506.   var cookie_string = name + "=" + escape ( value );
  1507.  
  1508.   if ( exp_y )
  1509.   {
  1510.     var expires = new Date ( exp_y, exp_m, exp_d );
  1511.     cookie_string += "; expires=" + expires.toGMTString();
  1512.   }
  1513.  
  1514.   if ( path )
  1515.         cookie_string += "; path=" + escape ( path );
  1516.  
  1517.   if ( domain )
  1518.         cookie_string += "; domain=" + escape ( domain );
  1519.  
  1520.   if ( secure )
  1521.         cookie_string += "; secure";
  1522.  
  1523.   document.cookie = cookie_string;
  1524. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement