Your IP : 18.223.170.69


Current Path : /home/bitrix/ext_www/crm.klimatlend.ua/bitrix/templates/mobile_app/
Upload File :
Current File : /home/bitrix/ext_www/crm.klimatlend.ua/bitrix/templates/mobile_app/im_mobile.min.js

(function(){if(BX.ImLegacy)return;BX.MessengerMobileLegacy=function(){this.notifyLoadFlag=false;this.notifyLastId=0;this.messageCountArray={};this.counterMessages=0;this.counterNotifications=0;this.timeoutUpdateCounters=null;this.timeoutRefreshMessage=null;this.timeoutRefreshNotifications=null;this.timeoutReadMessage=null;this.timeoutUpdateStateLight=null;this.timeoutAnimation=null;this.intervalAnimation=null;this.messageTmpIndex=0;this.sendAjaxTry=0;this.sendMessageFlag=false;this.historyMessage={};this.historyMessageCount=20;this.historyPage=1;this.audio={};this.audio.newMessage=null;this.audio.send=null;this.audio.reminder=null;this.audio.ready=false;this.writing=null;this.writingList={};this.writingListTimeout={};this.writingSendList={};this.writingSendListTimeout={}};BX.MessengerMobileLegacy.prototype.init=function(e){BX.addCustomEvent("onPullError",BX.delegate(function(e){if(e=="AUTHORIZE_ERROR"){app.BasicAuth({success:BX.delegate(function(){setTimeout(BX.delegate(this.updateStateLight,this),1e3)},this)})}},this));BX.addCustomEvent("UIApplicationDidBecomeActiveNotification",BX.delegate(function(e){setTimeout(BX.delegate(this.updateStateLight,this),1e3)},this));BXMobileApp.addCustomEvent("onImError",BX.delegate(function(e){if(e.error=="AUTHORIZE_ERROR"){app.BasicAuth()}else if(e.error=="RECENT_RELOAD"){app.BasicAuth({success:BX.delegate(function(){setTimeout(BX.delegate(this.updateStateLight,this),1e3)},this)})}},this));BX.addCustomEvent("onPullEvent-im",BX.delegate(function(e,t){return false;if(e=="readMessage"){this.messageCountArray[t.userId]=0;this.updateCounters()}else if(e=="readMessageChat"){this.messageCountArray["chat"+t.chatId]=0;this.updateCounters()}else if(e=="chatUserLeave"){if(t.userId==BX.message("USER_ID")){this.messageCountArray["chat"+t.chatId]=0;this.updateCounters()}}else if(e=="readNotify"){this.notifyLastId=parseInt(t.lastId);this.counterNotifications=0;this.updateCounters()}else if(e=="message"||e=="messageChat"){var i=t.MESSAGE.senderId;if(i==BX.message("USER_ID")){this.messageCountArray[t.MESSAGE.recipientId]=0;this.updateCounters();return}if(e=="messageChat")i=t.MESSAGE.recipientId;if(typeof this.messageCountArray[i]!="undefined")this.messageCountArray[i]++;else this.messageCountArray[i]=1;app.getVar({var:"PAGE_ID",from:"current",callback:BX.delegate(function(e){if(e=="DIALOG"+i)this.messageCountArray[i]=0;this.updateCounters()},this)})}else if(e=="notify"){lastId=parseInt(t.id);if(this.notifyLastId<lastId)this.notifyLastId=lastId;this.counterNotifications++;this.updateCounters();if(!this.notifyLoadFlag){clearTimeout(this.notifyTimeout);this.notifyTimeout=setTimeout(BX.delegate(function(){this.notifyLoadFlag=true;app.refreshPanelPage("notifications")},this),600)}}},this));BXMobileApp.addCustomEvent("onNotificationsLastId",BX.delegate(function(e){this.notifyLoadFlag=false;e=parseInt(e);if(this.notifyLastId<e)this.notifyLastId=e},this));BX.addCustomEvent("onDialogOpen",BX.delegate(function(e){this.messageCountArray[e.id]=0;this.updateCounters()},this));app.setPanelPages({messages_page:(BX.message("MobileSiteDir")?BX.message("MobileSiteDir"):"/")+"mobile/im/index.php?NEW",messages_open_empty:true,notifications_page:(BX.message("MobileSiteDir")?BX.message("MobileSiteDir"):"/")+"mobile/im/notify.php",notifications_open_empty:true});this.updateStateLight();this.initAudio()};BX.MessengerMobileLegacy.prototype.openSearch=function(){app.openTable({url:(BX.message("MobileSiteDir")?BX.message("MobileSiteDir"):"/")+"mobile/index.php?mobile_action=get_user_list",callback:function(e){if(!(e&&e.a_users&&e.a_users[0]))return;var t=e.a_users[0];BX.MobileTools.openChat(t["ID"],{name:t["NAME"],description:t["WORK_POSITION"],avatar:t["IMAGE"]})},set_focus_to_search:true,markmode:true,multiple:false,return_full_mode:true,modal:true,alphabet_index:true,outsection:false})};BX.MessengerMobileLegacy.prototype.initAudio=function(){return;if(this.audio.ready)return;this.audio.ready=true;BX.ready(BX.delegate(function(){var e=BX.create("div",{attrs:{style:"display: none"},children:[this.audio.reminder=BX.create("audio",{props:{style:{display:"none"}},children:[BX.create("source",{attrs:{src:"/bitrix/js/im/audio/reminder.ogg",type:"audio/ogg; codecs=vorbis"}}),BX.create("source",{attrs:{src:"/bitrix/js/im/audio/reminder.mp3",type:"audio/mpeg"}})]}),this.audio.newMessage=BX.create("audio",{props:{style:{display:"none"}},children:[BX.create("source",{attrs:{src:"/bitrix/js/im/audio/new-message-2.ogg",type:"audio/ogg; codecs=vorbis"}}),BX.create("source",{attrs:{src:"/bitrix/js/im/audio/new-message-2.mp3",type:"audio/mpeg"}})]}),this.audio.send=BX.create("audio",{props:{style:{display:"none"}},children:[BX.create("source",{attrs:{src:"/bitrix/js/im/audio/send.ogg",type:"audio/ogg; codecs=vorbis"}}),BX.create("source",{attrs:{src:"/bitrix/js/im/audio/send.mp3",type:"audio/mpeg"}})]})]});document.body.insertBefore(e,document.body.firstChild)},this))};BX.MessengerMobileLegacy.prototype.updateCounters=function(){clearTimeout(this.timeoutUpdateCounters);this.timeoutUpdateCounters=setTimeout(BX.delegate(function(){this.counterMessages=0;for(var e in this.messageCountArray)this.counterMessages+=parseInt(this.messageCountArray[e]);app.setBadge(parseInt(this.counterMessages+this.counterNotifications));app.setCounters({messages:this.counterMessages,notifications:this.counterNotifications})},this),500)};BX.MessengerMobileLegacy.prototype.sendMessage=function(e,t){var i=false;if(e.toString().substr(0,4)=="chat"){i=true;var s=e.toString().substr(4);if(parseInt(s)<=0)return false}else{if(parseInt(e)<=0)return false}if(typeof t!="undefined"){t=BX.util.trim(t+"")}else{var a=BX("send-message-input");t=BX.util.trim(a.value);a.value="";a.blur()}if(t.length==0)return false;var n=this.messageTmpIndex;this.drawMessage({id:"temp"+n,senderId:BX.message("USER_ID"),recipientId:e,date:BX.message("IM_MESSENGER_DELIVERED"),text:BX.MessengerMobileLegacy.prepareText(t,true,true)});if(!i)this.endSendWriting(e);this.messageTmpIndex++;this.sendMessageAjax(n,e,t,i);return false};BX.MessengerMobileLegacy.prototype.sendMessageAjax=function(e,t,i,s){BX.addClass(BX("messagetemp"+e,true),"im-block-load");BX("messagetemp"+e,true).appendChild(BX.create("div",{props:{className:"im-message-loading"}}));this.sendMessageFlag=true;BX.ajax({url:"/mobile/ajax.php?mobile_action=im",method:"POST",dataType:"json",data:{IM_SEND_MESSAGE:"Y",CHAT:s?"Y":"N",ID:"temp"+e,RECIPIENT_ID:t,MESSAGE:i,TAB:t,MOBILE:"Y",IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(a){if(typeof a=="undefined")a={ERROR:BX.message("IM_MESSENGER_NOT_DELIVERED")};this.sendMessageFlag=false;BX.removeClass(BX("messagetemp"+e,true),"im-block-load");if(a.ERROR.length==0){this.sendAjaxTry=0;BXMobileApp.onCustomEvent("onMessageAdd",{userId:t,text:a.SEND_MESSAGE},true);var n=BX.findChild(BX("messagetemp"+e),{className:"im-block-text"},true);if(n)n.innerHTML=a.SEND_MESSAGE;var r=BX.findChild(BX("messagetemp"+e),{className:"im-block-info"},true);if(r){r.innerHTML="";r.innerHTML=a.SEND_DATE_FORMAT}BX("messagetemp"+e).setAttribute("id","message"+a.ID)}else if(a.ERROR=="AUTHORIZE_ERROR"&&this.sendAjaxTry<=5){this.sendAjaxTry++;app.BasicAuth({success:BX.delegate(function(){this.sendMessageAjax(e,t,i,s)},this),failture:BX.delegate(function(){setTimeout(BX.delegate(function(){this.sendMessageAjax(e,t,i,s)},this),3e3)},this)})}else if(a.ERROR=="SESSION_ERROR"&&this.sendAjaxTry<=3){this.sendAjaxTry++;BX.message({bitrix_sessid:a.BITRIX_SESSID});setTimeout(BX.delegate(function(){this.sendMessageAjax(e,t,i,s)},this),1e3)}else{BX.addClass(BX("messagetemp"+e,true),"im-undelivered");BX("messagetemp"+e,true).appendChild(BX.create("div",{props:{className:"im-undelivered-message-icon"}}));var o=a.ERROR;if(a.ERROR=="SESSION_ERROR"||a.ERROR=="AUTHORIZE_ERROR"||a.ERROR=="UNKNOWN_ERROR"||a.ERROR=="IM_MODULE_NOT_INSTALLED")o=BX.message("IM_MESSENGER_NOT_DELIVERED");var d=BX.create("div",{props:{className:"im-undelivered-btn-block"},children:[BX.create("input",{attrs:{type:"button",value:BX.message("IM_MESSENGER_ND_RETRY")},props:{className:"im-undelivered-btn"},events:{touchend:BX.delegate(function(){BX.proxy_context.classList.remove("im-undelivered-btn-press");BX.removeClass(BX("messagetemp"+e,true),"im-undelivered");BX.remove(BX.proxy_context.parentNode);var a=BX.findChild(BX("messagetemp"+e,true),{className:"im-undelivered-message-icon"},true);if(a){BX.remove(a)}this.sendAjaxTry=0;this.sendMessageAjax(e,t,i,s)},this),touchstart:function(){this.classList.add("im-undelivered-btn-press")}}}),BX.create("span",{props:{className:"im-undelivered-text"},html:o})]});BX("im-blocks",true).insertBefore(d,BX("messagetemp"+e,true).nextSibling);this.sendAjaxTry=0;var r=BX.findChild(BX("messagetemp"+e,true),{className:"im-block-info"},true);if(r){r.innerHTML="";r.innerHTML=BX.MessengerMobileLegacy.formatDate(BX.MessengerMobileLegacy.getNowDate())}}},this),onfailure:BX.delegate(function(){BX.addClass(BX("messagetemp"+e,true),"im-undelivered");BX("messagetemp"+e,true).appendChild(BX.create("div",{props:{className:"im-undelivered-message-icon"}}));var a=BX.message("IM_MESSENGER_NOT_DELIVERED");var n=BX.create("div",{props:{className:"im-undelivered-btn-block"},children:[BX.create("input",{attrs:{type:"button",value:BX.message("IM_MESSENGER_ND_RETRY")},props:{className:"im-undelivered-btn"},events:{touchend:BX.delegate(function(){BX.proxy_context.classList.remove("im-undelivered-btn-press");BX.removeClass(BX("messagetemp"+e,true),"im-undelivered");BX.remove(BX.proxy_context.parentNode);var a=BX.findChild(BX("messagetemp"+e,true),{className:"im-undelivered-message-icon"},true);if(a){BX.remove(a)}this.sendAjaxTry=0;this.sendMessageAjax(e,t,i,s)},this),touchstart:function(){this.classList.add("im-undelivered-btn-press")}}}),BX.create("span",{props:{className:"im-undelivered-text"},html:a})]});BX("im-blocks",true).insertBefore(n,BX("messagetemp"+e,true).nextSibling);this.sendAjaxTry=0;var r=BX.findChild(BX("messagetemp"+e,true),{className:"im-block-info"},true);if(r){r.innerHTML="";r.innerHTML=BX.MessengerMobileLegacy.formatDate(BX.MessengerMobileLegacy.getNowDate())}},this)})};BX.MessengerMobileLegacy.prototype.drawMessage=function(e,t){t=t==true?true:false;if(typeof USER==undefined){alert("ERROR: Array USER undefined!");return false}e.text=e.text.replace(/\[USER=([0-9]{1,})\](.*?)\[\/USER\]/gi,'<a href="/mobile/users/?user_id=$1&FROM_DIALOG=Y">$2</a>');e.text=e.text.replace(/\[PCH=([0-9]{1,})\](.*?)\[\/PCH\]/gi,"$2");var i="";if(e.params&&e.params.FILE_ID){for(var s=0;s<e.params.FILE_ID.length;s++){var a=e.files[e.params.FILE_ID[s]];if(!a)continue;if(a["urlPreview"]&&a["urlShow"]){a["name"]='<a href="'+a["urlShow"]+'">'+a["name"]+"</a>"}i=i+'<div id="im-file-'+a["id"]+'">'+a["name"]+"</div>"}if(i){i='<div class="im-block-text-files"><div class="im-block-text-title">'+BX.message("IM_FILES")+":</div>"+i+"</div>"}}if(e.senderId==0||e.system=="Y"){var n=BX.create("div",{attrs:{id:"message"+e.id},props:{className:"im-block im-block-in im-block-system"},html:'<div class="im-block-cont">\t\t\t\t\t\t\t<div class="im-block-title"></div>\t\t\t\t\t\t\t<div class="im-block-text" id="messageText'+e.id+'">'+e.text+'</div>\t\t\t\t\t\t\t<div class="im-block-info">'+(parseInt(e.date)>0?BX.MessengerMobileLegacy.formatDate(e.date):e.date)+"</div>\t\t\t\t\t\t</div>"})}else{var n=BX.create("div",{attrs:{id:"message"+e.id},props:{className:"im-block im-block-"+(e.senderId==BX.message("USER_ID")?"out":"in")},html:'<div class="ml-avatar"><div class="ml-avatar-sub" style="background-image:url(\''+USERS[e.senderId]["avatar"]+'\'); background-size:cover;"></div></div>\t\t\t\t\t\t\t<div class="im-block-cont">\t\t\t\t\t\t\t<div class="im-block-title">'+USERS[e.senderId]["name"]+'</div>\t\t\t\t\t\t\t<div class="im-block-text" id="messageText'+e.id+'">'+e.text+"</div>\t\t\t\t\t\t\t"+i+'\t\t\t\t\t\t\t<div class="im-block-info">'+(parseInt(e.date)>0?BX.MessengerMobileLegacy.formatDate(e.date):e.date)+"</div>\t\t\t\t\t\t</div>"})}var r=BX("im-block-empty");if(r!=null){BX.remove(r)}var o=BX("im-blocks",true);if(t){if(o.firstChild)o.insertBefore(n,o.firstChild);else o.insertBefore(n,this.writing)}else{o.insertBefore(n,this.writing);clearTimeout(this.timeoutAnimation);this.timeoutAnimation=setTimeout(function(){clearInterval(this.intervalAnimation);if(window.platform=="android"){var e=document.body.scrollHeight-document.body.offsetHeight}else{var t=document.body.scrollTop;document.body.scrollTop=document.body.offsetHeight;var e=document.body.scrollTop;document.body.scrollTop=t}this.intervalAnimation=BitrixAnimation.animate({duration:1e3,start:{scroll:document.body.scrollTop},finish:{scroll:e},transition:BitrixAnimation.makeEaseOut(BitrixAnimation.transitions.quart),step:function(e){document.body.scrollTop=e.scroll},complete:function(){}})},200)}if(BX.hasClass(this.writing,"im-block-writing-read")){DIALOG_LAST_READ="";BX.removeClass(this.writing,"im-block-writing-read");this.writing.innerHTML=DIALOG_LAST_READ}return n.offsetHeight+20};BX.MessengerMobileLegacy.prototype.readMessage=function(e,t){t=parseInt(t)>0?parseInt(t):"N";clearTimeout(this.timeoutReadMessage);this.timeoutReadMessage=setTimeout(function(){BX.ajax({url:"/mobile/ajax.php?mobile_action=im",method:"POST",dataType:"json",data:{IM_READ_MESSAGE:"Y",USER_ID:e,LAST_ID:t,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(i){if(i.ERROR.length==0){this.sendAjaxTry=0}else if(i.ERROR=="AUTHORIZE_ERROR"&&this.sendAjaxTry<=3){this.sendAjaxTry++;BXMobileApp.onCustomEvent("onImError",{error:i.ERROR},true);setTimeout(BX.delegate(function(){this.readMessage(e,t)},this),2e3)}else if(i.ERROR=="SESSION_ERROR"&&this.sendAjaxTry<=3){this.sendAjaxTry++;BX.message({bitrix_sessid:i.BITRIX_SESSID});setTimeout(BX.delegate(function(){this.readMessage(e,t)},this),1e3)}else{this.sendAjaxTry=0}},this),onfailure:BX.delegate(function(e){this.sendAjaxTry=0},this)})},500)};BX.MessengerMobileLegacy.prototype.confirmRequest=function(e){BX.ajax({url:"/mobile/ajax.php?mobile_action=im",method:"POST",dataType:"json",timeout:30,data:{IM_NOTIFY_CONFIRM:"Y",NOTIFY_ID:e.notifyId,NOTIFY_VALUE:e.notifyValue,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()}});return false};BX.MessengerMobileLegacy.prototype.updateStateLight=function(){clearTimeout(this.timeoutUpdateStateLight);this.timeoutUpdateStateLight=setTimeout(BX.delegate(function(){BX.ajax({url:"/mobile/ajax.php?mobile_action=im",method:"POST",dataType:"json",timeout:20,data:{IM_UPDATE_STATE_LIGHT:"Y",MOBILE:"Y",SITE_ID:BX.message("SITE_ID"),NOTIFY:"Y",MESSAGE:"Y",IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(e){if(e.ERROR.length==0){if(BX.PULL&&e.PULL_CONFIG){BX.PULL.updateChannelID({METHOD:e.PULL_CONFIG.METHOD,CHANNEL_ID:e.PULL_CONFIG.CHANNEL_ID,CHANNEL_DT:e.PULL_CONFIG.CHANNEL_DT,PATH:e.PULL_CONFIG.PATH,LAST_ID:e.PULL_CONFIG.LAST_ID,PATH_WS:e.PULL_CONFIG.PATH_WS})}if(e.COUNTER_MESSAGES)this.counterMessages=parseInt(e.COUNTER_MESSAGES);if(e.COUNTER_NOTIFICATIONS)this.counterNotifications=parseInt(e.COUNTER_NOTIFICATIONS);if(e.NOTIFY_LAST_ID)this.notifyLastId=parseInt(e.NOTIFY_LAST_ID);if(this.counterMessages>0&&e.COUNTER_UNREAD_MESSAGES&&typeof e.COUNTER_UNREAD_MESSAGES=="object"){this.counterMessages=0;this.messageCountArray={};for(var t in e.COUNTER_UNREAD_MESSAGES){this.counterMessages+=e.COUNTER_UNREAD_MESSAGES[t].MESSAGE.counter;this.messageCountArray[t]=e.COUNTER_UNREAD_MESSAGES[t].MESSAGE.counter}BXMobileApp.onCustomEvent("onUpdateUserCounters",e.COUNTER_UNREAD_MESSAGES,true)}else{this.messageCountArray={};BXMobileApp.onCustomEvent("onUpdateUserCounters",e.COUNTER_UNREAD_MESSAGES,true)}this.updateCounters();if(e.COUNTERS&&typeof e.COUNTERS=="object")BXMobileApp.onCustomEvent("onUpdateSocnetCounters",e.COUNTERS,true);if(this.counterNotifications>0&&!this.notifyLoadFlag){clearTimeout(this.notifyTimeout);this.notifyTimeout=setTimeout(BX.delegate(function(){this.notifyLoadFlag=true;app.refreshPanelPage("notifications")},this),600)}this.sendAjaxTry=0;clearTimeout(this.timeoutUpdateStateLight);this.timeoutUpdateStateLight=setTimeout(BX.delegate(function(){this.updateStateLight()},this),8e4)}else if(e.ERROR=="AUTHORIZE_ERROR"&&this.sendAjaxTry<=3){this.sendAjaxTry++;BXMobileApp.onCustomEvent("onImError",{error:e.ERROR},true);clearTimeout(this.timeoutUpdateStateLight);this.timeoutUpdateStateLight=setTimeout(BX.delegate(function(){this.updateStateLight()},this),2e3)}else if(e.ERROR=="SESSION_ERROR"&&this.sendAjaxTry<=3){this.sendAjaxTry++;BX.message({bitrix_sessid:e.BITRIX_SESSID});clearTimeout(this.timeoutUpdateStateLight);this.timeoutUpdateStateLight=setTimeout(BX.delegate(function(){this.updateStateLight()},this),1e3)}else{this.sendAjaxTry=0}},this),onfailure:BX.delegate(function(e){this.sendAjaxTry=0},this)})},this),300)};BX.MessengerMobileLegacy.prototype.getHistory=function(e){this.historyPage=Math.floor(this.historyMessageCount/20)+1;BX.ajax({url:"/mobile/ajax.php?mobile_action=im",method:"POST",dataType:"json",data:{IM_HISTORY_LOAD_MORE:"Y",USER_ID:e,PAGE_ID:this.historyPage,MOBILE:"Y",IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(e){var t=0;var i=0;var s=0;var a=[];var n=[];for(var r in e.MESSAGE){if(this.historyMessage[e.MESSAGE[r].id])continue;e.MESSAGE[r].date=parseInt(e.MESSAGE[r].date)+parseInt(BX.message("USER_TZ_OFFSET"));e.MESSAGE[r].text=BX.MessengerMobileLegacy.prepareText(e.MESSAGE[r].text,false,true);a.push(e.MESSAGE[r]);n.push(e.MESSAGE[r])}n.sort(function(e,t){e=e.id;t=t.id;if(e<t){return 1}else if(e>t){return-1}else{return 0}});for(var r=0;r<n.length;r++){i+=this.drawMessage(n[r],true);if(s==0)s=i;this.historyMessage[n[r].id]=true;this.historyMessageCount++;t++}app.pullDownLoadingStop();document.body.scrollTop=i+20;clearInterval(this.intervalAnimation);this.intervalAnimation=BitrixAnimation.animate({duration:1500,start:{scroll:document.body.scrollTop},finish:{scroll:i-s},transition:BitrixAnimation.makeEaseOut(BitrixAnimation.transitions.quart),step:function(e){document.body.scrollTop=e.scroll},complete:function(){}});if(t<20){app.pullDown({enable:false});return}},this),onfailure:function(e){app.pullDownLoadingStop()}})};BX.MessengerMobileLegacy.getNowDate=function(e){var t=new Date;if(e==true)t=new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0);return Math.round(+t/1e3)+parseInt(BX.message("SERVER_TZ_OFFSET"))+parseInt(BX.message("USER_TZ_OFFSET"))};BX.MessengerMobileLegacy.formatDate=function(e){var t=[["tommorow",BX.message("IM_FORMAT_DATETIME_TOMMOROW")],["today",BX.message("IM_FORMAT_DATETIME_TODAY")],["yesterday",BX.message("IM_FORMAT_DATETIME_YESTERDAY")],["",BX.date.convertBitrixFormat(BX.message("IM_FORMAT_DATETIME"))]];return BX.date.format(t,parseInt(e)+parseInt(BX.message("SERVER_TZ_OFFSET")),BX.MessengerMobileLegacy.getNowDate(),true)};BX.MessengerMobileLegacy.prepareText=function(e,t,i){t=t==true?true:false;i=i==true?true:false;e=BX.util.trim(e);if(t)e=BX.util.htmlspecialchars(e);if(i){e=e.replace(/------------------------------------------------------<br \/>(.*?)\[(.*?)\]<br \/>(.*?)------------------------------------------------------(<br \/>)?/g,'<div class="bx-messenger-content-quote"><span class="bx-messenger-content-quote-icon"></span><div class="bx-messenger-content-quote-wrap"><div class="bx-messenger-content-quote-name">$1 <span class="bx-messenger-content-quote-time">$2</span></div>$3</div></div>');e=e.replace(/------------------------------------------------------<br \/>(.*?)<br \/>------------------------------------------------------(<br \/>)?/g,'<div class="bx-messenger-content-quote"><span class="bx-messenger-content-quote-icon"></span><div class="bx-messenger-content-quote-wrap">$1</div></div>')}if(t)e=e.replace(/\n/gi,"<br />");e=e.replace(/\t/gi,"&nbsp;&nbsp;&nbsp;&nbsp;");return e};BX.MessengerMobileLegacy.prototype.drawReadMessage=function(e,t,i){DIALOG_LAST_READ=BX.message("IM_MESSENGER_READED").replace("#DATE#",BX.MessengerMobileLegacy.formatDate(i));if(!this.writingList[e]&&DIALOG_ID==e){this.showReadMessage()}};BX.MessengerMobileLegacy.prototype.showReadMessage=function(){if(DIALOG_LAST_READ==""){BX.removeClass(this.writing,"im-block-writing-read")}else{BX.addClass(this.writing,"im-block-writing-read")}this.writing.innerHTML=DIALOG_LAST_READ};BX.MessengerMobileLegacy.prototype.startWriting=function(e){this.writingList[e]=true;this.drawWriting(e);clearTimeout(this.writingListTimeout[e]);this.writingListTimeout[e]=setTimeout(BX.delegate(function(){this.endWriting(e)},this),3e4)};BX.MessengerMobileLegacy.prototype.drawWriting=function(e){if(this.writingList[e]&&DIALOG_ID==e){BX.removeClass(this.writing,"im-block-writing-read");BX.addClass(this.writing,"im-block-writing-write");this.writing.innerHTML=BX.message("IM_MESSENGER_WRITING").replace("#USER_NAME#","<b>"+USERS[e].name+"</b>")}else if(!this.writingList[e]&&DIALOG_ID==e){BX.removeClass(this.writing,"im-block-writing-write");this.writing.innerHTML="";this.showReadMessage()}};BX.MessengerMobileLegacy.prototype.endWriting=function(e,t){t=t==true?true:false;clearTimeout(this.writingListTimeout[e]);this.writingList[e]=false;this.drawWriting(e);if(t){BX.removeClass(this.writing,"im-block-writing-write");this.showReadMessage()}};BX.MessengerMobileLegacy.prototype.sendWriting=function(e){if(parseInt(e)>0&&!this.writingSendList[e]){clearTimeout(this.writingSendListTimeout[e]);this.writingSendList[e]=true;BX.ajax({url:"/mobile/ajax.php?mobile_action=im",method:"POST",dataType:"json",data:{IM_START_WRITING:"Y",DIALOG_ID:DIALOG_ID,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()}});this.writingSendListTimeout[e]=setTimeout(BX.delegate(function(){this.endSendWriting(e)},this),3e4)}};BX.MessengerMobileLegacy.prototype.endSendWriting=function(e){if(parseInt(e)<=0)return false;clearTimeout(this.writingSendListTimeout[e]);this.writingSendList[e]=false};BX.MessengerMobileLegacy.prototype.leaveFromChat=function(e){BX.ajax({url:"/mobile/ajax.php?mobile_action=im",method:"POST",dataType:"json",timeout:60,data:{IM_CHAT_LEAVE:"Y",CHAT_ID:e,IM_AJAX_CALL:"Y",sessid:BX.bitrix_sessid()},onsuccess:function(e){if(e.ERROR==""){app.closeController()}}})};BX.MessengerMobileLegacy.prototype.autoScroll=function(){if(document.body.scrollHeight<=window.innerHeight)return false;clearInterval(this.intervalAnimation);this.intervalAnimation=BitrixAnimation.animate({duration:1e3,start:{scroll:document.body.scrollTop},finish:{scroll:document.body.scrollHeight},transition:BitrixAnimation.makeEaseOut(BitrixAnimation.transitions.quart),step:function(e){document.body.scrollTop=e.scroll},complete:function(){}})};BX.ImLegacy=new BX.MessengerMobileLegacy;window.BX.ImLegacy=BX.ImLegacy})();