if (!String.prototype.includes) { String.prototype.includes = function() { 'use strict'; return String.prototype.indexOf.apply(this, arguments) !== -1; }; } function shoneNummer(str){ res=String(str).replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1 '); return (res+"").indexOf('.00')!=-1?Math.round(res):res; } function ShowWait(){ $('#content').addClass('hide'); $('#wait').removeClass('hide'); } function HideWait(){ $('#wait').addClass('hide'); $('#content').removeClass('hide'); } function CSSLoad(file){ var link = document.createElement("link"); link.setAttribute("rel", "stylesheet"); link.setAttribute("type", "text/css"); link.setAttribute("href", file); document.getElementsByTagName("head")[0].appendChild(link) } function decodeArr(){ tmp=''; brandRus=[]; for (j=0; j'; } $('#brand_F').html(tmp); metkiRus=[]; tmp=""; for (j=0; j'; } $('#Metki_F').html(tmp); ColorsHash=[]; tmp=""; for (j=0; j'; } $('#Colors_F').html(tmp); tmp=''; for (j=0; j'; } $('#size_F').html(tmp); tmp=''; sostavRus=[]; for (j=0; j'; } $('#sostav_F').html(tmp); tmp=''; citisRus=[]; for (j=0; j'; } $('#citis_F').html(tmp); } function rus_to_latin ( str ) { var ru = { 'а': 'a', 'б': 'b', 'в': 'v', 'г': 'g', 'д': 'd', 'е': 'e', 'ё': 'e', 'ж': 'j', 'з': 'z', 'и': 'i', 'к': 'k', 'л': 'l', 'м': 'm', 'н': 'n', 'о': 'o', 'п': 'p', 'р': 'r', 'с': 's', 'т': 't', 'у': 'u', 'ф': 'f', 'х': 'h', 'ц': 'c', 'ч': 'ch', 'ш': 'sh', 'щ': 'shch', 'ы': 'y', 'э': 'e', 'ю': 'u', 'я': 'ya' }, n_str = []; str = str.replace(/[ъь]+/g, '').replace(/й/g, 'i'); for ( var i = 0; i < str.length; ++i ) { n_str.push( ru[ str[i] ] || ru[ str[i].toLowerCase() ] == undefined && str[i] || ru[ str[i].toLowerCase() ].replace(/^(.)/, function ( match ) { return match.toUpperCase() }) ); } return n_str.join(''); } function getCookie(name) { var matches = document.cookie.match(new RegExp( "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" )); return matches ? decodeURIComponent(matches[1]) : undefined; } function setCookie(name, value, options) { options = options || {}; var expires = options.expires; if (typeof expires == "number" && expires) { var d = new Date(); d.setTime(d.getTime() + expires * 1000); expires = options.expires = d; } if (expires && expires.toUTCString) { options.expires = expires.toUTCString(); } value = encodeURIComponent(value); var updatedCookie = name + "=" + value; for (var propName in options) { updatedCookie += "; " + propName; var propValue = options[propName]; if (propValue !== true) { updatedCookie += "=" + propValue; } } document.cookie = updatedCookie; } function MeinScroll(id) { $("html,body").animate({scrollTop: $(id).offset().top - 50}, 700); } function adW(was,name,val){ if (val==""){return was;} return was+(was==""?"":"&")+name+"="+btoa(encodeURI(val)); } var postCNT=0; function Post(param, urls,funct) {// + "&b=" + var xmlhttp = new XMLHttpRequest(); xmlhttp.withCredentials = true; xmlhttp.open('POST', urls, true); xmlhttp.timeout =30000; xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlhttp.send(param); postCNT=postCNT+1; /*setTimeout(func tion () { if (xmlhttp.readyState != 4) {ShowWait();} }, 400);*/ xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4) { postCNT=postCNT-1;// Ответ пришёл if (xmlhttp.status == 200) { // Сервер вернул код 200 (что хорошо) if (funct!=null) {funct(xmlhttp.responseText);} } else if (urls.indexOf("/BUY/cnt.php")==-1) {alert('Ошибка при ответе от сервера ('+xmlhttp.status+').'); location.reload();} } }; } function sleep(ms) { ms += new Date().getTime(); while (new Date() < ms){} } var mob=false; function FixResize(){ //$('.fix').css("height",$( window ).height()+"px"); if ($('#saheDetail').is(":visible")){ $('#content').css("min-height",$('#saheDetail').height()+"px"); } else if ($('#filters').is(":visible")){ $('#content').css("min-height",($('#filters').height()>screen.height?$('#filters').height():screen.height)+"px"); } else $('#content').css("min-height",($('#SachenList_List').height()>screen.height?$('#SachenList_List').height():screen.height)+"px"); if (!mob && $('.burger').is(":visible")){ mob=true; $('.reg,.cart.btn').detach().prependTo('#mobileBasket'); $('#headerDop').detach().prependTo('#MenuUp > div'); $('.insta,.VK').detach().prependTo('#MenuUp > div > div:nth-last-child(-n+2):eq(0)'); $('hr.MenuUp').detach().prependTo('#MenuUp > div > div:nth-last-child(-n+2):eq(0)'); } else if (mob && !$('.burger').is(":visible")){ mob=false; $('.reg,.cart.btn').detach().insertBefore('#dopInfa'); $('#headerDop').detach().insertAfter('#Title a.btn'); $('.insta,.VK').detach().prependTo('#headerDop'); $('hr.MenuUp').detach().insertAfter('#upSpace'); } } //var historyArr=[]; function setHis(url){ if (backCLK>0){return;} if (url=="/?"){return;} if ((location.pathname+location.search)!=url){ window.history.pushState(null, null, url); //historyArr,push(url); } else console.log(url); } function EmptySachenList(){ return "Ничего не найдено... Попробуйте изменить фильтры"; } function showAllert(msg){// todo сделать вывод сообщения красивым alert(msg); } function addToBasket_RES(res){ if (res=="ok"){ $('#priceCell').css("background-color","aquamarine"); if ($('.colorItem').length>1){ $('.colorItem[select=1]').attr("select",'0'); } if ($('.optionItem').length>1){ $('.optionItem[select=1]').attr("select",'0'); } $('#countToBuy').val("1"); showHideDopPrice(); $('#addToBasket').html('Перейти в корзину'); $('#addToBasket').attr('id','goToBasket'); } else $('#priceCell').css("background-color","red"); setTimeout(function () { $('#priceCell').css("background-color","#fff"); }, 200); return true; } function addToBasket(){ if ($('#addToBasket').length==0){ basket(); return; } ColorID=''; OptionID=''; // проверяем на то, что все параметры указали if ($('.colorItem').length>0){ if ($('.colorItem[select=1]').length<=0){ showAllert("Вы еще не выбрали цвет"); return false; } ColorID=$('.colorItem[select=1]').attr("ouid"); } if ($('.optionItem').length>0){ if ($('.optionItem[select=1]').length<=0){ showAllert("Вы еще не выбрали размер"); return false; } OptionID=$('.optionItem[select=1]').attr("ouid"); } cnt=$('#countToBuy').val(); was=adW("","OptionID",OptionID); was=adW(was,"ColorID",ColorID); was=adW(was,"cnt",cnt); Post(was,"/BUY/addToCard.php",addToBasket_RES); yndx('basket'); } function minusPlusToBuy(plus){ minCNT=$('#countToBuy').attr("min"); maxCNT=$('#countToBuy').attr("max"); tekCNT=$('#countToBuy').val(); if (plus){ if (tekCNT*1+1<=maxCNT) { $('#countToBuy').val(tekCNT*1+1); } } else { if (tekCNT*1-1>=minCNT) { $('#countToBuy').val(tekCNT*1-1); } } } function decodeHtml(str){ if (str==null) return ""; var map = { '&': '&', '<': '<', '
': '\n', '>': '>', '"': '"', 'quot;':'"', ''': "'" }; return str.replace(/&|<|
|>|"|quot;|'/g, function(m) {return map[m];}); } function clearFilters(){ $('.checkBox[plus="1"]').attr("plus","0"); $('#filters input').val(""); showSachenList(null); } function showHideDopPrice(){ tekCNT=$('#countToBuy').val()*1; if (tekCNT<=1){ $('.itogSM').css("display","none"); return; } tek=$('#priceBLK').attr("tek")*1; $('#priceCell .itogSM > div').html(shoneNummer(tek*tekCNT)+" руб."); $('.itogSM').show(); if ($('#addToBasket').length==0){ $('#goToBasket').html('добавить в корзину'); $('#goToBasket').attr('id','addToBasket'); } } function changeFoto(el,colr_clk){ if ($(el).length==0){return;} von=$(el).attr("von"); $('#tekIMG').attr("src","/Kolgotki/Fotos/bereits/"+von); $('#tekIMG').attr("von",von); $('#tekIMG').css("background-image",'url("/Kolgotki/Fotos/Preview/'+von+'")'); if (!colr_clk){return;} colorID=$(el).attr("colorid")*1; if (colorID>0){ selectIT($('.colorItem[ouid='+colorID+'][select=0]')); } } function color_imgClk(el){ ouid=$(el).attr("ouid")*1; if (ouid>0){ changeFoto($('.imgdop[colorid='+ouid+']:eq(0)'),false); } } function GetStart(cnt){ res=''; for (j7=0; j7<5; j7++){ res+=''; } return res; } lstReview=[]; function showReviews(res){ console.log(res);//////////////////////////////////////////////////////////////////////////// reviews=''; if (res.data.length>0){ for (iR=0; iR" +"
" +"
"+tekR.Name+"
" +"
"+tekR.CD+"
" +"
"+GetStart(tekR.points)+"
" +(tekR.colors!=null?"
"+tekR.colors+"
":'') +(tekR.sizes!=null?"
"+tekR.sizes+"
":'') +"
" +""; } } $('#rewiewsBLK').html(reviews); $('#otsivBLK').removeClass("hide"); } function getReviews(res){ if (res.length<=10){ // нет отзывов или плохой ответ return; } if (!$('#saheDetail').is(':visible')){return;} // значит уже вышли из товара res=JSON.parse(res); SacheID=$('#addToBasket').attr("sacheID"); if (SacheID==null){ SacheID=$('#goToBasket').attr("sacheID"); } lstReview["id"+res.id]=res; if (res.id*1!=SacheID*1){ return; } showReviews(res); } function loadReviews(SacheID){ $('#otsivBLK').addClass("hide"); if (lstReview["id"+SacheID]!=null){ showReviews(lstReview["id"+SacheID]); return; } Post("was=loadReviews&id="+SacheID,"/BUY/Reviews.php",getReviews); } function SacheDetail(tek){ if ($('#saheDetail').length==0){location.reload();} if (tek==null){return;} lastScrollContent=document.documentElement.scrollTop; if ($('#addToBasket').length==0){ $('#goToBasket').html('добавить в корзину'); $('#goToBasket').attr('id','addToBasket'); } $('#addToBasket').attr("sacheID",tek.id); res=''; if (tek.IMG!=null && tek.IMG.length>0){ res='
'; if (tek.IMG.length>1){ res=res+'
'; tmp=''; for (i=0; i
'; } res=res+tmp+''; } } else res='
'; $('#ImageList').html(res); /*console.time(); var img = new Image(); img.loaded = false; img.onload = function(){ this.loaded = true; $('#tekIMG').css("background-image",'url(\'/Kolgotki/Fotos/bereits/'+tek.IMG[0].lnk+'\');"'); console.timeEnd(); }; img.src = '/Kolgotki/Fotos/bereits/'+tek.IMG[0].lnk; */ res=''; if (tek.colors!=null && tek.colors.length>0){ for (jjj=0; jjj'+ '
'+decodeHtml(Res777.colors[i].name)+'
'+ (Res777.colors[i].comment!=null?('
'+decodeHtml(Res777.colors[i].comment)+'
'):'')+ ''; } } $('label[for="colorBLK"]').css("display",(tek.colors!=null && tek.colors.length>0?"block":"none")); $('#colorBLK').html(res); res=''; if (tek.metki!=null && tek.metki.length>0){ for (jjj=0; jjj'+decodeHtml(Res777.metki[i].name)+''; } } $('#metkiLST').html(res); minPrice=-1; res=''; if (tek.OptionsList !=null && tek.OptionsList.length>0){ for (jjj=0; jjj'+ tek.OptionsList[jjj].size+''; if (minPrice>tek.OptionsList[jjj].price || minPrice==-1){ $('#priceBLK').attr("tek",tek.OptionsList[jjj].price); $('#priceBLK').html(tek.OptionsList[jjj].price+' руб.'); if (tek.OptionsList[jjj].oldprice!=null && tek.OptionsList[jjj].oldprice>tek.OptionsList[jjj].price){ $('#oldPriceBLC').html(ColorOldPrice(tek.OptionsList[jjj].price,tek.OptionsList[jjj].oldprice)); } else $('#oldPriceBLC').html(""); minPrice=tek.OptionsList[jjj].price; } } } $('label[for="optionsBLK"]').css("display",(tek.OptionsList !=null && tek.OptionsList.length>0?"block":"none")); $('#optionsBLK').html(res); res=''; if (tek.sostavList!=null && tek.sostavList.length>0){ for (jjj=0; jjj'+Res777.sostav[i].name+' '+tek.sostavList[jjj].val+'%'; } } $('#sostavBLK').html((res!=''?'':'')+res); res=tek.opis!=null?('
'+decodeHtml(tek.opis)+'
'):''; $('#opisBLK').html((res!=''?'':'')+res); dop=""; if (tek.CompanyID!=null){ for (i=0; iСтрана:
'+Res777.citis[j].name+'
'); break; } break; } } $('#sacheNameELEM').html(decodeHtml(dop+tek.Name+(tek.DEN!=null?' '+tek.DEN:''))); tek.cntCLK=(tek.cntCLK==null?0:tek.cntCLK)+1; tek.cntCLK_24=(tek.cntCLK_24==null?0:tek.cntCLK_24)+1; $('#lookingCNT').html(tek.cntCLK==null?"":("Просмотров "+tek.cntCLK+(tek.cntCLK_24==null?"":", за сегодня "+tek.cntCLK_24))); $('#btnEdit').attr("value",tek.id); $('#countToBuy').val("1"); $('#btnMobile,#filters,#sortBLK,#content >hr,#SachenList').addClass('hide'); $('#saheDetail').removeClass('hide'); document.title=decodeHtml(dop+tek.Name+(tek.DEN!=null?' '+tek.DEN:''))+(minPrice>0?' за '+minPrice+' руб.':''); FixResize(); $('#priceCell').css('display',(minPrice==-1?'none':'table')); showHideDopPrice(); if (!mob){ $("#tekIMG").imagezoomsl({ innerzoommagnifier: true, classmagnifier: window.external ? window.navigator.vendor === "Yandex" ? "" : "round-loupe" : "", magnifierborder: "5px solid #F0F0F0", zoomrange: [2, 8], zoomstart: 2, magnifiersize: [250, 250] }); } $("html,body").scrollTop(0); $('#raiting').html(GetStart(tek.raiting)); stat("sache",tek.id); yndx('sache'); loadReviews(tek.id); patch=getPatch(); HideWait(); setHis((patch==""? ("/?id="+tek.id): (patch+'/'+tek.company_eng+'-'+tek.ENG+(tek.DEN!=null?tek.DEN:'')))); } function getPatch(){ patch=""; if (window.location.pathname.indexOf('/g/')==-1){return patch;} spltArr=window.location.pathname.split("/"); if (spltArr.length>=4){ patch=spltArr.slice(0,4).join('/'); } return patch; } function clkMenu(el){ $('#MenuUp .selected').removeClass("selected"); $('.checkBox[plus="1"]').attr("plus","0"); $('#filters input').val(""); $('#SearchSachen').val(""); document.title=$(el).text(); if ($(el).attr("glb")==null){ glblID=($(el).parent().parent().find('> a ').attr('ouid'))*1; razdT=(glblID==$(el).attr('ouid')?-1:$(el).attr('ouid'))*1; $(el).addClass("selected"); $(el).parent().addClass("selected"); $(el).parent().parent().find('> a ').addClass("selected"); stat("menu",$(el).attr("href")); setHis($(el).attr("href")); } else { glblID=-1; razdT=-1; $(el).addClass("selected"); id=$(el).parent().attr("id"); if (id=="news"){ $('#sortBLK div[class*="selected"]').removeClass("selected"); $('#sortBLK div[was="TS"]').addClass("selected"); sortWas="TS"; } else { $('#sortBLK div[class*="selected"]').removeClass("selected"); $('#sortBLK div[was="cntCLK"]').addClass("selected");/* $('#sortBLK div[was="Price"] label').removeClass("hide"); $('#sortBLK div[was="Price"] .up').addClass("hide");*/ sortWas="TS";/* sortWas="cntCLK"; sortType="desc";*/ } stat("menu",id); setHis('/?'+id); } if ($('#saheDetail').length!=1){ window.location='/'; return true; } $('#sortBLK,#filters').removeClass('mobile'); setTimeout(function(){ $('.burger:visible').click(); sacheBackCLC(true,false); }, 10); } function FilterClick(el){ vas=$(el).attr('plus')!="1"?"1":""; $(el).attr('plus',vas); if (vas=="1"){ stat("metka",$(el).attr('ouid')); } parID=$(el).parent().attr('id'); if ($('.checkBox[plus="1"]').length==0){ ShowWait(); setTimeout(function(){ showSachenList(parID); $("html,body").scrollTop(document.documentElement.scrollTop); }, 10); } else showSachenList(vas=="" && ((parID=='brand_F' && $('#brand_F .checkBox[plus="1"]').length==0) || (parID=='size_F' && $('#size_F .checkBox[plus="1"]').length==0))?null:parID); } function checkFiltersInput(){ if (minDEN_filter!="" && (minDEN_filter<$('#minDEN').attr("min")*1 || minDEN_filter>$('#maxDEN').attr("max")*1)){ $('#minDEN').val(""); minDEN_filter=""; } if (maxDEN_filter!="" && (maxDEN_filter>$('#maxDEN').attr("max")*1 || maxDEN_filter<$('#minDEN').attr("min")*1)){ $('#maxDEN').val(""); maxDEN_filter=""; } if (minDEN_filter!="" && maxDEN_filter!="" && minDEN_filter*1>maxDEN_filter*1){ $('#minDEN').val(""); minDEN_filter=""; $('#maxDEN').val(""); maxDEN_filter=""; } if (minPrice_filter!="" && (minPrice_filter<$('#minPrice').attr("min")*1 || minPrice_filter>$('#maxPrice').attr("max")*1)){ $('#minPrice').val(""); minPrice_filter=""; } if (maxPrice_filter!="" && (maxPrice_filter>$('#maxPrice').attr("max")*1 || maxPrice_filter<$('#minPrice').attr("min")*1)){ $('#maxPrice').val(""); maxPrice_filter=""; } if (minPrice_filter!="" && maxPrice_filter!="" && minPrice_filter*1>maxPrice_filter*1){ $('#minPrice').val(""); minPrice_filter=""; $('#maxPrice').val(""); maxPrice_filter=""; } } function setPerem(){ minDEN=100000; maxDEN=0; minPrice=10000; maxPrice=0; minDEN_filter=$('#minDEN').val(); maxDEN_filter=$('#maxDEN').val(); minPrice_filter=$('#minPrice').val(); maxPrice_filter=$('#maxPrice').val(); checkFiltersInput(); } function CheckAll(tek,plusLST,_F,checkAll){ if (plusLST==null){return true;} if (tek==null){return false;} isOk=true; plus=plusLST.split('@'); popal=0; for (j=0; j20){popal++;} else if (_F=="size_F" && plus.includes(tek[j].size+"") ){popal++;} else if (plus.includes(tek[j]+"")){ popal++; } else if (_F=="Colors_F"){ for (ji=0; ji-1){cntPopal++;} } if (cntPopal>=searchArray.length/1.3){return true;} return false; } function calculateMinMax(tek){ minPrice_tek=10000; oldPrice_tek=minPrice_tek; maxPrice_tek=0; if (tek.OptionsList!=null && tek.OptionsList.length>0){ for (j=0; jopt.price){minPrice=opt.price;} if (maxPriceopt.price){minPrice_tek=opt.price; oldPrice_tek=opt.oldprice;} if (maxPrice_tek0){ if (!CheckAll([tek.CompanyID],plusList["brand_F"],'brand_F',false))return false; if (!CheckAll(tek.metki,plusList["Metki_F"],'Metki_F',true)) return false; if (!CheckAll(tek.OptionsList,plusList["size_F"],'size_F',false)) return false; if (!CheckAll(tek.sostavList,plusList["sostav_F"],'sostav_F',true)) return false; if (!CheckAll([tek.CitiID],plusList["citis_F"],'citis_F',false))return false; if (!CheckAll(tek.colors,plusList["Colors_F"],'Colors_F',false))return false; } if (minDEN>tek.DEN){minDEN=tek.DEN;} if (maxDENmaxDEN_filter)){return false;} if (minPrice_filter!="" && minPrice_tekmaxPrice_filter){return false;} return true; } function setShowCss(){ $('#SachenList_List .FotoItem.hide:lt(7)').attr("class","FotoItem show1"); } function scrollSachen(){ FixResize(); if ($('#Basket').is(":visible")){ if ($(document).width()<=1300 || $(document).scrollTop() + screen.height/2 > $('#Basket #fioDetail > div:visible').last().offset().top ){ $('#basketITOG').css("display","none"); $('#basketITOG_down').css("display","block"); } else { $('#basketITOG_down').css("display","none"); $('#basketITOG').css("display","inline-block"); $('#basketITOG').css("position","fixed"); } return; } nnn=3; while (nnn>0){ nnn--; LastElem=$('#SachenList_List .FotoItem.show1'); hideElements=$('#SachenList_List .FotoItem.hide'); if (hideElements.length==0 || LastElem.length>=Res777.sachen.length){ break; } if (LastElem.length==0) { setShowCss(); continue; } n=Math.ceil(LastElem.length/1.4); // console.log(LastElem.length+"="+n); LastElem=LastElem.get(n>=LastElem.length-1?LastElem.length-1:n); if ($(document).scrollTop() + screen.height /* $(window).height()*/ > $(LastElem).offset().top ){ setShowCss(); continue; } } return true; } function sacheBackCLC(reloadIt,from_popstate){ if (!from_popstate && !reloadIt && window.history.length>=3){ window.history.back(); return; } $('.magnifier').css("display","none"); $('#SearchBLK').removeClass('searchMobile'); if ($('#saheDetail').is(":visible")){ $('#btnMobile,#filters,#sortBLK,#content >hr,#SachenList').removeClass('hide'); $('#saheDetail').addClass('hide'); if (!reloadIt){ setHis(getPatch()); setTimeout(function(){$("html,body").scrollTop(lastScrollContent);},10); return; } } ShowWait(); setTimeout(function(){ showSachenList(null); $("html,body").scrollTop(0); }, 10); } function ColorOldPrice(tekPrice,oldPrice){ razn=(oldPrice-tekPrice)*100/tekPrice; return 'Старая цена '+(razn>=50?'':'')+oldPrice+' руб.'+(razn>=50?'':''); } function selectIT(el){ $(el).parent().children().attr('select','0'); $(el).attr('select',$(el).attr('select')!="1"?"1":"0"); if ($(el).attr('price')!=null){ $('#priceBLK').html($(el).attr('price')+' руб.'); $('#oldPriceBLC').html(ColorOldPrice($(el).attr('price'),$(el).attr('oldprice'))); } if ($('#addToBasket').length==0){ $('#goToBasket').html('добавить в корзину'); $('#goToBasket').attr('id','addToBasket'); } } function sortCLK(el){ if ($(el).hasClass("selected") && $(el).find(">label").length==0){return;} ShowWait(); $('#sortBLK div[class*="selected"]').removeClass("selected"); $(".up,.down").addClass("hide"); $(el).addClass("selected"); if (sortWas==$(el).attr("was")){ if (sortType=="desc"){ sortType="asc"; } else { sortType="desc"; } } if (sortType=="desc"){ $(el).find(".down").removeClass("hide"); } else $(el).find(".up").removeClass("hide"); sortWas=$(el).attr("was"); setTimeout(function(){ showSachenList(null); $("html,body").scrollTop(0); }, 20); } function sortSachen(arr){ if (sortWas=="Name"){ if (sortType=="asc"){ arr.sort(function( a, b ) { // сортировка по убыванию названия. снач цифры if (a.Name > b.Name) return -1; if (a.Name < b.Name) return 1; return 0; }) } else { arr.sort(function( a, b ) { // сортировка по убыванию названия. снач цифры if (a.Name < b.Name) return -1; if (a.Name > b.Name) return 1; return 0; }) } } else if (sortWas=="Price"){ if (sortType=="asc"){ arr.sort(function( a, b ) { // по возрастанию цены if (a.OptionsList[0].price < b.OptionsList[0].price) return -1; if (a.OptionsList[0].price > b.OptionsList[0].price) return 1; return 0; }) } else { arr.sort(function( a, b ) { // по убыванию цены if (a.OptionsList[0].price > b.OptionsList[0].price) return -1; if (a.OptionsList[0].price < b.OptionsList[0].price) return 1; return 0; }) } } else if (sortWas=="OldPrice_Price"){ arr.sort(function( a, b ) { // по убыванию скидки (выгоде) if ((a.OptionsList[0].oldprice-a.OptionsList[0].price) > (b.OptionsList[0].oldprice-b.OptionsList[0].price)) return -1; if ((a.OptionsList[0].oldprice-a.OptionsList[0].price) < (b.OptionsList[0].oldprice-b.OptionsList[0].price)) return 1; return 0; }) } else if (sortWas=="commentCNT"){ arr.sort(function( a, b ) { // по отзывам убывание if (a.commentCNT==null){a.commentCNT=0;} if (b.commentCNT==null){b.commentCNT=0;} if (a.commentCNT > b.commentCNT) return -1; if (a.commentCNT < b.commentCNT) return 1; return 0; }) } else if (sortWas=="cntCLK"){ arr.sort(function( a, b ) { // популярности if (a.cntCLK==null){a.cntCLK=0;} if (b.cntCLK==null){b.cntCLK=0;} if (a.cntCLK_24==null){a.cntCLK_24=0;} if (b.cntCLK_24==null){b.cntCLK_24=0;} if (b.cntCLK_24>0 || a.cntCLK_24>0 ){ if (a.cntCLK_24 > b.cntCLK_24) return -1; if (a.cntCLK_24 < b.cntCLK_24) return 1; } if (a.cntCLK> b.cntCLK) return -1; if (a.cntCLK< b.cntCLK) return 1; return 0; }) } else if (sortWas=="TS"){ arr.sort(function( a, b ) { // Новинки if (a.TS > b.TS) return -1; if (a.TS < b.TS) return 1; return 0; }) } return arr; } function showSachenList(block){ tmp=""; setPerem(); ResTek=[]; checketCNT=$('.checkBox[plus="1"]').length; searchLen=$('#SearchSachen').val().length; if (searchLen>3){ tmpSearch=$('.menuBLK a:contains("'+ucFirst($('#SearchSachen').val())+'")'); if (tmpSearch.length>0){ $('#SearchSachen').val(""); tmpSearch.click(); return true; } } plusList=[]; $('.checkBox[plus="1"]').each(function(){ ouid=$(this).attr("ouid"); parrentID=$(this).parent().attr("id"); plusList[parrentID]=(plusList[parrentID]==null?'':(plusList[parrentID]+'@'))+ouid; }); if (Res777==null || Res777.sachen==null){ window.location="/"; return false; } news=false; sale=false; if ($('.selected[glb]').length>0){ if ($('.selected[glb]').parent().attr("id")=="news"){ news=true; } else { sale=true; } } Res777.sachen=sortSachen(Res777.sachen); patch=getPatch(); tmpNew=false; n=0; for (i=0; i3){ calculateMinMax(tek); if (!checkSearch(tek)){continue;} } else { if (sale && (tek.SaleIt==null || tek.SaleIt==0)){continue;} if (news && !tmpNew){continue;} if ((glblID>-1 && tek.metki.indexOf(glblID)==-1) || (razdT>-1 && tek.metki.indexOf(razdT)==-1)){continue;} } if (!checkFilters(tek,checketCNT,plusList)){continue;} ResTek.push(tek); //if (tek.res==null){ Res777.sachen[i].res='' +'
'+ '
'+ (tmpNew?'New':'')+ (tek.SaleIt!=null && tek.SaleIt==1? ('Sale'):'')+ '
'+ '
'+brandRus[tek.CompanyID]+'
'+ '
'+tek.Name+(tek.DEN!=null?' '+tek.DEN:'')+'
'+ '
'+ '
'+ '
'+minPrice_tek+' руб.
'+ (oldPrice_tek<=minPrice_tek || (oldPrice_tek-minPrice_tek)*100/oldPrice_tek<=7 ?'':'
'+oldPrice_tek+' руб.
')+ '
'; n++; // } tmp+=Res777.sachen[i].res; if (searchLen<4 && glblID==-1 && razdT==-1 && !sale && !news && n>=100){break;} } HideWait(); $('#SachenList_List').html(tmp==""?EmptySachenList():tmp); $('#minPrice').attr("placeholder","от "+minPrice).attr("min",minPrice).attr("max",maxPrice); $('#maxPrice').attr("placeholder","до "+maxPrice).attr("min",minPrice).attr("max",maxPrice); $('#priceF').css("display",minPrice!=100000 && maxPrice>0 ? "block":"none"); $('#minDEN').attr("placeholder","от "+minDEN).attr("min",minDEN).attr("max",maxDEN); $('#maxDEN').attr("placeholder","до "+maxDEN).attr("min",minDEN).attr("max",maxDEN); $('#DEN_F').css("display",minDEN!=100000 && maxDEN>0 ? "block":"none"); $('.cntSachen').html(ResTek.length); ////////////////////////////////////////////////////////////////////////////// CNT_filters_Metki=[]; CNT_FilterColor=[]; CNT_filters_brand=[]; CNT_filters_sostav=[]; CNT_filters_citis=[]; CNT_filters_size=[]; // console.time(); for (i=0; i0?"block":"none"); scrollSachen(); } function searchRes777perID(id){ res=null; id=id*1; for (i=0; i0){ popal3243543=true; popalik=true; } else { for (iii=0; iii0){ popal3243543=true; popalik=true; break; } } } if (!popalik){ v.style.display="none"; } } else if (plus==1 || (t07=wohin[ouid])>0){ popal3243543=true; v.innerHTML=(rus+(t07==null?'':" ("+t07+")")); } else v.style.display="none"; }); $('#'+_BLK).css("display",(!popal3243543?"none":"flow-root")); } function cntPlusFilters(datArr,wohin,_F){ // console.time(); // console.log(_F);*/ if (Array.isArray(datArr)){ for (j=0; j"+res); $("html,body").scrollTop(0); } function basket(){ Post('type=show','/BUY/basketHTML.php',basketCLK); } function ucFirst(str) { if (!str) return str; return str[0].toUpperCase() + str.slice(1); } function checkFCinput(elem){ if (elem==null){return true;} if ($(elem).is(':visible')==false){return true;} val=elem.value; minLen=elem.getAttribute("v-minLen"); maxLen=elem.getAttribute("v-maxLen"); pat=elem.getAttribute("v-pat"); type=elem.getAttribute("v-type"); if (pat!=null && pat!="") { val=val.replace(new RegExp(pat, 'g'), ''); } if (type=="textOnly"){ val=ucFirst(val); } elem.value=val; mes=elem.getAttribute("v-mes-len"); if ((elem.offsetWidth > 0 && elem.offsetHeight > 0) && ((val!=null && val.length>0) || elem.getAttribute("required")!=null)){ if ( (minLen!=null && minLen!="" && val.lengthmaxLen) ){ elem.setCustomValidity("Invalid field."); elem.parentElement.classList.add("error"); if (mes!=null){ elem.parentElement.getElementsByClassName('message')[0].innerHTML=mes; } return false; } } elem.setCustomValidity(""); if (mes!=null){ elem.parentElement.getElementsByClassName('message')[0].innerHTML=""; } elem.parentElement.classList.remove("error"); return true; } function ordersRes(res){ if (res.indexOf("ordersJSON=JSON.parse('[]');")!=-1 || res.indexOf("error")!=-1){ window.location="/"; return; } setHis('/?orders'); $('#content').html("
"+res); HideWait(); setTimeout(function(){ $("html,body").scrollTop(0); }, 10); } function orders(){ Post('type=show','/BUY/ordersHTML.php',ordersRes); } function getPhpRes(res){ $('#content').html("
"+res); HideWait(); setTimeout(function(){ $("html,body").scrollTop(0); }, 10); } function getPhp(wo){ if ($('.burger').is(':visible') && $('#MenuUp > div').is(':visible')){ $('.burger').click(); } ShowWait(); $('#MenuUp .selected').removeClass("selected"); $('#MenuUp a[ouid='+wo+']').addClass("selected"); $('#MenuUp a[ouid='+wo+']').parent().parent().find('> a ').addClass("selected"); setHis('/?'+wo); Post('type=show','/lic/'+wo+'.php',getPhpRes); return false; } function burgerCLK(elem){ elem.classList.toggle('change'); $('#MenuUp,#MenuUp_false').toggleClass('mobile'); $('#content').toggleClass('burgBLK'); $('body').toggleClass('burgBLK'); FixResize(); } function filterMobileCLK(el){ $(el).parent().find('div,hr').toggleClass('show'); } function stat(was,id){ if (st){return true;} Post("was="+was+"&id="+id,"/BUY/cnt.php",null); } ///////////////////////////////////---------REG--------- function checkPassRep(elem){ if (elem.value!=document.getElementById("passw").value){ elem.setCustomValidity("Invalid field."); } else elem.setCustomValidity(""); } function ResClose(){ $("#TB_overlay").hide("slow"); // $(document).off('click'); $(".fix").hide("slow"); $("body").css("overflow","auto"); return false; } var tekTime=0; function addLoginForm(was){ if ($('#schwartzBLK').is(":visible")){ $('#schwartzBLK').click(); } tekTime=Date.now(); setHis('/?reg'); yndx('regBegin'); if (was=="reg"){ document.getElementById("RegText").innerHTML="Регистрация"; document.getElementById("EmailInfo").innerHTML = "Указывайте настоящий email."; $("#ForgotThePas,#regNotLogin").hide(); $("#passwRepead_BLK").show(); } else { document.getElementById("RegText").innerHTML="Вход"; document.getElementById("EmailInfo").innerHTML = ""; $("#ForgotThePas,#regNotLogin").show(); $("#passwRepead_BLK").hide(); } $('#RegistrForm > p:not(#passwRepead_BLK)').css("display","block"); $("#TB_overlay,.fix,#RegForm").show("slow",function() { $("body").css("overflow","hidden"); LoadReCaptcha(); }); } function PasForgot(){ document.getElementById("RegText").innerHTML="Напоминание пароля"; $('#RegistrForm > p:eq(1)').css("display","none"); document.getElementById("submit").value="Отправить пароль"; } function RegistrationForm(){ if (typeof tekTime == "undefined" || (Date.now()-tekTime)/60000>1200){ document.getElementById("PasswInfo").innerHTML ="Обновите страницу и попробуйте еще раз..."; return false; } $('.recaptchaInfo').css("display","none"); document.getElementById("PasswInfo").innerHTML =""; if (typeof grecaptcha != "undefined") { if (grecaptcha.getResponse().length==0){ $('.recaptchaInfo').css("display","table"); return false; } recaptcha = grecaptcha.getResponse(); } else {recaptcha="null";} frgThePass=(document.getElementById("submit").value=="Отправить пароль"); if (!document.getElementById("email").checkValidity() || (!frgThePass && !document.getElementById("passw").checkValidity())){ return false; } email = document.getElementById("email").value; passw = document.getElementById("passw").value; if (document.getElementById("RegText").innerHTML == "Регистрация"){ if (!document.getElementById("passwRepead").checkValidity()){return false;} if (document.getElementById("passw").value!=document.getElementById("passwRepead").value){ document.getElementById("PasswInfo").innerHTML ="Пароли не совпадают..."; return false; } } was2='recaptcha='+recaptcha; was2=adW(was2,"email",email); was2=adW(was2,"passw",passw); was2=adW(was2,"type",(frgThePass?"frgThePass":( (document.getElementById("RegText").innerHTML == "Регистрация"?"reg":"einlogin") ) )); $('#RegForm #submit').attr("disabled","disabled"); $('#RegForm #submit').text("Ожидание"); Post(was2, "/BUY/Registration.php",NachDemRegistration); } function NachDemRegistration(resText) { $('#RegForm #submit').removeAttr("disabled"); $('#RegForm #submit').text("Далее"); if (resText == "" || resText == "error") { document.getElementById("PasswInfo").innerHTML = "Произошла ошибка, попробуйте еще раз"; ReLoadReCaptcha(); } else if (resText=="reg"){ pasTMP=document.getElementById("passw").value; emailTMP=document.getElementById("email").value; addLoginForm("reg"); setTimeout(function () { document.getElementById("passw").value=pasTMP; document.getElementById("email").value=emailTMP; }, 800); } else if (resText == "OK") { document.getElementById("RegText").innerHTML='Пароль был отпрален на указанную почту'; $('#RegistrForm').after(function () { return 'Не забудьте посмотреть папку "Спам"'; }); $('#RegistrForm').css("display","none"); setTimeout(function () { location.reload(); }, 5000); }else if (resText == "pas") { document.getElementById("PasswInfo").innerHTML = (document.getElementById("RegText").innerHTML == "Регистрация" ? "Email уже был ранее зарегестрирован. Пароль указан не верно. Вход не выполнен." : ("Пароль указан не верно")); ReLoadReCaptcha(); document.getElementById("passw").value=""; document.getElementById("passw").focus(); } else if (resText == "captcha") { ReLoadReCaptcha(); $('.recaptchaInfo').css("display","table"); } else if (resText.indexOf("OK") != -1) { arr = resText.split('|'); if (arr.length != 2) { return false; } setCookie("ssid", arr[1], {expires: 61536000}); yndx('regEnd'); location.reload(); } } function ReLoadReCaptcha(){ if ($('#recaptcha iframe').length!=0) { grecaptcha.reset(); } } function LoadReCaptcha(){ if ($('#recaptcha iframe').length==0) { grecaptcha.render('recaptcha', { 'sitekey' : '6Let4tkUAAAAAFPKfr8QUsK3Mclx1hH4c-Qa6QSn', callback: function () { $('.recaptchaInfo').css("display","none"); } }); $("#TB_overlay").off('click').click(function (event) { ResClose(); return false; }); setTimeout(function(){ if (mob) { $('.g-recaptcha-bubble-arrow').parent().css("left",0); } }, 100); //$($('.g-recaptcha-bubble-arrow').parent()[0]).css("left","0"); /*$(function(){ $(document).off('click').click(function(event) { if ($(event.target).closest("#RegForm").length) return; window.history.back(); event.stopPropagation(); }); });*/ } } ///////////////////////////////////---------REG--------- function yndx(was){ if (typeof ym != "undefined"){ ym(38538780,'reachGoal',was); if (was=='basket') {gtag_report_conversion();} } return true; }