Your IP : 3.17.128.87
(function(){var e=window.BX;if(e.UserContentView){return}e.UserContentView={displayHeight:0,mobile:false,ajaxUrl:"/bitrix/tools/sonet_set_content_view.php",pathToUserProfile:"",inited:false,viewAreaList:[],lastViewAreaList:{},viewAreaReadList:[],viewAreaSentList:[],viewAreaAverageHeight:200,viewAreaTimePeriodMin:1e3,viewAreaTimePeriodMax:1e4,viewAreaTimePeriodAvg:1500,sendViewAreaTimeout:5e3,commentsContainerId:null,commentsClassName:"feed-com-text-inner",commentsFullContentClassName:"feed-com-text-inner-inner",currentPopupId:null,popupList:{},toSendList:[]};e.UserContentView.clear=function(){this.viewAreaList=[]};e.UserContentView.setDisplayHeight=function(){this.displayHeight=document.documentElement.clientHeight};e.UserContentView.init=function(t){if(this.inited){return}this.inited=true;this.setDisplayHeight();window.addEventListener("scroll",e.throttle(function(){e.UserContentView.getInViewScope()},80),{passive:true});window.addEventListener("resize",e.delegate(e.UserContentView.setDisplayHeight,this));if(e.type.isPlainObject(t)){if(e.type.isBoolean(t.mobile)){this.mobile=t.mobile}if(e.type.isNotEmptyString(t.ajaxUrl)){this.ajaxUrl=t.ajaxUrl}if(e.type.isNotEmptyString(t.commentsContainerId)){this.commentsContainerId=t.commentsContainerId}if(e.type.isNotEmptyString(t.commentsClassName)){this.commentsClassName=t.commentsClassName}if(e.type.isNotEmptyString(t.commentsFullContentClassName)){this.commentsFullContentClassName=t.commentsFullContentClassName}}if(e.browser.SupportLocalStorage()){var i=e.localStorage.get("viewedContent");if(e.type.isArray(i)){this.viewAreaSentList=i}}e.addCustomEvent(window,"OnUCRecordHasDrawn",e.delegate(this.onUCRecordHasDrawn,this));e.addCustomEvent(window,"OnUCListWasShown",e.delegate(this.OnUCListWasShown,this));if(this.mobile){e.addCustomEvent(window,"OnUCHasBeenInitialized",e.delegate(this.OnUCHasBeenInitializedMobile,this));this.sendViewAreaTimeout=1500}setTimeout(e.delegate(this.sendViewAreaData,this),this.sendViewAreaTimeout)};e.UserContentView.getInViewScopeNode=function(t){var i=e(t),n=new Date,s=parseInt(n.getTime());if(!i){for(var o=0,a=this.viewAreaList.length;o<a;o++){if(t==this.viewAreaList[o]){delete this.viewAreaList[o]}}return}if(this.isNodeVisibleOnScreen(i)){var r=this.getXmlId(i);if(!e.type.isBoolean(this.lastViewAreaList[t])&&(!e.type.isNotEmptyString(r)||!e.util.in_array(r,this.viewAreaSentList))){setTimeout(e.delegate(function(){if(e.UserContentView.isNodeVisibleOnScreen(this)){e.UserContentView.setRead(this)}delete e.UserContentView.lastViewAreaList[this.id]},i),this.viewAreaTimePeriodAvg)}this.lastViewAreaList[t]=true}};e.UserContentView.getInViewScope=function(){for(var e=0,t=this.viewAreaList.length;e<t;e++){this.getInViewScopeNode(this.viewAreaList[e])}};e.UserContentView.getXmlId=function(e){return e.getAttribute("bx-content-view-xml-id")};e.UserContentView.getSaveValue=function(e){return e.getAttribute("bx-content-view-save")!="N"?"Y":"N"};e.UserContentView.setRead=function(t){var i=this.getXmlId(t);if(i.length>0){var n=false;for(var s=0,o=this.viewAreaReadList.length;s<o;s++){if(this.viewAreaReadList[s].xmlId==i){n=true;break}}if(!n){this.viewAreaReadList.push({xmlId:i,save:this.getSaveValue(t)});var a={xmlId:i};e.onCustomEvent(window,"BX.UserContentView.onSetRead",[a]);if(typeof BXMobileApp!="undefined"){BXMobileApp.onCustomEvent("BX.UserContentView.onSetRead",a,true)}}}};e.UserContentView.isNodeVisibleOnScreen=function(e){var t=e.getBoundingClientRect();var i=parseInt(this.displayHeight/4);var n=parseInt(this.displayHeight*3/4);return(t.top>0&&t.top<n||t.bottom>i&&t.bottom<this.displayHeight)&&(this.mobile||!(t.top<i&&t.bottom<i||t.top>n&&t.bottom>n))};e.UserContentView.sendViewAreaData=function(){var t=null,i=null;this.toSendList=[];for(i=0,length=this.viewAreaReadList.length;i<length;i++){t=this.viewAreaReadList[i];if(!e.util.in_array(t.xmlId,this.viewAreaSentList)){this.toSendList.push(t)}}if(this.toSendList.length>0&&this.ajaxUrl){var n={action:"set_content_view",sessid:e.bitrix_sessid(),site:e.message("SITE_ID"),lang:e.message("LANGUAGE_ID"),viewXMLIdList:this.toSendList};if(!!this.mobile){n.mobile_action="set_content_view";var s=new MobileAjaxWrapper;s.Wrap({type:"json",method:"POST",url:this.ajaxUrl,data:n,callback:e.delegate(e.UserContentView.success,this),callback_failure:function(e){}})}else{e.ajax({url:this.ajaxUrl,method:"POST",dataType:"json",data:n,onsuccess:e.delegate(e.UserContentView.success,this),onfailure:function(e){}})}}setTimeout(e.delegate(this.sendViewAreaData,this),this.sendViewAreaTimeout)};e.UserContentView.success=function(t){if(e.type.isNotEmptyString(t.SUCCESS)&&t.SUCCESS=="Y"){for(i=0,length=this.toSendList.length;i<length;i++){this.viewAreaSentList.push(this.toSendList[i].xmlId)}if(e.browser.SupportLocalStorage()){e.localStorage.set("viewedContent",this.viewAreaSentList,86400)}}};e.UserContentView.registerViewArea=function(t,i){if(t.length>0&&!e.util.in_array(t,this.viewAreaList)&&e(t)){this.viewAreaList.push(t);this.getInViewScopeNode(t)}};e.UserContentView.onUCRecordHasDrawn=function(t,i,n){if(typeof n=="undefined"||typeof n.ACTION=="undefined"||typeof i=="undefined"){return}if(n.ACTION=="REPLY"){var s=e.delegate(function(){this.onUCRecordHasDrawnFunc(i)},this);var o=e.debounce(e.delegate(function(){e.unbind(document,"mousemove",o);s()},this),100,this);var a=e.delegate(function(){BXMobileApp.UI.Page.isVisible({callback:function(e){if(e&&e.status=="visible"){s()}else{setTimeout(a,50)}}})},this);if(this.mobile){setTimeout(a,50)}else{e.bind(document,"mousemove",o)}}};e.UserContentView.onUCRecordHasDrawnFunc=function(t){var i="record-"+t.join("-");if(e(i)){var n=e.findChild(e(i),{tag:"div",className:this.commentsClassName},true);if(n&&n.id.length>0){var s=e.findChild(n,{tag:"div",className:this.commentsFullContentClassName});e.UserContentView.registerViewArea(n.id,s?s:null)}}};e.UserContentView.OnUCListWasShown=function(t,i,n){var s=null,o=e.findChildren(n,{tag:"div",className:this.commentsClassName},true);for(var a=0,r=o.length;a<r;a++){if(o[a].id.length>0){s=e.findChild(o[a],{tag:"div",className:this.commentsFullContentClassName});this.registerViewArea(o[a].id,s?s:null)}}};e.UserContentView.OnUCHasBeenInitializedMobile=function(e,t){this.registerViewAreaList({containerId:this.commentsContainerId,className:this.commentsClassName,fullContentClassName:this.commentsFullContentClassName})};e.UserContentView.registerViewAreaList=function(t){if(typeof t=="undefined"||typeof t.containerId=="undefined"||typeof t.className=="undefined"){return}if(e(t.containerId)){var i=null,n=e.findChildren(e(t.containerId),{tag:"div",className:t.className},true);for(var s=0,o=n.length;s<o;s++){if(n[s].id.length>0){i=e.findChild(n[s],{tag:"div",className:t.fullContentClassName});this.registerViewArea(n[s].id,i?i:null)}}}};e.UserContentView.liveUpdate=function(t){var i=e("feed-post-contentview-cnt-"+t.CONTENT_ID);var n=e("feed-post-contentview-cnt-wrap-"+t.CONTENT_ID);if(i&&n){var s=e.create("SPAN",{props:{className:"feed-content-view-plus-one"},style:{width:n.clientWidth-8+"px",height:n.clientHeight-8+"px"},html:"1"});n.insertBefore(s,n.firstChild);setTimeout(function(){i.innerHTML=parseInt(i.innerHTML)+1},500);setTimeout(function(){e.cleanNode(s,true)},2e3)}};e.UserContentView.Counter=function(){this.contentId=null;this.nodeId=null;this.node=null;this.popup=null;this.popupTimeoutId=null;this.popupContent=null;this.hiddenCountNode=null;this.popupContentPage=1;this.popupShownIdList=[];this.pathToUserProfile="";this.mouseLeaveTimeoutId=null;this.listXHR=null};e.UserContentView.Counter.prototype.init=function(t){this.contentId=t.contentId;this.nodeId=t.nodeId;if(this.nodeId){this.node=e(this.nodeId);this.popupContent=e.findChild(e("bx-contentview-cnt-popup-cont-"+this.contentId),{tagName:"span",className:"bx-contentview-popup"},true,false)}if(e.type.isNotEmptyString(t.pathToUserProfile)){this.pathToUserProfile=t.pathToUserProfile}if(typeof e.PULL!="undefined"){e.PULL.extendWatch("CONTENTVIEW"+this.contentId)}this.popupScroll();e.bind(this.node,"mouseover",e.delegate(function(){if(this.popup!==null&&this.popup.isShown()){return}clearTimeout(this.popupTimeoutId);this.popupContentPage=1;e.cleanNode(this.popupContent);this.popupContent.appendChild(e.create("SPAN",{props:{className:"bx-contentview-wait"}}));this.popupTimeoutId=setTimeout(e.delegate(function(){if(e.UserContentView.currentPopupId==this.contentId){return false}if(this.popupContentPage==1){this.list({page:1})}this.popupTimeoutId=setTimeout(e.delegate(function(){this.openPopup()},this),400)},this),400)},this));e.bind(this.node,"mouseout",e.delegate(function(){clearTimeout(this.popupTimeoutId)},this));e.bind(this.node,"click",e.delegate(function(){clearTimeout(this.popupTimeoutId);if(this.popupContentPage==1){this.list({page:1})}this.openPopup()},this))};e.UserContentView.Counter.prototype.list=function(t){if(this.listXHR){this.listXHR.abort()}var i=t.page;if(parseInt(this.node.innerHTML)==0){return false}if(i==null){i=this.popupContentPage}if(i==1){this.popupShownIdList=[]}var n={action:"get_view_list",sessid:e.bitrix_sessid(),site:e.message("SITE_ID"),lang:e.message("LANGUAGE_ID"),contentId:this.contentId,pathToUserProfile:this.pathToUserProfile,page:i};this.listXHR=e.ajax({url:e.UserContentView.ajaxUrl,method:"POST",dataType:"json",data:n,onsuccess:e.delegate(function(t){if(parseInt(t.itemsCount)<=0&&parseInt(t.hiddenCount)<=0){return false}if(i==1){this.popupContent.innerHTML=""}this.popupContentPage+=1;var n=null;for(var s=0;s<t.items.length;s++){if(e.util.in_array(t.items[s]["ID"],this.popupShownIdList)){continue}this.popupShownIdList.push(t.items[s]["ID"]);if(t.items[s]["PHOTO_SRC"].length>0){n=e.create("IMG",{attrs:{src:t.items[s]["PHOTO_SRC"]},props:{className:"bx-contentview-popup-avatar-img"}})}else{n=e.create("IMG",{attrs:{src:"/bitrix/images/main/blank.gif"},props:{className:"bx-contentview-popup-avatar-img bx-contentview-popup-avatar-img-default"}})}this.popupContent.appendChild(e.create("A",{attrs:{href:t.items[s]["URL"],target:"_blank",title:t.items[s]["DATE_VIEW_FORMATTED"]},props:{className:"bx-contentview-popup-img"+(!!t.items[s]["TYPE"]?" bx-contentview-popup-img-"+t.items[s]["TYPE"]:"")},children:[e.create("SPAN",{props:{className:"bx-contentview-popup-avatar-new"},children:[n,e.create("SPAN",{props:{className:"bx-contentview-popup-avatar-status-icon"}})]}),e.create("SPAN",{props:{className:"bx-contentview-popup-name-new"},html:t.items[s]["FULL_NAME"]})]}))}if(parseInt(t.hiddenCount)>0){e.cleanNode(this.hiddenCountNode,true);this.hiddenCountNode=e.create("SPAN",{props:{className:"bx-contentview-popup-name-new contentview-counter-hidden"},html:e.message("SONET_CONTENTVIEW_JS_HIDDEN_COUNT").replace("#CNT#",t.hiddenCount)});this.popupContent.appendChild(this.hiddenCountNode)}this.adjustWindow();this.popupScroll()},this),onfailure:function(e){}});return false};e.UserContentView.Counter.prototype.openPopup=function(){if(parseInt(this.node.innerHTML)==0){return false}if(this.popup==null){this.popup=new e.PopupWindow("contentview-popup-"+this.contentId,this.node,{lightShadow:true,offsetLeft:-22,autoHide:true,closeByEsc:true,zIndex:2005,bindOptions:{position:"top"},animationOptions:{show:{type:"opacity-transform"},close:{type:"opacity"}},events:{onPopupClose:function(){e.UserContentView.currentPopupId=null},onPopupDestroy:function(){}},content:e("bx-contentview-cnt-popup-cont-"+this.contentId),className:"popup-window-contentview"});e.UserContentView.popupList[this.contentId]=this.popup;e.bind(e("contentview-popup-"+this.contentId),"mouseout",e.delegate(function(){clearTimeout(this.popupTimeout);this.popupTimeout=setTimeout(e.delegate(function(){this.popup.close()},this),1e3)},this));e.bind(e("contentview-popup-"+this.contentId),"mouseover",e.delegate(function(){clearTimeout(this.popupTimeout);clearTimeout(this.mouseLeaveTimeoutId)},this));e.bind(this.node,"mouseleave",e.delegate(function(){this.mouseLeaveTimeoutId=setTimeout(e.delegate(function(){this.popup.close()},this),1e3)},this))}if(e.UserContentView.currentPopupId!=null){e.UserContentView.popupList[e.UserContentView.currentPopupId].close()}e.UserContentView.currentPopupId=this.contentId;this.popup.show();this.adjustWindow()};e.UserContentView.Counter.prototype.popupScroll=function(){e.bind(this.popupContent,"scroll",e.delegate(function(){var t=e.proxy_context;if(t.scrollTop>(t.scrollHeight-t.offsetHeight)/1.5){this.list({page:null});e.unbindAll(t)}},this))};e.UserContentView.Counter.prototype.adjustWindow=function(){if(this.popup!=null){this.popup.bindOptions.forceBindPosition=true;this.popup.adjustPosition();this.popup.bindOptions.forceBindPosition=false}};e.addCustomEvent(window,"BX.UserContentView.onInitCall",e.delegate(e.UserContentView.init,e.UserContentView));e.addCustomEvent(window,"BX.UserContentView.onRegisterViewAreaListCall",e.delegate(e.UserContentView.registerViewAreaList,e.UserContentView));e.addCustomEvent(window,"BX.UserContentView.onClearCall",e.delegate(e.UserContentView.clear,e.UserContentView));e.addCustomEvent("onPullEvent-contentview",function(t,i){if(t=="add"){e.UserContentView.liveUpdate(i)}})})();