function isMobile() { if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { return true; } return false; } /* БЛОК ОЧИСТКИ ЭКРАНА if (window.devtools.isOpen) $('html').html(''); window.addEventListener('devtoolschange', event => { if (event.detail.isOpen && !isMobile()) $('html').html(''); }); /* КОНЕЦ БЛОКА ЗАЩИТЫ*/ function resize() { //$('.slider').css({'min-height':$(window).height()-$('.top-line').height()-$('.top-menu').height()-0+'px'}); } $(window).resize(function() { resize(); w = $(window).width(); h = $(window).height(); if (w / h > 1.2) { $('.pre-slide>#move-slide>.slider').each(function(i,el) { $(el).css('background-image','url('+$(el).data('image169')+')'); }); } else { if (w/h < 0.9) { $('.pre-slide>#move-slide>.slider').each(function(i,el) { $(el).css('background-image','url('+$(el).data('image916')+')'); }); } else { $('.pre-slide>#move-slide>.slider').each(function(i,el) { $(el).css('background-image','url('+$(el).data('image11')+')'); }); } } }); $(document).ready(function(e) { resize(); //document.oncontextmenu = function() {return false;}; $(document).mousedown(function(e){ if( e.button == 2 ) return false; return true; }); $('body').on('load', resize); $('.pre-slide>#move-slide>.slider').on('click', function(e) { link = $(this).data('link'); window.location.href = link; }); var configChosen = { '.chosen-select': {} } for (var selector in configChosen) { $(selector).chosen(configChosen[selector]); } if (getCookie('alert') !="") { arr = getCookie('alert').split('<@>'); setCookie('alert', "", { 'max-age': -1 }); myAlert(arr[0],arr[1],arr[2]); } $('li[data-href]').on('click', function(e) { if ($(this).data('href')!="") window.location.href = $(this).data('href'); }) $('a[href*="#"]').click(function() { var t = parseInt($(this).data('top')); if (!$(this).hasAttribute('data-fancybox')) { if (t > 0) t = $($.attr(this, 'href')).offset().top - t; else t = $($.attr(this, 'href')).offset().top; $('html, body').animate({ scrollTop: t }, 400); return false; } }); $('#reg .type li').on('click touchstart', function(e) { $('#reg .type li.active').removeClass('active'); $(this).addClass('active'); $('#reg .form li.active').removeClass('active'); $('#reg .form li:nth-child('+$(this).data('form')+')').addClass('active'); }); $('#reg .chek span').on('click', function(e) { $('#reg .chek div').slideToggle(); $(this).hide(); }); $('#reg .form input').on('input', function (e) { $(this).removeClass('red');}) $('.forgot').on('click touchstart', function(e) { $('#enterform').slideToggle(); $('#forgotform').slideToggle(); }); $('#do_reg').on('click',function(e) { //Проверим есть ли имя pass = $('#reg_pass').val(); mail = $('#reg_mail').val(); fio = $('#reg_fio').val(); phone = $('#reg_phone').val(); $(this).html(''); $.post('/design/shapochka/pages/auth/form.php',{type:'reg',mail:mail,pass:pass,fio:fio,phone:phone}, function(data) { arr = data.split('<@>'); if (arr[0] == 200) { $('.fancybox-close-small').click(); myAlert(arr[1],arr[2],arr[3]); } else { arr.forEach(function(e) { $(e).addClass('red'); if (e=="#reg_pass") myAlert("Ошибка","Пароль должен содержать не менее 5 символов","Понятно"); if (e=="#reg_mail") myAlert("Ошибка","Возможно вы допустили ошибку при вводе email адреса","Понятно"); if (e=="#reg_fio") myAlert("Ошибка","Укажите фамилию и имя","Понятно"); if (e=="#reg_phone") myAlert("Ошибка","Укажите номер телефона","Понятно"); }); $('#do_reg').html('Регистрация'); return false; } }); }); $('#do_enter').on('click',function(e) { mail = $('#enter_mail').val(); pass = $('#enter_pass').val(); $(this).html(''); $.post('/design/shapochka/pages/auth/form.php',{type:'enter',mail:mail,pass:pass}, function(data) { arr = data.split('<@>'); if (arr[0] == 200) {// в данном случае 200 = ошибка myAlert(arr[1],arr[2],arr[3]); $('#do_enter').html('Войти'); return false; } else window.location.reload(); }); }); $('#do_forgot').on('click touchstart',function(e) { mail = $('#forgot_mail').val(); $(this).html(''); $('#enter_mail').val(mail); $('#enter_pass').val(''); $.post('/design/shapochka/pages/auth/form.php',{type:'forgot',mail:mail}, function(data) { arr = data.split('<@>'); if (arr[0] == 200) { $('#forgotform .forgot').click(); $('#enter_mail').val(); myAlert(arr[1],arr[2],arr[3]); } else { myAlert(arr[1],arr[2],arr[3]); } $('#do_forgot').html('Получить пароль'); }); }); $('.lkbox>.mm>.name').on('click', function(e) { if ($(window).width() < 651) { $('.lkbox>.mm>ul').slideToggle(); } }); setTimeout(function(e) { $('.lkbox>.mm>.name').click(); }, 1500); }); $(window).scroll(function(e) { topPx = self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop); if (topPx > 102) { $('.top-menu').addClass('fix'); } else { $('.top-menu').removeClass('fix'); } if (topPx > 150) $('.toTop').css({'bottom':'0px'}); else $('.toTop').css({'bottom':'-150px'}); }); $(document).ready(function(e) { //$(".left-panel").niceScroll({cursorcolor:"rgba(0,0,0,.2)"}); //$("html").niceScroll({cursorcolor:"rgba(0,0,0,.2)"}); $('div:not(.forvideo) iframe').css({'width':'100%'}); $('a[href*="#"]').click(function() { t = parseInt($(this).data('top')); if (t > 0) t = $($.attr(this, 'href')).offset().top - t; else t = $($.attr(this, 'href')).offset().top; $('html, body').animate({ scrollTop: t }, 400); return false; }); $('.toTop').click(function() { $('html, body').animate({ scrollTop: 0 }, 400); return false; }); $('.playvideo').on('click', function(e) { $.post('/getVideo.php',{id:$(this).data('id')}, function(data) { window.location.hash = randString(); $('.forvideo').html(data); }); }); $('body').on('click','.closevideo', function(e) { $('.forvideo').html(''); window.location.hash = randString(); }); $('body').on('mouseleave','.forvideo', function(e) { $('.forvideo').html(''); window.location.hash = randString(); }); $('.cookie div').on('click', function(e) { $('.cookie').fadeOut(); setCookie('yes',true); }); }); function randString(n) { if(!n) { n = 26; } var text = ''; var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; for(var i=0; i < n; i++) { text += possible.charAt(Math.floor(Math.random() * possible.length)); } return text; } function getCookie(name) { var matches = document.cookie.match(new RegExp( "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" )); return matches ? decodeURIComponent(matches[1]) : false; } function setCookie(name, data) { var date = new Date(new Date().getTime() + 1000*60*60*24); document.cookie = name + "=" + data + "; path=/; domain=."+location.hostname+"; expires=" + date.toUTCString(); } function dedupe(arr) { var res = []; for (i = 0; i < arr.length; i++) { z = arr[i] * 1; if (res.indexOf(z) == -1) res.push(z); } return res; } function dedupe_remove(arr,el) { var res = []; for (i = 0; i < arr.length; i++) { z = arr[i] * 1; if (res.indexOf(z) == -1 && z != el*1 ) res.push(z); } return res; } function qf_price(number, symbol = true, dec = false) { // Format a number with grouped thousands var i, j, kw, kd, km; // input sanitation & defaults decimals = 0; if (dec) decimals = 2; dec_point = "."; thousands_sep = " "; i = parseInt(number = (+number || 0).toFixed(decimals)) + ""; if( (j = i.length) > 3 ){ j = j % 3; } else{ j = 0; } km = (j ? i.substr(0, j) + thousands_sep : ""); kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep); //kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).slice(2) : ""); kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, 0).slice(2) : ""); if (symbol) return km + kw + kd + ' '; else return km + kw + kd; } function validate(str, type='pass') { var check; if (type == 'pass') check = /(?=.*[0-9])(?=.*[a-zР°-СЏ])(.){6,}/gi; if (type == 'phone') check = /\+7 \([0-9]{3}\) [0-9]{3}(-[0-9]{2}){2}/gi; return str.match(check); } function myAlert(t,c,b) { $.alert({ title: t, content: c, theme: 'supervan', buttons: { somethingElse: { text: b, btnClass: 'btn-green', keys: ['enter'] } } }); }