//if( !window['jcClWidgetBase'] ){ //открытие по тэгу if( typeof jcClWidgetBaseOk === 'undefined'){ var jcClWidgetBase = function (param) { this.hash = param.hash; this.wid = param.wid; this.host = param.host; this.type = ''; this.content = ''; this.button = ''; this.cssfile = this.host+'/widget/widget.css'; this.parentid = 0; //родительская сделка this.customer = {}; this.init(param); this.referrer = ''; this.setstat(); this.onopenform = ''; this.oncloseform = ''; this.progressDiv = false; this.progress = false; if(!jcClWidgetBase.mapWidgets[this.wid]) jcClWidgetBase.mapWidgets[this.wid] = this; } jcClWidgetBase.prototype = { init: function(param) { var thisObj = this; this.maindiv = document.createElement('div'); this.maindiv.id='cl_widget_'+this.hash; this.maindiv.innerHTML = ''; this.img = document.createElement('img'); this.img.id='cl_widget_'+this.hash+'_img'; this.img.className = 'clwidget_img'; this.maindiv.appendChild(this.img); this.btn = document.createElement('div'); this.btn.id = 'cl_widget_button_'+this.hash; this.btn.className = 'clwidget-btn'; this.btn.onclick = function(e) { thisObj.openform(); } this.maindiv.appendChild(this.btn); this.container = document.createElement('div'); this.container.id='cl_widget_content_'+this.hash; this.container.className='clwidget-content'; this.container.style.display = 'none'; this.maindiv.appendChild(this.container); this.modal = document.createElement('div'); this.modal.id='cl_widget_overlay_'+this.hash; this.modal.className='clwidget-overlay'; this.modal.onclick = function(e) { thisObj.closeform(); } this.maindiv.appendChild(this.modal) document.body.appendChild(this.maindiv); this.modal.style.zIndex = 9990; this.container.style.zIndex = 9999; jcClWidgetBase.mapWidgets[ this.wid ] = this; this.parentid = 0; this.customer = { id:0, fname:'', mname:'', lname:'', phone:'', email:'', city:''}; }, //init openform: function() { this.modal.style.display='block'; this.modal.style.opacity = 0.7; this.container.style.display='block'; if(this.onopenform) this.onopenform(); }, closeform: function() { this.modal.style.display='none'; this.modal.style.opacity = 0; this.container.style.display='none'; if(this.oncloseform) this.oncloseform(); }, getcookie: function(name) { var reg = new RegExp('('+name+'=)([^;]*)','i'); var matches = document.cookie.match(reg); return matches ? decodeURIComponent(matches[2]) : false; }, setcookie: function(name,val,options) { var str=name+'='+val+';path=/;'; if(options && options.expires) str+='expires='+options.expires; document.cookie = str; }, deletecookie: function(name) { this.setcookie(name, "", {expires: -1}) }, setstat: function() { this.referrer = this.getcookie('clwd_ref'); if(this.referrer == false) { this.referrer = document.referrer; var date = new Date; date.setDate(date.getDate() + 7); this.setcookie('clwd_ref',document.referrer,{expires : date.toUTCString()}); } }, toYandex: function(target) { //Yandex metrika var yaID=0; if (typeof Ya !== "undefined") if(Ya && Ya._metrika && Ya._metrika.getCounters && Ya._metrika.getCounters().length && Ya._metrika.getCounters()[0].id) { yaID = Ya._metrika.getCounters()[0].id+''; if(eval('yaCounter'+yaID)) { var yaCNT = eval('yaCounter'+yaID); yaCNT.reachGoal(target); } } }, toGoogle: function(target) { //Google Analytics if (typeof _gaq !== "undefined") if(_gaq && _gaq.push) _gaq.push(['_trackEvent', 'CloffWidget', target]); //Universal Analytics else if (typeof ga !== "undefined") if(ga) ga('send', 'event', 'CloffWidget', target); }, callscript: function(url,data,fcallback) { var t = new Date().getTime(); var str = url+'?_t='+t+'&_w='+this.wid+'&_h='+this.hash+'&_r='+encodeURIComponent(this.referrer); if(data) str+='&'+data; this.img.onload = function() { var nstatus = parseInt(this.naturalHeight,10); if(fcallback) fcallback(nstatus); } this.img.src = str; }, getparams: function(){ var t = new Date().getTime(); return ('_t='+t+'&_w='+this.wid+'&_h='+this.hash+'&_r='+encodeURIComponent(this.referrer)); }, //отправка запроса CORS callajax: function(url, data, fcallback, isprogress, errfunc) { var t = new Date().getTime(); var thisObj = this; var xmlHttp = new XMLHttpRequest(); xmlHttp.withCredentials = true; if(data){ xmlHttp.open( (data?'POST':'GET'), url, true); xmlHttp.setRequestHeader("Method", "POST " + url + " HTTP/1.1"); xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); data += ('&_t='+t+'&_w='+this.wid+'&_h='+this.hash+'&_r='+encodeURIComponent(this.referrer)); } else { url += ( ( (url.indexOf('?')<=0) ? '?' : '&')+'_t='+t+'&_w='+this.wid+'&_h='+this.hash+'&_r='+encodeURIComponent(this.referrer)); xmlHttp.open( (data?'POST':'GET'), url, true); } xmlHttp.onreadystatechange = function(){ var param = false; //console.log('xmlHttp.readyState',xmlHttp.readyState, 'isprogress', isprogress); if(isprogress){ //console.log('xmlHttp.readyState if(isprogress){ ',(25*xmlHttp.readyState)); thisObj.setProgress(25*xmlHttp.readyState); } if(xmlHttp.readyState == 4){ if(isprogress){ thisObj.hideProgress(); } if(xmlHttp.status !=200 ) { if(errfunc) errfunc(); if( xmlHttp.status != 0 ){ alert('ERROR: request error.\nResponce status:'+xmlHttp.status); return false; } else{ xmlHttp.abort(); return false; } } var resp = xmlHttp.responseText; try { param = eval(resp)[0]; } catch (e) { console.log('Ошибка обработки ответа:', resp); console.error(e); if(errfunc) errfunc(); return false; }; if(fcallback) fcallback(param); } }; if(isprogress){ this.showProgress(); } xmlHttp.send(data); var n = 0; var prog = function(){ n++; thisObj.setProgress(4*n); if(n<20) window.setTimeout( prog, 100); }; prog(); }, setProgress: function(v){ this.progress.value = v; }, showProgress: function(){ if(!this.progressDiv){ this.progressDiv = document.createElement("DIV"); this.progressDiv.className = 'clwidget-progress-overlay'; this.progressDiv.style.display = 'none'; this.progress = document.createElement("PROGRESS"); this.progress.className = 'clwidget-progress'; this.progress.max = 100; this.progressDiv.appendChild(this.progress); document.body.appendChild(this.progressDiv); } //получим zIndex this.progress.value = 0; this.progressDiv.style.zIndex = ( this.zIndex ? parseInt(this.zIndex,10)+10000: (this.container?parseInt(this.container.style.zIndex,10):0)+5); this.progressDiv.style.display = 'block'; }, hideProgress: function(){ this.progressDiv.style.display = 'none'; }, //hideProgress setParent: function(pid){ this.parentid = pid; }, //setParent setCustomer: function(oc){ this.customer = Object.assign({}, oc); }, //setCustomer } jcClWidgetBase.mapWidgets = {}; jcClWidgetBase.getWidget = function(wid){ return ( jcClWidgetBase.mapWidgets[wid] ? jcClWidgetBase.mapWidgets[wid]: false ); }; jcClWidgetBase.onHASH = function(e){ console.log('HASH333', location.hash); if(location.hash.substr(0,6)==='#CLWDG'){ let wid = parseInt(location.hash.substr(6),10); if(wid){ let wgd = jcClWidgetBase.getWidget(wid); if(wgd) wgd.openform(); } } } window.addEventListener('DOMContentLoaded', (event) => { window.addEventListener("hashchange" , function(e) { jcClWidgetBase.onHASH(e); } , false); console.log('OK DOMContentLoaded', jcClWidgetBase.mapWidgets); //ну и проверим а вдруг сразу? if( location.hash && location.hash.length) setTimeout( function(){ jcClWidgetBase.onHASH(); },800); }); console.log('SET DOMContentLoaded', jcClWidgetBase.mapWidgets); var jcClWidgetBaseOk = 1; } //END if jcClWidgetBaseOk; //} //if( !window['jcClWidgetBase'] ){ /* .LINE {max-width: 1010px;} .BLOCK_1 {max-width: 880px;} .BLOCK_2 {max-width: 560px;} .COLUMN_1 {max-width: 346px;} .COLUMN_2 {max-width: 226px; */ console.log('Hello trade'); if(!window.cl$){ window.cl$ = function(el) { return (typeof el == 'string' ? document.getElementById(el) : el); }; } function jcClWidgetTradeb67bc3624616a5c9603df430768769db(param) { this.setting = param.setting; //console.log('param:', param); this.arrPT = []; this.arrPT.push( { id:1, name:'Наличный расчет' } ); this.arrPT.push( { id:2, name:'Безналичный расчет' } ); this.arrPT.push( { id:4, name:'Онлайн оплата' } ); this.arrPT.push( { id:11, name:'Перевод между сделками' } ); jcClWidgetBase.apply(this, arguments); this.type = 'trade'; /*убираем стандартную кнопку*/ this.container = false; this.btn.style.display = 'none'; /*убираем стандартную кнопку*/ var thisObj = this; this.hash ='b67bc3624616a5c9603df430768769db'; this.money = {"id":"1","idDict":"307","idGroup":"0","order":"0","name":"\u0420\u0443\u0431\u043b\u044c","code":"\u0440.","descr":"\u0440\u0443\u0431.","isHide":"0","isProtect":"0","flag":"0"}; this.sizes = [ {w:880, cl: 'BLOCK_1'}, {w:560, cl: 'BLOCK_2'}, {w:380, cl: 'COLUMN_1'}, {w:226, cl: 'COLUMN_2'}, ]; this.cntday = 1; this.SUTKI = 24*3600*1000; this.ssid = this.getcookie('cl_ssid'); if(!this.ssid) this.ssid = ''; this.sid = 'cl_hotel_myaccount_widget_b67bc3624616a5c9603df430768769db'; this.mbrid = param.mbrid; this.customer = false; if(this.mbrid>0){ this.customer = param.customer; } this.email = ''; this.fname = ''; this.mname = ''; this.lname = ''; this.catalog = false; //табы this.tabsMain = false; //данные this.arrBooking = []; //окна this.wAuth = false; this.wMain = false; this.wPay = false; this.wCart = false; this.arrWnd = []; this.frmDoc = false; this.isStatic = false; //списки this.mapCart = {}; this.arrCart = []; this.cnt = 0; this.amount = 0; this.utils = jcClWidgetTradeb67bc3624616a5c9603df430768769db.utils; this.zIndex = jcClWidgetTradeb67bc3624616a5c9603df430768769db.zIndex; this.cart_radio_pt = false; this.utils.init(this); this.initIface(); } jcClWidgetTradeb67bc3624616a5c9603df430768769db.prototype = Object.create(jcClWidgetBase.prototype); jcClWidgetTradeb67bc3624616a5c9603df430768769db.openform = function( ID_CONTAINER, e ){ if(window.clW_b67bc3624616a5c9603df430768769db){ jcClWidgetTradeb67bc3624616a5c9603df430768769db.opencnt = 0; clW_b67bc3624616a5c9603df430768769db.openform( ID_CONTAINER, e ); } else{ setTimeout( function(){ if(jcClWidgetTradeb67bc3624616a5c9603df430768769db.opencnt<10){ jcClWidgetTradeb67bc3624616a5c9603df430768769db.opencnt++; jcClWidgetTradeb67bc3624616a5c9603df430768769db.openform( ID_CONTAINER, e ); } },500); } }; jcClWidgetTradeb67bc3624616a5c9603df430768769db.zIndex = 99998; jcClWidgetTradeb67bc3624616a5c9603df430768769db.prototype.openform = function(ID_CONTAINER, e){ console.log('jcClWidgetTrade.openform 0000'); var thisObj = this; this.zIndex = Math.max(this.utils.maxZIndex(), this.zIndex); console.log('jcClWidgetTrade.openform 1111', this.zIndex); if(ID_CONTAINER){ this.container = cl$(ID_CONTAINER); this.isStatic = true; } if(!this.container){ this.container = document.body; this.isStatic = false; } if(!this.wMain){ this.initTrade(); } this.wMain.style.zIndex = this.zIndex; this.utils.init(this); if(this.progressDiv) this.progressDiv.style.zIndex = this.zIndex+10000; this.load(function(){ thisObj.show(); thisObj.resize(); }); }; //END openform jcClWidgetTradeb67bc3624616a5c9603df430768769db.prototype.show = function(){ //перезаполним каталог var curCat = false; var list = cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_wnd_list_category'); list.innerHTML = ''; for(var c in this.catalog){ //категория list.appendChild(this.catalog[c].getElement()); if( (!curCat) && this.catalog[c].getItemCount()>0){ curCat = this.catalog[c]; } } console.log('jcClWidgetTrade.show 1111'); if(this.isStatic){ //получается что форма а не окно this.container.innerHTML = ''; var w = this.wMain.removeChild( this.wMain.getElementsByTagName('DIV').item(0) ); //( this.wMain.parentNode ? this.wMain.parentNode.removeChild(this.wMain): this.wMain); this.container.appendChild(w); this.utils.jscClassRemove(w, 'lk_modal_wrap'); } else{ this.wMain.style.zIndex = this.zIndex; this.wMain.style.display = 'flex'; } console.log('jcClWidgetTrade.show 2222'); if(curCat) curCat.show(); }; jcClWidgetTradeb67bc3624616a5c9603df430768769db.prototype.close = function(){ this.wMain.style.zIndex = this.zIndex; this.wMain.style.display = 'none'; this.wCart.style.display = 'none'; }; //END close jcClWidgetTradeb67bc3624616a5c9603df430768769db.prototype.initIface = function(){ console.log('0 jcClWidgetTrade.initIface'); //this.initTrade(); if( this.setting.use_paytype && (this.arrPT.length>0) ){ this.cart_radio_pt = this.utils.radioInit( cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_paytype'), this.arrPT, this.arrPT[0].id); } else{ cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_paytype').parentNode.style.display = 'none'; } if( !this.setting.use_address ){ cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_cart_address').parentNode.style.display = 'none'; } console.log('1 jcClWidgetTrade.initIface'); } jcClWidgetTradeb67bc3624616a5c9603df430768769db.prototype.initTrade = function(){ var thisObj = this; console.log('0 jcClWidgetTrade.initTrade'); if(!this.container) this.container = document.body; this.wMain = cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_wnd'); this.wMain.style.display = 'none'; this.container.appendChild( this.wMain.parentNode.removeChild(this.wMain) ); cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_wnd_x').onclick = function(){ thisObj.close(); return false; }; this.list_product = cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_wnd_product_list'); this.wCart = cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_wnd_cart'); this.wCart.style.display = 'none'; document.body.appendChild( this.wCart.parentNode.removeChild(this.wCart) ); cl$(this.wCart.id+'_x').onclick = function(){ thisObj.wCart.style.display = 'none'; return false; }; this.cart_list_product = cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_wnd_cart_list'); this.wCart.show = function(){ thisObj.cart_list_product.innerHTML = ''; for(var cp in thisObj.mapCart){ thisObj.cart_list_product.appendChild(thisObj.mapCart[cp].getElement()); } cartInit(); thisObj.wCart.style.zIndex = thisObj.zIndex+5; thisObj.wCart.style.display = 'flex'; }; var cartInit = function(){ //-----pattern cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_cart_phone').onkeydown = function(e) { var thisElem = this; e = e || event; if (e.which!=0 && e.charCode!=0) e.keyCode = event.which; //МН if(thisElem.parentNode.getAttribute('mycode')!='+7') { if((e.keyCode>57) && (e.keyCode<96)) return false; if((e.keyCode==32) || (e.keyCode>105)) return false; if(e.altKey || e.ctrlKey || e.shiftKey) return false; return true; } if(/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase())) { setTimeout(function(){ thisObj.utils.setPhonePattern(thisElem,e);}, 10); return true; } if((e.keyCode>57) && (e.keyCode<96)) return false; if((e.keyCode==32) || (e.keyCode>105)) return false; if(e.altKey || e.ctrlKey || e.shiftKey) return false; setTimeout(function(){thisObj.utils.setPhonePattern(thisElem,e);}, 10); } if(thisObj.customer){ cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_cart_fname').value = thisObj.customer.fname; cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_cart_mname').value = thisObj.customer.mname; cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_cart_lname').value = thisObj.customer.lname; cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_cart_email').value = thisObj.customer.email; cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_cart_phone').value = '('+thisObj.customer.phone.substr(1,3)+')'+thisObj.customer.phone.substr(4,3)+'-'+thisObj.customer.phone.substr(7,2)+'-'+thisObj.customer.phone.substr(9,2); } if(thisObj.parentid){ thisObj.utils.jscClassAdd( cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_customer_form'), 'hide' ); } else{ thisObj.utils.jscClassRemove( cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_customer_form'), 'hide' ); } cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_wnd_cart_ok').onclick = function(e){ thisObj.save(); }; }; console.log('1 jcClWidgetTrade.initTrade'); }; //END prototype.initTrade jcClWidgetTradeb67bc3624616a5c9603df430768769db.prototype.resize = function(){ var scrH = this.wMain.clientHeight var wnd = cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_wnd_header').parentNode; var wndH = wnd.clientHeight; if(this.isStatic){ cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_wnd_button_UP').style.display = 'none'; } else { if( scrH>wndH+wnd.clientTop ){ cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_wnd_button_UP').style.display = 'none'; } else{ cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_wnd_button_UP').style.display = 'flex'; } } }; jcClWidgetTradeb67bc3624616a5c9603df430768769db.prototype.load = function(cb){ var thisObj = this; this.request( thisObj.host+'/widget/trade.load.rs.php?aj=1', 'aj=1', function(param){ thisObj.catalog = []; for(var c in param.arrcat){ thisObj.catalog.push(new jcClCategory(thisObj, param.arrcat[c])); } if(cb) cb(); }); }; jcClWidgetTradeb67bc3624616a5c9603df430768769db.prototype.onCategoryShow = function(cat){ for(var c in this.catalog){ if(this.catalog[c].id != cat.id){ this.utils.jscClassAdd(cl$(this.catalog[c].el.id+'_name'), 'cl_wdt_outline'); } else{ this.utils.jscClassRemove(cl$(this.catalog[c].el.id+'_name'), 'cl_wdt_outline'); } } }; jcClWidgetTradeb67bc3624616a5c9603df430768769db.prototype.request = function(url, spost, callback){ var thisObj =this; if(this.progressDiv) this.progressDiv.style.zIndex = this.zIndex+10000; thisObj.callajax( url, spost, function(param){ if(parseInt(param.errcode,10)==10){ thisObj.utils.alert('Сессия устарела.
\nТребуется аутентификация.', function(){ thisObj.mbrid = 0; thisObj.close(); }); return; } if(param.errcode>0){ thisObj.utils.alert(param.errmsg); return; } if(callback) callback(param); }, true); }; jcClWidgetTradeb67bc3624616a5c9603df430768769db.prototype.add = function(product){ if(this.mapCart[product.id]){ //уже есть == увеличиваем количество this.mapCart[product.id].cnt++; } else{ this.mapCart[product.id] = new jcClCartItem(product); } this.rePrice(); } jcClWidgetTradeb67bc3624616a5c9603df430768769db.prototype.remove = function(product){ //интерфейсный элемент product.el.parentNode.removeChild(product.el); if(this.mapCart[product.id]) delete(this.mapCart[product.id]); this.rePrice(); } jcClWidgetTradeb67bc3624616a5c9603df430768769db.prototype.rePrice = function(){ var thisObj = this; var cart = cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_wnd_catalog_cart'); this.cnt = 0; this.amount = 0; for(var p in this.mapCart){ this.cnt += this.mapCart[p].cnt; this.amount += (this.mapCart[p].cnt*this.mapCart[p].product.price); } var btTxt = 'Корзина пуста'; var btTitle = 'Выберите товары/продукты'; if(this.cnt){ this.utils.jscClassAdd(cart, 'clh_cart_full'); btTxt = 'Корзина ('+this.cnt+')\n
'+(this.amount/100)+this.money.code; btTitle = 'Оформить заказ'; cart.onclick = function(){ thisObj.wCart.show(); }; } else{ this.utils.jscClassRemove(cart, 'clh_cart_full'); cart.onclick = function(){}; } cart.innerHTML = btTxt; cart.title = btTitle; cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_cart_amount').innerHTML = this.amount/100; } jcClWidgetTradeb67bc3624616a5c9603df430768769db.prototype.save = function(){ var thisObj = this; this.rePrice(); //получим и проверим данные var fname = this.utils.trim( cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_cart_fname').value ); var lname = this.utils.trim( cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_cart_lname').value ); var email = this.utils.trim( cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_cart_email').value ); var phone = this.utils.trim( cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_cart_phone').value ); var addr = this.utils.trim( cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_cart_address').value ); var comment = this.utils.trim( cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_cart_comment').value ); var paytype = ( this.cart_radio_pt ? this.cart_radio_pt.selid: 0); var err = ''; if(fname==''){ err += 'Введите имя\n'; } if(lname==''){ err += 'Введите фамилию\n'; } if(email==''){ err += 'Введите email\n'; } if(phone==''){ err += 'Введите телефон\n'; } if( this.setting.use_address==2 ){ if(addr==''){ err += 'Введите адрес доставки\n'; } } err = this.utils.trim(err); if(err!=''){ this.utils.alert(err); return; } let customer_id = 0; if(this.customer) customer_id = this.customer.id; var arrCart = []; for(var p in this.mapCart){ arrCart.push({ id:this.mapCart[p].product.id, cnt:this.mapCart[p].cnt, price:this.mapCart[p].product.price, amount:(this.mapCart[p].cnt*this.mapCart[p].product.price) }); } cid = 0; if(this.customer) cid =this.customer.id; var spost = 'mbrid='+this.mbrid + '&fname='+fname + '&lname='+lname + '&customerid='+customer_id + '&parentid='+this.parentid + '&email='+email + '&phone='+phone + '&addr='+addr + '&comment='+comment + '&paytype='+paytype + '&custid='+cid + '&arrcart='+JSON.stringify(arrCart) ; //console.log('spost:', spost); thisObj.request( thisObj.host+'/widget/trade.cart.save.rs.php?aj=1', spost, function(param){ console.log('ORDER ', param); if(param.message && param.message.length>0){ thisObj.close(); thisObj.utils.alert(param.message, function(){ if(param.payurl && param.payurl.length>0){ document.location.href = param.payurl; } }) } }, true); } jcClWidgetTradeb67bc3624616a5c9603df430768769db.utils = { init: function(w){ this.wdg = w }, trim: function(s){ return s.replace(/^\s+|\s+$/g, ""); }, addEvent : function(elem, type, handler){ if (elem.addEventListener){elem.addEventListener(type, handler, false)} else { elem.attachEvent("on"+type, handler)} }, removeEvent : function(elem, type, handler){ if (elem.removeEventListener){elem.removeEventListener(type, handler, false)} else { elem.detachEvent("on"+type, handler)} }, wAlert : false, wConfirm : false, wdg: false, alert : function(msg,callback){ var utils = jcClWidgetTradeb67bc3624616a5c9603df430768769db.utils; if(!utils.wAlert) { utils.wAlert = cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_wnd_alert'); utils.wAlert.style.display = 'none'; document.body.appendChild( utils.wAlert.parentNode.removeChild(utils.wAlert) ); cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_wnd_alert_close_x').onclick = cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_wnd_alert_close').onclick = function(){ utils.jscClassAdd(utils.wAlert, 'hide'); utils.wAlert.style.zIndex = utils.wdg.zIndex; if(callback){ callback(); } }; } var zIndex = Math.max(utils.wdg.zIndex,utils.maxZIndex()); utils.wAlert.style.zIndex = zIndex+5; cl$(utils.wAlert.id+'_msg').innerHTML = msg.replace(/(?:\r\n|\r|\n)/g, "
"); utils.wAlert.style.display = 'flex'; utils.jscClassRemove(utils.wAlert, 'hide'); }, confirm : function(msg, param){ var utils = jcClWidgetTradeb67bc3624616a5c9603df430768769db.utils; var thisObj = this; if(!this.wConfirm) { this.wConfirm = cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_wnd_confirm'); this.wConfirm.msg = cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_wnd_confirm_msg'); this.wConfirm.style.display = 'none'; document.body.appendChild( this.wConfirm.parentNode.removeChild(this.wConfirm) ); } cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_wnd_confirm_close_x').onclick = cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_wnd_confirm_not').onclick = function(){ utils.jscClassAdd(thisObj.wConfirm, 'hide'); thisObj.wConfirm.style.display = 'none'; if(param && param.onclose) param.oncancel(); }; cl$('cl_trade_widget_b67bc3624616a5c9603df430768769db_wnd_confirm_yes').onclick = function(){ utils.jscClassAdd(thisObj.wConfirm, 'hide'); thisObj.wConfirm.style.display = 'none'; if(param && param.onok) param.onok(); }; var zIndex = Math.max(utils.wdg.zIndex,utils.maxZIndex()); this.wConfirm.style.zIndex = zIndex+5; this.wConfirm.msg.innerHTML = msg; utils.jscClassRemove(thisObj.wConfirm, 'hide'); this.wConfirm.style.display = 'flex'; }, //работа с куками setCookie : function(cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays*24*60*60*1000)); var expires = "expires="+ d.toUTCString(); document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; }, getCookie : function(cname) { var name = cname + "="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for(var i = 0; i parseFloat(window.getComputedStyle(a).zIndex)) .filter(a => !isNaN(a)) .sort(function(a, b) { return a - b; }) .pop(); return (res ? res: 0); }, setPhonePattern: function(inp,e) { var digs=inp.value.replace(new RegExp("[^0-9]",'g'),''); if(digs.length>10) digs=digs.substr(0,10); var pos=inp.selectionStart; var digsFull=digs+'__________'; var res='('+digsFull.substr(0,3)+')'+digsFull.substr(3,3)+'-'+digsFull.substr(6,2)+'-'+digsFull.substr(8,2); switch (e.keyCode) { case 8: //backspace switch (pos) { case 0: pos=1; break; case 5:case 9:case 12: pos--; break; } break; case 46: //delete break; case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57: case 96:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105: //цифры case 229: //mobile samsung keypad!!! all of keys if(pos>res.replace(/[\_]/g,'').length) switch (digs.length) { case 0:case 1:case 2: pos=digs.length+1; break; case 3:case 4:case 5: pos=digs.length+2; break; case 6:case 7: pos=digs.length+3; break; case 8:case 9: pos=digs.length+4; break; } else switch (pos) { case 1:case 4:case 8:case 11: case 5:case 9:case 12: pos++; break; } break; } inp.value=res; if (inp.createTextRange) { var r = inp.createTextRange(); r.collapse(true); r.moveEnd('character', pos); r.moveStart('character', pos); r.select(); } else inp.setSelectionRange(pos,pos); return true; }, radioInit: function(el, arr, sid){ var u = this; var radioObj = { root: el, mapItems: {}, selid: 0, select: function(item){ this.selid = parseInt( item.id.replace( this.root.id+'_', '' ), 10); cl$(item.id+'_bt').checked = true; }, init: function(){ var thisObj = this; var itemTPL = this.root.innerHTML; this.root.innerHTML = ''; sHTML = ''; reg = /PTID/gi; for(var k=0; k1){ cl$(jcClGallery.wnd.id+'_photo_description').style.display = 'flex'; cl$(jcClGallery.wnd.id+'_photo_description').innerHTML = descr; } else{ cl$(jcClGallery.wnd.id+'_photo_description').style.display = 'none'; } jcClGallery.wnd.zIndex = widget.zIndex+1000; jcClGallery.wnd.style.display = 'flex'; cl$(jcClGallery.wnd.id+'_photo_close').onclick = function(){ jcClGallery.wnd.style.display = 'none'; }; var jfNextImg = function(){ var ci = cur.firstChild; if(ci){ cur.removeChild(cur.firstChild); sto.insertBefore(ci,sto.lastChild.nextSibling); } cur.appendChild(sto.removeChild(sto.firstChild)); } var jfPrevImg = function(){ var ci = cur.firstChild; if(ci){ cur.removeChild(cur.firstChild); sto.insertBefore(ci,sto.firstChild); } cur.appendChild(sto.removeChild(sto.lastChild)); } jfNextImg(); if(arrImgs.length>1){ cl$(jcClGallery.wnd.id+'_photo_next').style.visibility = 'visible'; cl$(jcClGallery.wnd.id+'_photo_prev').style.visibility = 'visible'; } else{ cl$(jcClGallery.wnd.id+'_photo_next').style.visibility = 'hidden'; cl$(jcClGallery.wnd.id+'_photo_prev').style.visibility = 'hidden'; } cl$(jcClGallery.wnd.id+'_photo_next').onclick = function(){ jfNextImg(); }; cl$(jcClGallery.wnd.id+'_photo_prev').onclick = function(){ jfPrevImg(); }; };//playGallery } var sc = document.createElement('script'); sc.type = 'text/javascript'; sc.src = 'https://20483.cloff.ru/js/wdt.js?v=600'; sc.charset = 'UTF-8'; var hd = document.getElementsByTagName("HEAD"); hd.item(0).appendChild(sc); var d = document.createElement('DIV'); d.innerHTML = (' CLOFF_logo_ext file_sign file_dollar file_template print_new email_alt dots_reg_h dots_reg_v bars delete_outline_alt attach_money calend guest bed_double bed_two chevron_left chevron_right chevron_right_w caret_up caret_down caret_down quest_circle_solid clock exit_new excl_triangle_solid check pet_paw '); if(document.body) document.body.appendChild(d); else document.head.appendChild(d); var clW_b67bc3624616a5c9603df430768769db; sc.onload = function(){ clW_b67bc3624616a5c9603df430768769db = new jcClWidgetTradeb67bc3624616a5c9603df430768769db({ hash:'b67bc3624616a5c9603df430768769db' , wid:2905 , host:'https://20483.cloff.ru/' , mbrid:0 , customer:{ customerid:'0' , email:'' , phone:'' , fname:'' , lname:'' , mname:'' } , setting: { use_address: 0, use_paytype: 0, } }); };