Your IP : 3.143.4.20


Current Path : /home/bitrix/ext_www/rk_shared_core/bitrix/js/im/call/
Upload File :
Current File : /home/bitrix/ext_www/rk_shared_core/bitrix/js/im/call/util.min.js

(function(){BX.namespace("BX.Call");if(BX.Call.Util){return}BX.Call.Util={userData:{},usersInProcess:{},updateUserData:function(e){var r=[];var a=this;for(var t=0;t<e.length;t++){if(this.userData.hasOwnProperty(e[t])){continue}r.push(e[t])}var n=new Promise(function(e,t){if(r.length===0){return e()}BX.rest.callMethod("im.user.list.get",{ID:r,AVATAR_HR:"Y"}).then(function(r){var t=r.answer.result;if(BX.type.isPlainObject(t)){for(var n in t){a.userData[n]=t[n];delete a.usersInProcess[n]}}e()}).catch(function(e){t(e.answer)})});for(var t=0;t<r.length;t++){this.usersInProcess[r[t]]=n}return n},getUser:function(e){var r=this;return new Promise(function(a,t){if(r.userData.hasOwnProperty(e)){return a(r.userData[e])}else if(r.usersInProcess.hasOwnProperty(e)){r.usersInProcess[e].then(function(){return a(r.userData[e])})}else{r.updateUserData([e]).then(function(){return a(r.userData[e])})}})},getUserName:function(e){var r=this;return new Promise(function(a,t){if(r.userData.hasOwnProperty(e)){return a(r.userData[e].name?r.userData[e].name:"")}else if(r.usersInProcess.hasOwnProperty(e)){r.usersInProcess[e].then(function(){return a(r.userData[e].name?r.userData[e].name:"")})}else{r.updateUserData([e]).then(function(){return a(r.userData[e].name?r.userData[e].name:"")})}})},getUserAvatar:function(e){var r=this;return new Promise(function(a,t){if(r.userData.hasOwnProperty(e)){return a(r.userData[e].avatar_hr?r.userData[e].avatar_hr:"")}else if(r.usersInProcess.hasOwnProperty(e)){r.usersInProcess[e].then(function(){return a(r.userData[e].avatar_hr?r.userData[e].avatar_hr:"")})}else{r.updateUserData([e]).then(function(){return a(r.userData[e].avatar_hr?r.userData[e].avatar_hr:"")})}})},getCustomMessage:function(e,r){var a;if(!BX.type.isPlainObject(r)){r={}}if(r.gender&&BX.message.hasOwnProperty(e+"_"+r.gender)){a=BX.message(e+"_"+r.gender)}else{a=BX.message(e)}r=this.convertKeysToUpper(r);return a.replace(/#.+?#/gm,function(e){var a=e.substr(1,e.length-2);return r.hasOwnProperty(a)?r[a]:e})},convertKeysToUpper:function(e){var r=BX.util.objectClone(e);for(var a in r){var t=a.toUpperCase();if(t!=a){r[t]=r[a];delete r[a]}}return r},appendChildren:function(e,r){r.forEach(function(r){e.appendChild(r)})},containsVideoTrack:function(e){if(!(e instanceof MediaStream))return false;return e.getVideoTracks().length>0},findRowCount:function(e,r,a){var t=0;var n=0;for(var s=1;s<=a;s++){var u=this.getFilledArea(e,r,a,s);if(u>n){t=s;n=u}}return t},getFilledArea:function(e,r,a,t){var n=Math.ceil(a/t);var s=e/n;var u=r/t;var i=u/s;var o=9/16;var c;var f;if(i<o){c=u;f=s*(i/o)}else{f=s;c=u*(o/i)}var h=f*c*a;return h}}})();