Your IP : 18.216.81.181


Current Path : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/im/
Upload File :
Current File : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/im/desktop.min.js

(function(e){if(e.BX.desktop)return;var t=e.BX;var o=function(){this.apiReady=typeof BXDesktopSystem!="undefined"||typeof BXDesktopWindow!="undefined";this.clientVersion=0;this.disableLogin=false;this.autorun=null;this.lastSetIcon=null;this.showNotifyId={};this.htmlWrapperHead=null;this.topmostWindow=null;this.topmostWindowTimeout=null;this.path={};this.path.mainUserOptions="/desktop_app/options.ajax.php";this.path.pathToAjax="/desktop_app/im.ajax.php";this.path.pathToPull="/desktop_app/pull.ajax.php";this.tabItems={};this.tabRedrawTimeout=null;this.syncStatus=null;this.syncPauseBlock=false;this.inited=false;this.sizeInited=false;this.minWidth=515;this.minHeight=384;this.timeoutDelayOfLogout=null;this.eventHandlers={};this.addCustomEvent("bxImLogoutInit",t.delegate(function(e,t){this.logout(e,t,true)},this));t.bind(e,"keydown",t.delegate(function(e){if(e.keyCode==82&&(e.ctrlKey==true||e.metaKey==true)){if(e.shiftKey==true&&typeof BXIM!="undefined"){BXIM.setLocalConfig("global_msz_v2",false);t.desktop.apiReady=false;console.log("NOTICE: User use /windowReload + /clearWindowSize")}else{console.log("NOTICE: User use /windowReload")}this.windowReload()}else if(e.keyCode==68&&(e.ctrlKey==true||e.metaKey==true)&&e.shiftKey==true){this.openDeveloperTools();console.log("NOTICE: User use /openDeveloperTools")}else if(e.keyCode==76&&(e.ctrlKey==true||e.metaKey==true)&&e.shiftKey==true){this.openLogsFolder();console.log("NOTICE: User use /openLogsFolder")}},this))};o.prototype.init=function(o){o=o||{};if(this.inited){return true}this.inited=true;this.setWindowResizable(true);this.setWindowMinSize({Width:t.MessengerWindow.minWidth,Height:t.MessengerWindow.minHeight});if(this.ready()){console.log(t.message("BXD_DEFAULT_TITLE").replace("#VERSION#",this.getApiVersion(true)));t.debugEnable(true)}if(!t.browser.IsMac()&&document.head)document.head.insertBefore(t.create("style",{attrs:{type:"text/css"},html:"@font-face { font-family: 'helvetica neue'; src: local('Arial'); } @font-face { font-family: 'Helvetica'; src: local('Arial'); }"}),document.head.firstChild);if(this.ready()){t.ready(function(){t.addClass(document.body,"bx-desktop")})}else{t.ready(function(){t.addClass(document.body,"im-desktop-content")})}t.addCustomEvent("onMessengerWindowInit",t.delegate(function(){this.userInfo=t.MessengerWindow.getUserInfo();this.contentMenu=t.MessengerWindow.contentMenu;this.content=t.MessengerWindow.content;t.onCustomEvent(e,"onDesktopInit",[this]);t.desktop.onCustomEvent("onDesktopInit",[this])},this));t.addCustomEvent("onPullRevisionUp",function(e,o){t.PULL.closeConfirm();console.log("NOTICE: Window reload, becouse PULL REVISION UP ("+o+" -> "+e+")");location.reload()});t.addCustomEvent("onPullError",t.delegate(function(e,o){if(e=="AUTHORIZE_ERROR"){this.setIconStatus("offline");this.login(function(){console.log("DESKTOP LOGIN: success after PullError");t.PULL.setPrivateVar("_pullTryConnect",true);t.PULL.updateState("13",true)})}else if(e=="RECONNECT"){this.setIconStatus("offline")}},this));t.addCustomEvent("onImError",t.delegate(function(e,o){if(e=="AUTHORIZE_ERROR"||e=="SEND_ERROR"&&o=="AUTHORIZE_ERROR"){this.setIconStatus("offline");this.login(t.delegate(function(){this.setIconStatus("online");var e="DESKTOP LOGIN: success after ImError";console.log(e);if(typeof BXIM!="undefined"){t.desktop.log("phone."+BXIM.userEmail+".log",e);BXIM.messenger.connectionStatus("online",false)}},this))}else if(e=="CONNECT_ERROR"){this.setIconStatus("offline")}},this));if(this.ready()){t.userOptions.setAjaxPath(this.path.mainUserOptions);t.addCustomEvent("onPullStatus",t.delegate(function(e){if(e=="offline")this.setIconStatus("offline");else this.setIconStatus(BXIM&&BXIM.settings?BXIM.settings.status:"online")},this));t.bind(e,"online",t.delegate(function(){this.setIconStatus(BXIM&&BXIM.settings?BXIM.settings.status:"online")},this));t.bind(e,"offline",t.delegate(function(){this.setIconStatus("offline")},this));this.addCustomEvent("BXWakeAction",t.delegate(function(){this.setIconStatus(BXIM&&BXIM.settings?BXIM.settings.status:"online")},this));this.addCustomEvent("BXSleepAction",t.delegate(function(){this.setIconStatus("offline")},this));this.addCustomEvent("BXExitApplication",t.delegate(function(){this.preventShutdown();this.logout(true,"exit_event")},this))}this.addCustomEvent("BXChangeTab",t.delegate(function(e){this.changeTab(e)},this));this.addCustomEvent("BXTrayConstructMenu",t.delegate(function(){this.onCustomEvent("main","BXTrayMenu",[]);setTimeout(function(){t.desktop.finalizeTrayMenu()})},this));this.addCustomEvent("BXFileStorageSyncPauseChanged",t.delegate(this.onSyncStatusChanged,this))};o.prototype.notSupported=function(){this.setWindowMinSize({Width:864,Height:493});this.setWindowSize({Width:864,Height:493});this.setWindowResizable(false);this.setWindowTitle(t.message("BXD_DEFAULT_TITLE").replace("#VERSION#",this.getApiVersion(true)));var o=t.create("div",{props:{className:"bx-desktop-update-box"},children:[t.create("div",{props:{className:"bx-desktop-update-box-text"},html:t.message("BXD_NEED_UPDATE")}),t.create("div",{props:{className:"bx-desktop-update-box-btn"},events:{click:t.delegate(function(){this.checkUpdate(true)},this)},html:t.message("BXD_NEED_UPDATE_BTN")})]});t.ready(function(){document.body.innerHTML="";document.body.appendChild(o);t.onCustomEvent(e,"onDesktopOutdated",[this])})};o.prototype.getCurrentUrl=function(){return document.location.protocol+"//"+document.location.hostname+(document.location.port==""?"":":"+document.location.port)};o.prototype.ready=function(){return this.apiReady};o.prototype.diskReady=function(){return this.apiReady&&typeof BXFileStorage!="undefined"};o.prototype.login=function(e){if(this.disableLogin){console.log("DESKTOP LOGIN: command was disabled");return false}var o="DESKTOP LOGIN: try to login";console.log(o);if(typeof BXIM!="undefined"){t.desktop.log("phone."+BXIM.userEmail+".log",o)}if(!this.ready()){this.windowReload();return false}var n={};if(typeof e=="function"){n.success=t.delegate(function(o){if(typeof o=="string"){t.message({bitrix_sessid:o})}e(o);this.onCustomEvent("main","BXLoginSuccess",[o])},this)}else{n.success=t.delegate(this.loginSuccessCallback,this)}BXDesktopSystem.Login(n);return true};o.prototype.loginSuccessCallback=function(e){if(typeof e=="string"){t.message({bitrix_sessid:e})}if(!this.ready())return false;this.windowReload();return true};o.prototype.showLoginForm=function(){BXDesktopSystem.Logout(1,"login_form")};o.prototype.windowReload=function(){location.reload()};o.prototype.logout=function(e,o,n){e=e==true;this.apiReady=false;t.ajax({url:this.path.pathToAjax+"?DESKTOP_LOGOUT",method:"POST",dataType:"json",timeout:30,data:{IM_DESKTOP_LOGOUT:"Y",sessid:t.bitrix_sessid()},onsuccess:t.delegate(function(){if(o)console.log("Logout reason: "+o);if(e)BXDesktopSystem.Shutdown();else BXDesktopSystem.Logout(2)},this),onfailure:t.delegate(function(){if(o)console.log("Logout reason (fail): "+o);if(e)BXDesktopSystem.Shutdown();else BXDesktopSystem.Logout(3)},this)});return true};o.prototype.checkUpdate=function(e){if(typeof BXDesktopSystem=="undefined")return false;e=typeof e!="boolean"?false:e;if(!e&&this.enableInVersion(16))BXDesktopSystem.ExecuteCommand("update.check",{NotifyNoUpdates:true,ShowNotifications:true});else this.browse(t.browser.IsMac()?"http://dl.bitrix24.com/b24/bitrix24_desktop.dmg":"http://dl.bitrix24.com/b24/bitrix24_desktop.exe","desktopApp");return true};o.prototype.getApiVersion=function(e){if(typeof BXDesktopSystem=="undefined")return 0;if(!this.clientVersion)this.clientVersion=BXDesktopSystem.GetProperty("versionParts");return e?this.clientVersion.join("."):this.clientVersion[3]};o.prototype.enableInVersion=function(e){if(typeof BXDesktopSystem=="undefined")return false;return this.getApiVersion()>=parseInt(e)};o.prototype.addCustomEvent=function(t,o){if(!this.ready())return false;var n=function(t){var n=[];for(var i in t.detail)n.push(t.detail[i]);o.apply(e,n)};if(!this.eventHandlers[t])this.eventHandlers[t]=[];this.eventHandlers[t].push(n);e.addEventListener(t,n);return true};o.prototype.removeCustomEvents=function(t){if(!this.eventHandlers[t])return false;this.eventHandlers[t].forEach(function(o){e.removeEventListener(t,o)});this.eventHandlers[t]=[]};o.prototype.onCustomEvent=function(e,t,o){if(!this.ready())return false;if(arguments.length==2){o=t;t=e;e="all"}else if(arguments.length<2){return false}var n={};for(var i=0;i<o.length;i++)n[i]=o[i];if(e=="all"){var s=opener?opener:top;for(var i=0;i<s.BXWindows.length;i++){if(s.BXWindows[i]&&s.BXWindows[i].name!=""&&s.BXWindows[i].BXDesktopWindow&&s.BXWindows[i].BXDesktopWindow.DispatchCustomEvent)s.BXWindows[i].BXDesktopWindow.DispatchCustomEvent(t,n)}s.BXDesktopWindow.DispatchCustomEvent(t,n)}else{if(e=this.findWindow(e))e.DispatchCustomEvent(t,n)}return true};o.prototype.findWindow=function(e){if(!this.ready())return null;if(typeof e=="undefined")e="main";var t=opener?opener:top;if(e=="main"){return t.BXDesktopWindow}else{for(var o=0;o<t.BXWindows.length;o++){if(t.BXWindows[o].name===e)return t.BXWindows[o].BXDesktopWindow}}return null};o.prototype.windowIsFocused=function(){if(!this.ready())return false;return BXDesktopWindow.GetProperty("isForeground")};o.prototype.setIconStatus=function(e){if(!this.ready())return false;if(this.lastSetIcon==e)return false;this.lastSetIcon=e;BXDesktopSystem.SetIconStatus(e);return true};o.prototype.setIconBadge=function(e,t){if(!this.ready())return false;t=t===true;if(this.isActiveWindow()){BXDesktopSystem.SetIconBadge(e+"",t)}return true};o.prototype.setIconTooltip=function(e){if(!this.ready())return false;return BXDesktopSystem.ExecuteCommand("tooltip.change",e)};o.prototype.setWindowResizable=function(e){if(!this.ready())return false;BXDesktopWindow.SetProperty("resizable",e!==false);return false};o.prototype.setWindowClosable=function(e){if(!this.ready())return false;BXDesktopWindow.SetProperty("closable",e!==false);return false};o.prototype.flashIcon=function(e){if(!this.ready())return false;BXDesktopSystem.FlashIcon(e==true);return true};o.prototype.getWorkArea=function(){if(!this.ready())return false;var e=BXDesktopSystem.GetWorkArea();return{top:e[0],left:e[1],right:e[2],bottom:e[3]}};o.prototype.showNotification=function(e,t,o){if(!this.ready()||t=="")return false;if(this.showNotifyId[e])return false;this.showNotifyId[e]=true;BXDesktopSystem.ExecuteCommand("notification.show.html",this.getHtmlPage(t,o,"desktop-notify-popup"));return true};o.prototype.adjustSize=function(e,o){return t.MessengerWindow.adjustSize(e,o)};o.prototype.resize=function(){if(!this.ready())return false;BXDesktopWindow.SetProperty("clientSize",{Width:document.body.offsetWidth,Height:document.body.offsetHeight});return true};o.prototype.syncPause=function(o,n){if(!this.diskReady())return false;if(n){this.syncPauseBlock=o}if(!this.syncPauseBlock||this.syncPauseBlock&&n){this.syncStatus=!o;BXFileStorage.SyncPause(!this.syncStatus);t.onCustomEvent(e,"onDesktopSyncPause",[this.syncStatus])}return true};o.prototype.onSyncStatusChanged=function(e){this.syncPause(e,true)};o.prototype.getSyncStatus=function(){return this.syncStatus};o.prototype.windowCommand=function(o,n){if(!this.ready())return false;if(arguments.length==1){n=o;o=e}if(n=="show"&&o==e){t.desktop.setActiveWindow()}try{if(n=="show"||n=="hide"||n=="focus"||n=="freeze"||n=="unfreeze"){o.BXDesktopWindow.ExecuteCommand(n)}else if(n=="close"){if(o.opener){if(o.name.indexOf("topmost")>=0||o.name.indexOf("notif")>=0){o.BXDesktopWindow.ExecuteCommand("close")}else{o.close()}}else{o.BXDesktopWindow.ExecuteCommand("hide")}}}catch(e){console.log("ExecuteCommand Error",n,o,e);console.trace()}return true};o.prototype.openTopmostWindow=function(e,t,o){if(!this.ready())return false;this.closeTopmostWindow();this.topmostWindow=BXDesktopSystem.ExecuteCommand("topmost.show.html",this.getHtmlPage(e,t,o));return true};o.prototype.closeTopmostWindow=function(){if(this.topmostWindow){this.windowCommand(this.topmostWindow,"close");this.topmostWindow=null}return true};o.prototype.getHtmlPage=function(e,o,n){if(!this.ready())return;e=e||"";o=o||"";n=n||"";if(this.htmlWrapperHead==null)this.htmlWrapperHead=document.head.outerHTML.replace(/BX\.PULL\.start\([^)]*\);/g,"");if(e!=""&&t.type.isDomNode(e))e=e.outerHTML;if(o!=""&&t.type.isDomNode(o))o=o.outerHTML;if(o!="")o='<script type="text/javascript">BX.ready(function(){'+o+"});<\/script>";return"<!DOCTYPE html><html>"+this.htmlWrapperHead+'<body class="im-desktop im-desktop-popup '+n+'">'+e+o+"</body></html>"};o.prototype.openDeveloperTools=function(){if(typeof BXDesktopWindow=="undefined")return false;BXDesktopWindow.OpenDeveloperTools();return true};o.prototype.openLogsFolder=function(){if(!this.ready())return false;BXDesktopSystem.OpenLogsFolder();return true};o.prototype.browse=function(e){if(typeof BXDesktopSystem=="undefined")return false;BXDesktopSystem.ExecuteCommand("browse",e);return true};o.prototype.autorunStatus=function(e){if(!this.ready())return false;if(typeof e!="boolean"){if(this.autorun==null)this.autorun=BXDesktopSystem.GetProperty("autostart")}else{this.autorun=e;BXDesktopSystem.SetProperty("autostart",this.autorun)}return this.autorun};o.prototype.diskAttachStatus=function(){if(!this.ready())return false;return BitrixDisk?BitrixDisk.enabled:false};o.prototype.clipboardSelected=function(o,n){n=n||false;var i="";var s=0;var r=0;if(typeof o=="object"&&(o.tagName=="TEXTAREA"||o.tagName=="INPUT")){s=o.selectionStart;r=o.selectionEnd;i=o.value.substring(s,r);if(n){if(i&&i.indexOf(" ")>-1){i=""}else{var a=o.value.substr(0,s).search(/([-'`~!@#$%^&*()_|+=?;:'",.<>\{\}\[\]\\\/\x20])(?!.*[-'`~!@#$%^&*()_|+=?;:'",.<>\{\}\[\]\\\/\x20])/)+1;var u=o.value.substr(a).search(/[-'`~!@#$%^&*()_|+=?;:'",.<>\{\}\[\]\\\/\x20]/);u=u>0?u:o.value.length;i=o.value.substr(a,u);s=a;r=a+u}}}else{if(!n&&e.getSelection().toString().length>0){var d=e.getSelection().getRangeAt(0).cloneContents();var p=document.createElement("div");p.appendChild(d);i=p.innerHTML}}if(i.length>0){i=t.util.htmlspecialcharsback(i);i=i.split("&nbsp;&nbsp;&nbsp;&nbsp;").join("\t");i=i.replace(/<img.*?data-code="([^"]*)".*?>/gi,"$1");i=i.replace(/&nbsp;/gi," ").replace(/&copy;/,"(c)");i=i.replace(/<div class=\"bx-messenger-hr\"><\/div>/gi,"\n");i=i.replace(/<span class=\"bx-messenger-clear\"><\/span>/gi,"\n");i=i.replace(/<s>([^"]*)<\/s>/gi,"");i=i.replace(/<(\/*)([buis]+)>/gi,"[$1$2]");i=i.replace(/<a.*?href="([^"]*)".*?>.*?<\/a>/gi,"$1");i=i.replace(/------------------------------------------------------(.*?)------------------------------------------------------/gim,"["+t.message("BXD_QUOTE_BLOCK")+"]");i=i.replace("<br />","\n").replace(/<\/?[^>]+>/gi,"")}return{text:i,selectionStart:s,selectionEnd:r}};o.prototype.clipboardCopy=function(e,o){if(!this.ready())return false;document.execCommand(o==true?"cut":"copy");var n=t.create("textarea",{style:{position:"absolute",opacity:0,top:-1e3,left:-1e3}});document.body.insertBefore(n,document.body.firstChild);n.focus();document.execCommand("paste");var i=n.value;if(typeof e=="function"){var s=e(n.value);if(typeof s!="undefined")i=n.value=s;n.selectionStart=0;document.execCommand("copy")}t.remove(n);return i};o.prototype.clipboardCut=function(){return this.clipboardCopy(null,true)};o.prototype.clipboardPaste=function(){if(!this.ready())return false;document.execCommand("paste");return true};o.prototype.clipboardDelete=function(){if(!this.ready())return false;document.execCommand("delete");return true};o.prototype.clipboardUndo=function(){if(!this.ready())return false;document.execCommand("undo");return true};o.prototype.clipboardRedo=function(){if(!this.ready())return false;document.execCommand("redo");return true};o.prototype.clipboardReplaceText=function(e,t,o,n){if(!this.ready())return false;e.focus();e.selectionStart=t;e.selectionEnd=o;if(o-t<n.length){o=t+n.length}document.execCommand("insertText",false,n);e.selectionStart=o;e.selectionEnd=o;return true};o.prototype.selectAll=function(e){if(!this.ready())return false;e.selectionStart=0;return true};o.prototype.getLocalConfig=function(e,t){t=typeof t=="undefined"?null:t;if(!this.ready())return t;var o=BXDesktopSystem.QuerySettings(e,t+"");if(typeof o=="string"&&o.length>0){try{o=JSON.parse(o)}catch(e){o=t}}return o};o.prototype.setLocalConfig=function(e,t){if(!this.ready())return false;if(typeof t=="object")t=JSON.stringify(t);else if(typeof t=="boolean")t=t?"true":"false";else if(typeof t=="undefined")t="";else if(typeof t!="string")t=t+"";BXDesktopSystem.StoreSettings(e,t);return true};o.prototype.removeLocalConfig=function(e){if(!this.ready())return false;BXDesktopSystem.StoreSettings(e,null);return true};o.prototype.log=function(e,t){if(!this.ready())return false;BXDesktopSystem.Log(e,t);return true};o.prototype.createWindow=function(e,t){BXDesktopSystem.GetWindow(e,t)};o.prototype.getWindowTitle=function(e){if(!this.ready())return false;BXDesktopWindow.GetProperty("title");return true};o.prototype.setWindowTitle=function(e){if(!this.ready())return false;if(typeof e=="undefined")return false;e=t.util.trim(e);if(e.length<=0)return false;BXDesktopWindow.SetProperty("title",e);return true};o.prototype.setWindowPosition=function(e){if(!this.ready())return false;BXDesktopWindow.SetProperty("position",e);return true};o.prototype.setWindowSize=function(e){if(!this.ready())return false;BXDesktopWindow.SetProperty("clientSize",e);if(e.Width&&e.Height)t.MessengerWindow.adjustSize(e.Width,e.Height);return true};o.prototype.setWindowMinSize=function(e){if(!this.ready())return false;if(!e.Width||!e.Height)return false;t.MessengerWindow.minWidth=e.Width;t.MessengerWindow.minHeight=e.Height;BXDesktopWindow.SetProperty("minClientSize",e);return true};o.prototype.addTrayMenuItem=function(e){if(!this.ready())return false;BXDesktopWindow.AddTrayMenuItem(e);return true};o.prototype.finalizeTrayMenu=function(){if(!this.ready())return false;BXDesktopWindow.EndTrayMenuItem();return true};o.prototype.preventShutdown=function(){if(!this.ready())return false;BXDesktopSystem.PreventShutdown();return true};o.prototype.diskReportStorageNotification=function(e,t){if(!this.ready())return false;BXDesktopSystem.ReportStorageNotification(e,t);return true};o.prototype.diskOpenFolder=function(){if(!this.ready())return false;BXFileStorage.OpenFolder();return true};o.prototype.addSeparator=function(e){return t.MessengerWindow.addSeparator(e)};o.prototype.addTab=function(e){return t.MessengerWindow.addTab(e)};o.prototype.changeTab=function(e,o){return t.MessengerWindow.changeTab(e,o)};o.prototype.closeTab=function(e){return t.MessengerWindow.closeTab(e)};o.prototype.setTabBadge=function(e,o){return t.MessengerWindow.setTabBadge(e,o)};o.prototype.updateTabBadge=function(){if(!this.ready())return false;var e=0;for(var o in t.MessengerWindow.tabItems){if(t.MessengerWindow.tabItems[o].badge)e+=t.MessengerWindow.tabItems[o].badge}if(e<=0)e="";else if(e>50)e="50+";BXDesktopSystem.SetTabBadge(this.getContextWindow(),e+"")};o.prototype.setTabContent=function(e,o){return t.MessengerWindow.setTabContent(e,o)};o.prototype.isActiveWindow=function(){if(!this.ready())return false;return BXDesktopSystem.IsActiveTab()};o.prototype.getActiveWindow=function(){if(!this.ready())return 1;return BXDesktopSystem.ActiveTab()};o.prototype.getContextWindow=function(){if(!this.ready())return 1;if(this.isActiveWindow()){return this.getActiveWindow()}else{if(this.getActiveWindow()==TAB_CP){return TAB_B24NET}else{return TAB_CP}}};o.prototype.setActiveWindow=function(e){if(!this.ready())return false;if(typeof e!="undefined"){if(e==TAB_B24NET||e==TAB_CP){BXDesktopSystem.SetActiveTabI(e)}}else{BXDesktopSystem.SetActiveTab()}};o.prototype.getUserInfo=function(){return t.MessengerWindow.getUserInfo()};t.desktop=new o})(window);