-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasd.js
1 lines (1 loc) · 3.74 KB
/
asd.js
1
!function(){var i=FIVE_CRM_GLOBAL.calltracking;i.config={path:{getPhone:FIVE_CRM_GLOBAL.common.api_path+"ctm/calltracking/get-phone",refreshCookie:FIVE_CRM_GLOBAL.common.api_path+"ctm/calltracking/refresh-cookie"}},i.data={},i.methods={encodeQueryData:function(e){var t=[];for(var n in e)t.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t.join("&")},getGenStaticData:function(){return"url="+encodeURIComponent(window.location.hostname)+"&public_token="+FIVE_CRM_GLOBAL.common.public_token},buildQueryData:function(){return this.encodeQueryData(FIVE_CRM_GLOBAL.calltracking.data)},getDataForRefresh:function(){return FIVE_CRM_GLOBAL.calltracking.config.path.refreshCookie+"?format=json&"+this.getGenStaticData()+"&"+this.buildQueryData()},getDataForFetch:function(){return FIVE_CRM_GLOBAL.calltracking.config.path.getPhone+"?format=json&"+this.getGenStaticData()+"&"+this.buildQueryData()},getLinkElement:function(e,t){var n=document.createElement("a");return"8800"==e.substr(0,4)?n.setAttribute("href","tel:"+e):n.setAttribute("href","tel:+"+e),n.innerHTML=t,n.style.color="#000",n.style.textDecoration="none",n},phoneNumberFormat:function(e){var t="";if(0<Object.keys(i.settings).length&&""!=i.settings.mask){for(var n=i.settings.mask,o=0,a=0;a<n.length;a++)"9"==n[a]&&o<11?(t+=e[o],o++):t+=n[a];"8800"==e.substr(0,4)&&(t=t.replace("+",""))}else"8800"!=e.substr(0,4)&&(t+="+"),t+=e.substr(0,1),t+=" ("+e.substr(1,3)+") ",t+=e.substr(4,3)+"-",t+=e.substr(7,2)+"-",t+=e.substr(9,2);return t},pastePhoneNumber:function(e){var t=document.getElementsByClassName("five_crm_calltracking_phone");"7800"==e.substr(0,4)&&(e=e.replace("7800","8800"));for(var n=this.phoneNumberFormat(e),o=this.getLinkElement(e,n),a=0;a<t.length;a++)t[a].innerHTML='<img class="alignnone size-full wp-image-277" src="http://rov-st.ru/wp-content/uploads/2019/03/img_297947.png" alt="" width="296" height="297" />',t[a].appendChild(o.cloneNode(!0))},fetch:function(){var t=this;FIVE_CRM_GLOBAL.UtmForm.utmCookie.checkUTM(FIVE_CRM_GLOBAL.calltracking.data),FIVE_CRM_GLOBAL.UtmForm.utmCookie.getGAID(FIVE_CRM_GLOBAL.calltracking.data),FIVE_CRM_GLOBAL.UtmForm.utmCookie.getYAID(FIVE_CRM_GLOBAL.calltracking.data),FIVE_CRM_GLOBAL.UtmForm.utmCookie.jsonp.send(t.getDataForFetch(),{onSuccess:function(e){e.ans?(FIVE_CRM_GLOBAL.calltracking.data.phone=e.phone,t.pastePhoneNumber(e.phone)):console.warn("[5CRM->widget->calltracking->msg]: "+e.msg)}})},intervalRefreshCookies:function(){var e=this,t=0,n=i.settings.refresh_interval;if(n&&""!=n&&0<n&&n<=60)var o=n;else o=14;var a=setInterval(function(){t++,e.refreshCookie(),1<=t&&clearInterval(a)},6e4*o)},refreshCookie:function(){this.requestRefreshCookies()},requestRefreshCookies:function(){var t=this;FIVE_CRM_GLOBAL.UtmForm.utmCookie.jsonp.send(t.getDataForRefresh(),{onSuccess:function(e){e.ans?(t.saveCookie(),FIVE_CRM_GLOBAL.calltracking.data.phone=e.phone,t.pastePhoneNumber(e.phone)):console.warn("[5CRM->widget->calltracking->msg]: "+e.msg)}})},checkCookies:function(){return!!FIVE_CRM_GLOBAL.UtmForm.utmCookie.readCookie("calltracking_obj")},addMinutes:function(e,t){return new Date(e.getTime()+6e4*t)},saveCookie:function(){FIVE_CRM_GLOBAL.UtmForm.utmCookie.writeCookie("calltracking_obj",JSON.stringify(FIVE_CRM_GLOBAL.calltracking.data),this.addMinutes(new Date,15))}},i.checkLoadCommonJs=function(){var e=this;FIVE_CRM_GLOBAL.UtmForm.isInit?e.run():setTimeout(function(){e.checkLoadCommonJs()},300)},i.initSettings=function(){},i.run=function(){var e=this;i.settings?i.initSettings():i.settings={},e.methods.checkCookies()?(e.data=JSON.parse(unescape(FIVE_CRM_GLOBAL.UtmForm.utmCookie.readCookie("calltracking_obj"))),e.methods.refreshCookie()):(e.methods.fetch(),e.methods.saveCookie()),e.methods.intervalRefreshCookies()},i.init=function(){this.checkLoadCommonJs()},i.init()}(window);