/*1308863674,169775555*/ if (window.CavalryLogger) { CavalryLogger.start_js(["bg93w"]); } function BuddyListNub(){this.parent.construct(this);}BuddyListNub.

extend('NubCon troller');copy_properties(BuddyListNub,{TYPEAHEAD_MIN_FRIENDS:10,TYPEAHEAD_MIN_F RIENDS_FLMODE:20});BuddyListNub.prototype={init:function(b,a,d){this.parent.init (b);this.root=b;this.buddyList=a;this.typeahead=d;this.button=DOM.find(b,'a.fbNu bButton');this.label=DOM.find(b,'span.label');if(!ChatConfig.get('sidebar'))this .throbber=DOM.scry(b,'img.throbber')[0];a.subscribe('content-changed',this.flyou tContentChanged.bind(this));Arbiter.subscribe('buddylist/count-changed',this._up dateCount.bind(this));Arbiter.subscribe('chat/connect',this._handleConnect.bind( this));Arbiter.subscribe('chat/visibility-changed',this._handleVisibility.bind(t his));var c=Toggler.createInstance(b);c.setSticky(!!chatOptions.getSetting('stic ky_buddylist'));Arbiter.subscribe('chat/option-changed',function(e,f){f.name===' sticky_buddylist'&&c.setSticky(!!f.value);});Event.listen(b,'keydown',this._onKe yDown.bind(this));Event.listen(this.button,'click',this.onButtonClick.bind(this) );this.typeahead.subscribe(['respond','query','reset'],function(e,f){if(this._is Open){if(f&&f.value){CSS.removeClass(this.root,'maxHeight');this.buddyList.hide( );}else{CSS.addClass(this.root,'maxHeight');this.buddyList.show();}this.flyoutCo ntentChanged();}}.bind(this));this.subscribe('show',this.onShow.bind(this));this .subscribe('hide',this.onHide.bind(this));this.subscribe('resize',this.onResize. bind(this));presence.registerStateStorer(this._storeState.bind(this));presence.r egisterStateLoader(this._loadState.bind(this));this._loadState(presence.state);A rbiter.inform('buddylist-nub/initialized',this,Arbiter.BEHAVIOR_PERSISTENT);},ge tButton:function(){return this.button;},_handleConnect:function(a){this._setLabe l(_tx("Chat"),true);},_handleVisibility:function(){var a=Chat.isOnline();if(!a){ this._setLabel(_tx("{Chat} (Desconectado)",{Chat:_tx("Chat")}));this.hide();}CSS .conditionClass(presence.holder,'offline',!a);},_loadState:function(b){var a=!!b .blo;if(!presence.poppedOut)if(a){this.show();}else this.hide();},onButtonClick: function(){var a=this.subscribe('show',function(){this.typeahead.getCore().getEl ement().focus();}.bind(this));this.unsubscribe.bind(this,a).defer();},onHide:fun ction(){this._isOpen=false;this.buddyList.subscribe('initialized',function(){thi s.buddyList.hide();}.bind(this));this.typeahead.getCore().reset();presence.doSyn c();},_onKeyDown:function(event){var a=Event.getKeyCode(event);if(a===KEYS.ESC&& !CSS.hasClass(this.root,'menuOpened')){this.hide();return false;}},onResize:func tion(){if(ChatConfig.get('sidebar'))this.buddyList.render();},onShow:function(){ this._isOpen=true;Chat.goOnline(function(){this.buddyList.subscribe('initialized ',function(){CSS.addClass(this.root,'maxHeight');this.buddyList.show();}.bind(th is));presence.doSync();}.bind(this));},_setLabel:function(a,c){var b=this.label. cloneNode(true);DOM.setContent(b,a);DOM.replace(this.label,b);this.label=b;this. throbber&&CSS.conditionShow(this.throbber,!!c);},_storeState:function(a){a.blo=t his._isOpen?1:0;return a;},_updateCount:function(){if(!Chat.isOnline())return;va r a=AvailableList.getCount();var b=_tx("{Chat} {number-available}",{Chat:_tx("Ch at"),'number-available':['<span class="count">','(<strong>',a,'</strong>)','</sp an>'].join('')});this._setLabel(HTML(b));var c=this.buddyList.flMode?BuddyListNu b.TYPEAHEAD_MIN_FRIENDS_FLMODE:BuddyListNub.TYPEAHEAD_MIN_FRIENDS;CSS.conditionS how(this.typeahead.getElement(),a>=c);}}; function ChatTabActions(a){this._container=a;this._actions={};this._actionOrder= [];this._visibilityChanged=false;this._anyVisible=false;this.actionClass='action ';}copy_properties(ChatTabActions.prototype,{anyVisible:function(){return this._ anyVisible;},appendAction:function(c,b,a){this._addAction(c,b,a);this._actionOrd er.push(c);return this;},prependAction:function(c,b,a){this._addAction(c,b,a);th is._actionOrder.unshift(c);return this;},removeAction:function(a){delete this._a ctions[a];return this;},setVisible:function(b,c){var a=this._actions[b];if(a&&a. visible!=c){a.visible=c;this._visibilityChanged=true;}return this;},refresh:func tion(){if(this._visibilityChanged){this._render();this._visibilityChanged=false; return true;}return false;},_render:function(){DOM.empty(this._container);var c= this._actions;var b=this._actionOrder;this._anyVisible=false;var d=[];for(var e= 0;e<b.length;++e){var a=c[b[e]];if(a.visible){if(this._anyVisible)d.push($N('spa

n',{className:'divider'},HTML(' &middot; ')));d.push(a.create_element());this._a nyVisible=true;}}DOM.appendContent(this._container,d);this._container.style.disp lay=this._anyVisible?'block':'none';},_addAction:function(c,b,a){if(typeof b=='s tring'){var d=b;b=function(){return $N('a',{className:this.actionClass,href:'#'} ,d);}.bind(this);}this._actions[c]={create_element:function(){var e=b();Event.li sten(e,'click',a);return e;},visible:false};this._visibilityChanged=true;}}); var ChatUserInfoManager=window.ChatUserInfoManager (function(){var a=new Arbite r();var b={};var k=[];var f=false;var h=false;function c(){if(!k.length f)retur n;f=true;e.defer();}function d(m,l){a.inform('fetch');new AsyncRequest().setURI( m).setData(l).setHandler(function(n){j(n,l.ids);}).setErrorHandler(i).setAllowCr ossPageTransition(true).setMethod('GET').setReadOnly(true).send();}function e(){ var l=k;k=[];d('/ajax/chat/user_info.php',{ids:l});}function g(){f=false;c();}fu nction j(o,n){var p=n?Object.from(n):{};for(var m in o.payload){var r=o.payload[ m];r.type='friend';ChatUserInfos[m]=r;var l=b[m];if(l){delete b[m];l.forEach(fun ction(s){try{s(r);}catch(t){}});}delete p[m];}for(var q in p)delete b[q];g();a.i nform('updated');}function i(){g();}return copy_properties(a,{get:function(m,l){ l=l bagofholding;if(ChatUserInfos[m]){l(ChatUserInfos[m]);}else{if(!b[m]){b[m]= [];k.push(m);c();}b[m].push(l);}},hasAll:function(){return h;},fetchAll:function (){if(!h){d('/ajax/chat/user_info_all.php',{viewer:Env.user});h=true;}}});})(); function TypingIndicator(a,b,d,c){this.id=a;this.input=b;this.source=d;this.call back=null;this.ignoreEnter=false;Arbiter.subscribe(PresenceMessage.getArbiterMes sageType('typ'),this.onTyping.bind(this));this.currentState=TypingIndicator.INAC TIVE;this.remoteState=TypingIndicator.INACTIVE;this.lastKeystrokeAt=null;this.no tifyTimer=null;this.checkTimer=null;c=c {};this.notifyDelay=c.notifyDelay Typi ngIndicator.DEFAULT_NOTIFY_DELAY;this.keystrokeExpiry=c.keystrokeExpiry TypingI ndicator.DEFAULT_KEYSTROKE_EXPIRY;Event.listen(b,'keyup',this._update.bind(this) );}copy_properties(TypingIndicator,{INACTIVE:0,TYPING:1,DEFAULT_NOTIFY_DELAY:100 0,DEFAULT_KEYSTROKE_EXPIRY:7000});copy_properties(TypingIndicator.prototype,{set IgnoreEnter:function(a){this.ignoreEnter=a;},resetState:function(){presence.debu g('typing: ** RESET **');this.currentState=TypingIndicator.INACTIVE;this.remoteS tate=TypingIndicator.INACTIVE;this.lastKeystrokeAt=null;clearTimeout(this.notify Timer);this.notifyTimer=null;clearTimeout(this.checkTimer);this.checkTimer=null; },_notifyState:function(c){var d=this.id;var a=AvailableList.get(d);if(a&&c!=thi s.remoteState){this.remoteState=c;presence.debug('typing: notifyState('+c+')');i f(!channelManager.iframeEverLoaded)return;var b={typ:c,to:d,source:this.source}; new AsyncRequest().setHandler(this._onTypResponse.bind(this,d)).setErrorHandler( bagofholding).setData(b).setURI('/ajax/messaging/typ.php').setAllowCrossPageTran sition(true).send();}},_onTypResponse:function(c,b){var a=b.getPayload() {};if( a.offline)AvailableList.set(c,AvailableList.OFFLINE);},_update:function(event){v ar a=Event.getKeyCode(event);var b=this.currentState;if(!(this.ignoreEnter&&a=== KEYS.RETURN))if(this.input.value.length===0){if(!(b==TypingIndicator.INACTIVE))t his._transition(TypingIndicator.INACTIVE);}else if(b==TypingIndicator.TYPING){th is._recordKeystroke();}else if(b==TypingIndicator.INACTIVE){this._transition(Typ ingIndicator.TYPING);this._recordKeystroke();}},_recordKeystroke:function(){this .lastKeystrokeAt=new Date();if(!this.checkTimer)this.checkTimer=this._checkTypin g.bind(this).defer(this.keystrokeExpiry);},_checkTyping:function(){var a=this.la stKeystrokeAt.valueOf()+this.keystrokeExpiry;var b=new Date().valueOf();if(b>a){ this._transition(TypingIndicator.INACTIVE);}else{clearTimeout(this.checkTimer);t his.checkTimer=this._checkTyping.bind(this).defer(a-b+10);}},_transition:functio n(a){clearTimeout(this.checkTimer);this.checkTimer=null;this.lastKeystrokeAt=nul l;presence.debug('typing:'+this.currentState+' -> '+a);this.currentState=a;clear Timeout(this.notifyTimer);this.notifyTimer=this._notifyState.bind(this,a).defer( this.notifyDelay);},setCallback:function(a){this.callback=a;},onTyping:function( b,a){this.callback&&this.callback(a.obj);}}); function ChatThreadTab(a,e,f,b,d,c){this.parent.construct(this,a,e,f,b,d,c);}Cha tThreadTab.extend('ChatTab');ChatThreadTab.prototype={rendererName:'chat-threadtab',msgGroupRendererName:'chat-msg-thread-with-tooltip',hasThread:true,getPostT ype:function(){return 'thread';},handleBuddyAvailability:bagofholding,getAvailab ility:function(){return AvailableList.ACTIVE;},addRecipients:function(b){this.pa rent.addRecipients(b);if(!this.getHasThread())for(var a=0;a<b.length;a++)this.pe

ndingNewRecipients.push(b[a]);return this;},showSendAsMessageLinks:bagofholding, isCanonical:function(){return false;},_messagingMarkThreadAsRead:function(a){Mes saging.markAsRead(a);},getConversationURI:bagof(''),getProfileURI:function(){ret urn Messaging.getInboxThreadURI(this.id);},setHasThread:function(a){this.hasThre ad=a;},getHasThread:function(){return this.hasThread;}}; function ChatGroupTab(a,b,d,f,e,c){this.parent.construct(this,a,b,d,d,e,c);this. _facepileHandlers=[];}ChatGroupTab.extend('ChatTab');ChatGroupTab.prototype={_FA CEPILE_UPDATE_INTERVAL:60000,rendererName:'chat-group-tab',msgGroupRendererName: 'chat-msg-group-with-tooltip',getPostType:function(){return 'group';},focus:func tion(c,a,b){this.parent.focus(c,a,b);this._setUpdateFacepiles(true);},unfocus:fu nction(){this.parent.unfocus();this._setUpdateFacepiles(false);},close:function( ){this.parent.close();this._setUpdateFacepiles(false);this._removeFacepileHandle rs();},_facepilesToken:null,_setUpdateFacepiles:function(a){if(a){if(!this._face pilesToken){this._facepilesToken=setInterval(this._sendFacepileRequest.bind(this ),this._FACEPILE_UPDATE_INTERVAL);this._sendFacepileRequest();}}else if(this._fa cepilesToken){clearInterval(this._facepilesToken);this._facepilesToken=null;}},_ sendFacepileRequest:function(){new AsyncRequest().setData({type:this.getPostType (),id:this.id}).setURI('/ajax/groups/chat/update_facepiles.php').setHandler(this ._renderFacepile.bind(this)).send();},_renderFacepile:function(b){this._removeFa cepileHandlers();var a=b.getPayload();if(a.response_html)DOM.setContent(this.cha tInfo,HTML(a.response_html));if(a.facepile_click_info)a.facepile_click_info.each (function(d){var c=DOM.scry($(d.id),'a');if(c.length)this._facepileHandlers.push (Event.listen(c[0],"click",function(){chatDisplay.focusTab(d.uid,true,d.name,d.f irstName);return false;}));}.bind(this));this.handleResize();},_removeFacepileHa ndlers:function(){while(this._facepileHandlers.length)this._facepileHandlers.pop ().remove();},handleBuddyAvailability:bagofholding,showSendAsMessageLinks:bagofh olding,playSound:bagofholding,_buildUI:function(){var b=this.parent._buildUI();v ar a=XHPTemplate.getNode(b,'reportLink');if(a)CSS.addClass(a,'hidden_elem');this .chatInfo=XHPTemplate.getNode(b,'facepileHolder');},isCanonical:function(){retur n false;},getAvailability:function(){return AvailableList.ACTIVE;},mentionsUser: function(a){if(a.from==presence.user)return false;var b=a.msg.text;if(presence.a lias!==""&&b.indexOf(presence.alias)!=-1)return true;if(presence.firstName!==""& &b.toLowerCase().indexOf(presence.firstName.toLowerCase())!=-1)return true;retur n false;},newMsg:function(a){if(this.mentionsUser(a))this.parent.playSound();thi s.parent.newMsg(a);},getConversationURI:bagof(''),getProfileURI:function(){retur n URI(env_get('www_base')).setPath('/home.php').setQueryData({sk:'group_'+this.i d});}}; function ChatTab(a,c,e,b,g,d){this.inDock=!presence.inPopoutWindow;this.chatDisp lay=a;this.id=c;this.name=e;this.tabRef='chatDisplay.tabs['+this.id+']';this.fir stName=b;this.tabDisabled=false;this.numMissed=g 0;this.missedTime=d;this.focus ed=false;this.lastLogItem=null;this.historyLoaded=false;this.pendingSentMsgs=[]; this.failedSentMsgs=[];this.historyRequestID=0;this.bounceAnimation=null;this.pe ndingNewRecipients=[];this.allRecipients=[];this.convTextEmoteProcessor=Emote.ht mlEmote;this.minTextHeight=presence.inPopoutWindow?this.minTextHeightPopout:this .minTextHeightPopin;this.lastMessageAt=null;this.lastMessageHadOfflineResponse=f alse;this._handlers=[];this._subscriptions=[];this._buildUI();this.loadData();th is._handleStatusChange();this._textareaListener=null;this.isWindowFocused=true;t his._handlers.push(Event.listen(window,'blur',this._onWindowBlur.bind(this)),Eve nt.listen(window,'focus',this._onWindowFocus.bind(this)));Arbiter.subscribe(['ch at/visibility-changed','buddylist/availability-changed'],this._handleStatusChang e.bind(this));if(this.inDock){var f=new NubController();f.init(this.tabHandle);f .subscribe('show',function(){if(this.chatDisplay.focused!=this.id)this.chatDispl ay.focusTab(this.id);}.bind(this));f.subscribe('hide',function(){if(this.focused )this.chatDisplay.unfocus();}.bind(this));}this._subscriptions.push(Arbiter.subs cribe('overflow-applied-to-body',this.scrollToBottom.bind(this)));this._messagin gToken=MessagingEvents.subscribe('read',function(h,i){if(i.chat_ids&&i.chat_ids. contains(this.id)){this._clearMessagingMarkAsRead();if(i.mark_as_read)this._mark Read();}}.bind(this));Sound.init();}ChatTab.mixin('Arbiter',{currentMsgGroup:nul l,rendererName:'chat-tab',msgGroupRendererName:'chat-msg-group',pendingToLogComp areWindow:60000,resendDelay:5000,handleWidth:150,popinWidth:258,popinHeight:250,

popoutWidthOffset:180,flPopoutWidthOffset:200,minTextHeightPopin:13,minTextHeigh tPopout:32,maxTextHeight:77,msgBunchTime:300000,maxHandleLen:16,maxTitleLen:20,b ounceDuration:50,_ACTION_LOG_SUBSCRIBE:1,_ACTION_LOG_UNSUBSCRIBE:2,_onWindowFocu s:function(event){this.isWindowFocused=true;if(this.focused)this._markRead();},_ onWindowBlur:function(event){this.isWindowFocused=false;},isTabVisible:function( ){return this.focused&&(presence.inPopoutWindow !presence.poppedOut);},start:fu nction(){this._popSendQueue();},restart:function(){if(this.focused){this.getHist ory(true);}else this.historyLoaded=false;this.handleResize.bind(this).defer();}, loadData:function(){if(this.chatDisplay.histories[this.id])this._setHistory(this .chatDisplay.histories[this.id]);},_onHistoryInitialHandler:function(a,b){if(a!= this.historyRequestID){presence.debug("tabs: got old history async, ignoring");r eturn false;}return null;},_onHistoryResponse:function(a,l){var b=l.getPayload() ;var n=b.userInfo;var h=b.history;Chat.setUserInfo(this.id,n,b.fls);if(!h)return ;var k=false;if(this.pendingSentMsgs.length>0&&h.length>0){var j=this.pendingSen tMsgs[0];var c;for(c=h.length-1;c>=0;c--){var g=h[c];if(g.to!=this.chatDisplay.u ser){var m=Math.abs(j.time-g.time);if(m<this.pendingToLogCompareWindow&&j.text== g.msg.text){this._setMsgInfoMarkup(j.msgID,'');this.pendingSentMsgs.shift();this ._popSendQueue();this.poppedSendQueue=true;break;}}}var e=h[h.length-1].time;for (c=0;c<this.pendingSentMsgs.length;c++){j=this.pendingSentMsgs[c];if(j.time<e)j. time=(++e);}}var i=this.chatDisplay.histories[this.id];if(i)if(h.length>0){var d =h[h.length-1];var f=d.time;for(var c=0;c<i.length;c++){var g=i[c];if(g.time>f)h .push(g);}}else h=i;this._setHistory(h);this.chatDisplay.histories[this.id]=h;if (a)if(!k)this._popSendQueue();},getHistory:function(a){var b=++(this.historyRequ estID);new AsyncRequest().setInitialHandler(this._onHistoryInitialHandler.bind(t his,b)).setHandler(this._onHistoryResponse.bind(this,a)).setErrorHandler(bagofho lding).setMethod('GET').setReadOnly(true).setOption('suppressErrorAlerts',true). setData({type:this.getPostType(),id:this.id}).setURI('/ajax/chat/history.php').s etAllowCrossPageTransition(true).send();},getPostType:function(){return 'friend' ;},_setHistory:function(e){this.lastLogItem=null;DOM.empty(this.chatConvContent) ;var g=0;var j=[];Array.prototype.push.apply(j,this.failedSentMsgs);Array.protot ype.push.apply(j,this.pendingSentMsgs);var f=0;var a=false;for(var b=0;b<e.lengt h;b++){var c=e[b];var d=this.getMessageTypeInfo(c.type);if(d.unknown)continue;if (!d.preserveHistory)a=true;for(;g<j.length;g++){var h=j[g];var i=this.getMessage TypeInfo(h.type);if(!i.preserveHistory)a=true;if(h.time>f&&h.time<=c.time){if(i. visible)this.renderMsg(presence.user,this.id,h.time,h,h.msgID,h.isError,h.infoMa rkup);}else break;}if(d.msg){this.renderMsg(c.from,c.to,c.time,c.msg);}else if(d .videoMsg)this._renderVideoMsg(c.videoMsg,c.params);this.lastLogItem=c;f=c.time; }for(;g<j.length;g++){var h=j[g];if(this.getMessageTypeInfo(h.type).visible){thi s.renderMsg(presence.user,this.id,h.time,h,h.msgID,h.isError,h.infoMarkup);this. lastLogItem={type:h.type,from:presence.user,to:this.id,time:h.time,msg:h};}}this ._toggleClearChatHistory(a);this.scrollToBottom();this.historyLoaded=true;},setH istoryLoaded:function(a){this.historyLoaded=a;},addRecipients:function(b){for(va r a=0;a<b.length;a++)this.allRecipients.push(b[a]);return this;},setRecipients:f unction(a){this.allRecipients=a;return this;},getRecipients:function(){return th is.allRecipients;},newActionLogMsg:function(b){var a=this.isUserScrolled();this. _renderActionLogMessage(b.actorInfo,b.newRecipientsInfo,b.actionType,b.timestamp Msec);this._toggleClearChatHistory(true);!a&&this.scrollToBottom();},_renderActi onLogMessage:function(b,e,i,g){var a=this.chatDisplay.templates['chat-msg-event' ].render();var c=XHPTemplate.getNode(a,'icon');var d=XHPTemplate.getNode(a,'mess age');var h=XHPTemplate.getNode(a,'timestamp');var f=this.chatDisplay.renderServ erTime(g);DOM.setContent(h,f);this._checkDateBreak(g);switch(i){case this._ACTIO N_LOG_SUBSCRIBE:if(!e e.length===0)return;c.src='/images/icons/add_people.png'; DOM.setContent(d,HTML(this._getSubscribeMessage(this.chatDisplay.user,b,e)));bre ak;case this._ACTION_LOG_UNSUBSCRIBE:c.src='/images/messaging/read/left-conversa tion.png';DOM.setContent(d,HTML(this._getUnsubscribeMessage(this.chatDisplay.use r,b)));break;default:return;}DOM.appendContent(this.chatConvContent,a);this.curr entMsgGroup=null;},_getSubscribeMessage:function(c,a,b){switch(b.length){case 1: return _tx("{subscriber1} was added by {actor}",{subscriber1:this._getLinkifiedN ame(c,b[0],true),actor:this._getLinkifiedName(c,a,false)});case 2:return _tx("{s ubscriber1} and {subscriber2} were added by {actor}",{subscriber1:this._getLinki

fiedName(c,b[0],true),subscriber2:this._getLinkifiedName(c,b[1],false),actor:thi s._getLinkifiedName(c,a,false)});case 3:return _tx("{subscriber1}, {subscriber2} and {subscriber3} were added by {actor}",{subscriber1:this._getLinkifiedName(c, b[0],true),subscriber2:this._getLinkifiedName(c,b[1],false),subscriber3:this._ge tLinkifiedName(c,b[2],false),actor:this._getLinkifiedName(c,a,false)});default:r eturn _tx("{subscriber1}, {subscriber2} and {more_people} others were added by { actor}",{subscriber1:this._getLinkifiedName(c,b[0],true),subscriber2:this._getLi nkifiedName(c,b[1],false),more_people:b.length-2,actor:this._getLinkifiedName(c, a,false)});}},_getUnsubscribeMessage:function(b,a){return _tx("{actor} left the conversation",{actor:this._getLinkifiedName(b,a,true)});},_getLinkifiedName:func tion(c,b,a){if(!b.fbid){return b.name;}else if(c==b.fbid){return a?_tx("You"):_t x("you");}else return presence.renderLink(b.href,b.name);},clearHistory:function (){new AsyncRequest().setHandler(bagofholding).setErrorHandler(bagofholding).set Data({clear_history_id:this.id}).setURI(this.chatDisplay.settingsURL).setAllowCr ossPageTransition(true).send();this.failedSentMsgs=[];this.pendingSentMsgs=[];th is._setHistory(this.chatDisplay.histories[this.id]=[]);},reportLinkAction:functi on(){Bootloader.loadComponents('dialog',(function(){var a=URI(this.chatDisplay.r eportURL).addQueryData({id:this.id}).addQueryData({src:'top_report_link'});Dialo g.bootstrap(a.toString(),null,false);}).bind(this));},_isCurrentPendingSend:func tion(a){return (this.pendingSentMsgs.length>0&&a==this.pendingSentMsgs[0].msgID) ;},_onSendServerDialogCancel:function(){if(!this._isCurrentPendingSend(msgID))re turn;this.failedSentMsgs.push(this.pendingSentMsgs.shift());this._popSendQueue() ;},_onSendInitialHandler:function(a){this.lastMessageHadOfflineResponse=false;}, _onSendResponse:function(a,d){var b=d.getPayload();if(this._isCurrentPendingSend (a)){var c=this.pendingSentMsgs[0];c.asyncSuccess=true;}if(b&&b.warning){var e=t his._renderMsgWarning(('title' in b.warning?b.warning.title+'<br />':'')+b.warni ng.body);this._setMsgInfoMarkup(a,e,'msg_warning');}},_onSendTransportError:func tion(a,b){if(!this._isCurrentPendingSend(a))return;if(!this.resendTimeout)this.r esendTimeout=this._resendMessage.bind(this,a).defer(this.resendDelay);},_onSendE rror:function(c,e){if(!this._isCurrentPendingSend(c))return;var d=e.getPayload() ;var b=e.getError();var a=presence.getErrorDescription(e);if(b==1356003 b==1356 022){this.showSendAsMessageLinks();}else if(b==1356002){this.lastMessageHadOffli neResponse=true;chatOptions.setVisibility(false);presence.doSync();}else if(b==1 356008){a=d.error.title;ErrorDialog.show(d.error.title,d.error.body);}else if(b= =1356026){a=d.errorText;(new Function(d.do_onload)).apply();}this._sendErrorAll( a);},showSendAsMessageLinks:function(){this.lastMessageHadOfflineResponse=true;A vailableList.set(this.id,AvailableList.OFFLINE);for(var b=0;b<this.pendingSentMs gs.length;b++){var e=this.pendingSentMsgs[b];var f=ge('msg_'+this.id+'_'+e.msgID );if(f){var a='rel="dialog"';var g=new URI(this.chatDisplay.messageURL).addQuery Data({id:this.id,message:e.text}).toString();var c=presence.renderLink(g,_tx("en viar como un mensaje"),a);var d=_tx("{message} ({=send as a message})",{message: this._renderMsgHtmlize(e.text),'=send as a message':c});DOM.setContent(f,HTML(d) );}}},_renderMsgWarning:function(b){var a=this.chatDisplay.templates['chat-msg-w arning'].render();DOM.setContent(XHPTemplate.getNode(a,'message'),b);return a;}, _renderMsgError:function(a){var b=this.chatDisplay.templates['chat-msg-error'].r ender();DOM.setContent(XHPTemplate.getNode(b,'message'),a);return b;},_sendError All:function(a){var b=this._renderMsgError(a);var c=true;while(this.pendingSentM sgs.length){var d=this.pendingSentMsgs.shift();d.isError=true;if(c)d.infoMarkup= b;this._setMsgInfoMarkup(d.msgID,b,'msg_error');this.failedSentMsgs.push(d);c=fa lse;b='';}},_createMessage:function(e,c){var b=rand32()+1;var f=presence.getTime ();var a=new Date().getTime();if(this.lastLogItem&&f<this.lastLogItem.time)f=thi s.lastLogItem.time+1;var d={text:e,msgID:b,type:c,created:a,time:f,asyncSuccess: false,isError:false,errorMarkup:''};return d;},_flushSmallQueue:function(){if(th is.pendingSentMsgs.length==1){var a=this.pendingSentMsgs[0];if(channelManager.if rameEverLoaded){this._sendMessage(a);}else if(!this.resendTimeout)this.resendTim eout=this._resendMessage.bind(this,a.msgID).defer(this.resendDelay);}},_updateCh atActivity:function(b,a){this.lastLogItem={type:b.type,from:presence.user,to:thi s.id,time:b.time,msg:a};this.chatDisplay.chatActivityTime=(new Date()).getTime() ;presence.doSync();},sendInput:function(){var d=this.chatInput.value;if(!d !d.m atch(/[^\s]/))return;this.chatInput.value='';var c=this._createMessage(d,'msg');

this.pendingSentMsgs.push(c);this._flushSmallQueue();var b={text:d};var a=this.i sUserScrolled();this.renderMsg(presence.user,this.id,c.time,b,c.msgID);this._tog gleClearChatHistory(true);!a&&this.scrollToBottom();this._updateChatActivity(c,b );this.typingIndicator&&this.typingIndicator.resetState();},_sendMessage:functio n(b){b.time=presence.getTime();if(this.lastLogItem&&b.time<this.lastLogItem.time )b.time=this.lastLogItem.time+1;clearTimeout(this.resendTimeout);this.resendTime out=null;var c=this._getSendData(b);channelManager.expectResponse();Arbiter.info rm('chat/message-sent',c);var a=b.msgID;new AsyncRequest().setServerDialogCancel Handler(this._onSendServerDialogCancel.bind(this)).setInitialHandler(this._onSen dInitialHandler.bind(this)).setHandler(this._onSendResponse.bind(this,a)).setErr orHandler(this._onSendError.bind(this,a)).setTransportErrorHandler(this._onSendT ransportError.bind(this,a)).setData(c).setURI('/ajax/chat/send.php').setAllowCro ssPageTransition(true).send();this.pendingNewRecipients=[];},_getSendData:functi on(e){var c=this.chatDisplay.histories[this.id];var d=null;var a=this.getAvailab ility();var i=a==AvailableList.OFFLINE;var h=a==AvailableList.IDLE;var f={msg_id :e.msgID,client_time:e.time,to:this.id,num_tabs:this.chatDisplay.numTabs,pvs_tim e:d,msg_text:e.text,to_offline:i,to_idle:h,popped_out:presence.inPopoutWindow};i f(this.pendingNewRecipients.length>0)f.new_recips=this.pendingNewRecipients;if(i ){var b=AvailableList.getDebugInfo(this.id);f.overlay=b.overlay;f.overlayTime=b. overlayTime;f.presence=b.presence;f.presenceTime=presence.getTime();f.clock=(new Date()).getTime();}if(ChatConfig.get('sidebar')){f.sidebar_launched=true;var g= window.ChatSidebar&&ChatSidebar.getInstance();if(g){f.sidebar_enabled=g.isEnable d();f.sidebar_capable=g.isViewportCapable();f.sidebar_visible=g.isVisible();}}re turn f;},_popSendQueue:function(){if(this.pendingSentMsgs.length==0)return;var a =this.pendingSentMsgs[0];if(channelManager.iframeEverLoaded){this._sendMessage(a );}else if(!this.resendTimeout)this.resendTimeout=this._resendMessage.bind(this, a.msgID).defer(this.resendDelay);},_resendMessage:function(a){clearTimeout(this. resendTimeout);this.resendTimeout=null;if(this._isCurrentPendingSend(a))if(chann elManager.iframeEverLoaded){this._sendMessage(this.pendingSentMsgs[0]);}else thi s.resendTimeout=this._resendMessage.bind(this,a).defer(this.resendDelay);},_setM sgInfoMarkup:function(d,c,a){var b=DOM.scry(this.chatConvContent,'#msg_'+this.id +'_'+d)[0];if(!b)return;DOM.insertAfter(b,c);a&&CSS.addClass(b,a);this.scrollToB ottom();},tabHitAreaOnClick:function(){if(this.suppressHeaderCollapse)return;if( presence.inPopoutWindow){this.chatDisplay.focusTab(this.id,true,this.name,this.f irstName);}else this.chatDisplay.toggleTab(this.id,true,this.name,this.firstName );this.chatDisplay.doStopBlinking();},tabXOnClick:function(a){this.chatDisplay.c loseTab(this.id);this.chatDisplay.doStopBlinking();$E(a).kill();return false;},h eaderLinkMouseOver:function(){CSS.addClass(this.chatHeader,'suppress_hover');thi s.suppressHeaderCollapse=true;},headerLinkMouseOut:function(){CSS.removeClass(th is.chatHeader,'suppress_hover');this.suppressHeaderCollapse=false;},chatConvOnMo useDown:function(event){if(event.button!=0)return;this.chatDisplay.doStopBlinkin g();},chatConvOnMouseUp:function(){if(DOM.getSelection()=='')this.focusChatInput (true);},focusChatInput:function(a){if(this.isTabVisible())if(a this.canStealFo cus())this.chatInput.focus();},canStealFocus:function(){if(undefined!=document.a ctiveElement){var a=document.activeElement;if(a){var b='INPUT'==a.nodeName 'TEX TAREA'==a.nodeName ('DIV'==a.nodeName&&a.contentEditable=="true");return !b;}}r eturn false;},showAddFriend:function(){var a={canonical:this.isCanonical()};if(t his.isCanonical()){a.recipient_id=this.id;}else{a.thread_id=this.id;a.recipients =this.getRecipients();}new AsyncRequest().setURI('/ajax/chat/show_add_friends.ph p').setData(a).setHandler(bagofholding).setErrorHandler(bagofholding).setAllowCr ossPageTransition(true).send();},_buildUI:function(){var m=this.chatDisplay.temp lates[this.rendererName].render();this._updateNubName(m);if(!ChatConfig.get('big bird_ui')){var o=XHPTemplate.getNode(m,'titlebarLink');o.href=this.getProfileURI ();}var p=XHPTemplate.getNode(m,'titlebarText');DOM.setContent(p,this.name);var d=XHPTemplate.getNode(m,'chatConv');var h=XHPTemplate.getNode(m,'closeButton');v ar e=XHPTemplate.getNode(m,'input');this._handlers.push(Event.listen(d,'mousedow n',this.chatConvOnMouseDown.bind(this)),Event.listen(d,'mouseup',this.chatConvOn MouseUp.bind(this)),Event.listen(h,'click',this.tabXOnClick.bind(this)),Event.li sten(e,'keydown',this.inputKeyDown.bind(this)),Event.listen(e,'click',this.chatD isplay.doStopBlinking.bind(this.chatDisplay)));var k=XHPTemplate.getNode(m,'maxi

mizeButton');if(k)this._handlers.push(Event.listen(k,'click',this.maximizeOnClic k.bind(this)));this.tabHandle=m;this.statusEl=XHPTemplate.getNode(m,'status');th is.tabCount=XHPTemplate.getNode(m,'numMessages');this.chatWrapper=XHPTemplate.ge tNode(m,'chatWrapper');this.chatConv=d;this.chatConvContent=XHPTemplate.getNode( m,'conversation');this.chatInput=e;var f=ge('fbDockChatTabs');DOM.prependContent (f,this.tabHandle);if(ChatConfig.get('typing_notifications'))this.typingIndicato r=new TypingIndicator(this.id,e,'chat');this._updateNumMissedDisplay();var q=XHP Template.getNode(m,'videoCallLink');if(q){this._handlers.push(Event.listen(q,'cl ick',function(){VideoEvents.inform(VideoEvents.START_CALL_UI,{idTarget:this.id}) ;this.focused&&this.chatDisplay.unfocus();return false;}.bind(this)));this._call IncomingToken=VideoEvents.subscribe(VideoEvents.CALL_INCOMING,function(r,s){if(s .idTarget==this.id&&this.focused)this.chatDisplay.unfocus();}.bind(this));}if(Ch atConfig.get('bigbird_ui')){var j=XHPTemplate.getNode(m,'dropdown');if(j){Toggle r.createInstance(j).setSticky(false);var i=XHPTemplate.getNode(m,'conversationLi nk');if(i){if(this.isCanonical()){i.href=Messaging.getUserThreadURI(this.id);}el se i.href=Messaging.getInboxThreadURI(this.id);this._handlers.push(Event.listen( i,'click',this.unfocus.bind(this)));}var l=XHPTemplate.getNode(m,'reportSpamLink ');if(l)this._handlers.push(Event.listen(l,'click',this.reportLinkAction.bind(th is)));var g=XHPTemplate.getNode(m,'clearWindowLink');if(g)this._handlers.push(Ev ent.listen(g,'click',this.clearHistory.bind(this)));var b=XHPTemplate.getNode(m, 'addFriendLink');if(b)this._handlers.push(Event.listen(b,'click',this.showAddFri end.bind(this)));var c=XHPTemplate.getNode(m,'addToThreadLink');if(c)this._handl ers.push(Event.listen(c,'click',this.showAddFriend.bind(this)));}var n=XHPTempla te.getNode(m,'titlebarCloseButton');this._handlers.push(Event.listen(n,'click',t his.tabXOnClick.bind(this)));}else{var a=XHPTemplate.getNode(m,'actions');this.a ctions=new ChatTabActions(a);this.actions.appendAction('clearHistory',_tx("Despe jar ventana",{Chat:_tx("Chat")}),this.clearHistory.bind(this));if(!ChatConfig.ge t('report')&&this instanceof ChatTab)this.actions.appendAction('reportLink',_tx( "Informar"),this.reportLinkAction.bind(this));this.actions.refresh();}return m;} ,isCanonical:function(){return true;},_updateNubName:function(a){DOM.setContent( XHPTemplate.getNode(a,'name'),this.name);},maximizeOnClick:function(){var a=this .getConversationURI();if(a){goURI(a);this.focused&&this.chatDisplay.unfocus();}r eturn false;},getConversationURI:function(){return Messaging.getUserThreadURI(th is.id);},getProfileURI:function(){return URI(env_get('www_base')).setPath('/prof ile.php').setQueryData({id:this.id});},show:function(){CSS.show(this.tabHandle); },hide:function(){CSS.hide(this.tabHandle);},inputKeyDown:function(event){this.c hatDisplay.doStopBlinking();if(!this._textareaListener){var c=DataStore.get(this .chatInput,'DOMControl');this._textareaListener=c.subscribe('resize',this.handle Resize.bind(this));}switch(event.keyCode){case KEYS.RETURN:if(!event.shiftKey){t his.sendInput();event.prevent();}break;case KEYS.ESC:this.chatDisplay.closeTab(t his.id);event.prevent();return false;case KEYS.TAB:if(presence.inPopoutWindow){v ar b=event.shiftKey;var a=this.chatDisplay.getNextTabId(this.id,b);if(a>0){this. chatDisplay.focusTab(a,true);event.prevent();return false;}}break;}},updateName: function(a){this.name=a;this._updateNubName(this.tabHandle);},trimName:function( a){var b=this.name;if(b.length>a)b=b.substring(0,a-2)+'...';return b;},_handleSt atusChange:function(){var b=Chat.isOnline();var a=b?this.getAvailability():Avail ableList.OFFLINE;var c;if(b){if(!a)if(ChatConfig.get('titan')){var d=ChatUserInf os[this.id] {};switch(d.gender){case GenderConst.FEMALE_SINGULAR:case GenderCon st.FEMALE_SINGULAR_GUESS:c=_tx("{name} is offline. Your messages will be sent to her inbox.",{name:this.firstName});break;case GenderConst.MALE_SINGULAR:case Ge nderConst.MALE_SINGULAR_GUESS:c=_tx("{name} est\u00e1 sin conexi\u00f3n. Los men sajes se enviar\u00e1n a su bandeja de entrada.",{name:this.firstName});break;de fault:c=_tx("{name} is offline. Your messages will be sent to their inbox.",{nam e:this.firstName});break;}}else c=_tx("{name} est\u00e1 desconectado\/a.",{name: this.firstName});}else c=_tx("No est\u00e1s conectado.");if(c){DOM.setContent(th is.statusEl,c);CSS.show(this.statusEl);this.scrollToBottom();}else CSS.hide(this .statusEl);if(b&&a){this._enableTab(a==AvailableList.IDLE);}else this._disableTa b();},_enableTab:function(a){this.tabDisabled=false;if(presence.inPopoutWindow){ CSS.removeClass(this.popoutTab,'disabled');CSS.conditionClass(this.popoutTab,'id le',a);CSS.addClass(this.popoutTab,'active');}CSS.removeClass(this.tabHandle,'di

sabled');CSS.conditionClass(this.tabHandle,'idle',a);CSS.addClass(this.tabHandle ,'active');},_disableTab:function(){this.tabDisabled=true;if(presence.inPopoutWi ndow){CSS.addClass(this.popoutTab,'disabled');CSS.removeClass(this.popoutTab,'id le');CSS.removeClass(this.popoutTab,'active');}CSS.addClass(this.tabHandle,'disa bled');CSS.removeClass(this.tabHandle,'idle');CSS.removeClass(this.tabHandle,'ac tive');},handleResize:function(){var a=this.isUserScrolled();Dock._resizeNubFlyo ut(this.tabHandle);!a&&this.scrollToBottom();},isUserScrolled:function(){return (this.chatConv.scrollHeight>this.chatConv.scrollTop+this.chatConv.clientHeight); },scrollToBottom:function(){if(!this.focused)return;this.chatConv.scrollTop=this .chatConv.scrollHeight;},unfocus:function(){if(!this.focused)return;this.focused =false;if(this.inDock){Dock.hide(this.tabHandle);}else CSS.removeClass(this.tabH andle,'focused');this.inform('unfocus');},focus:function(c,a,b){if(this.focused) return;this.focused=true;this._isFragileMode=false;this._markRead();if(this.inDo ck){Dock.show(this.tabHandle);}else CSS.addClass(this.tabHandle,'focused');if(!c )this._onFocusUIActions(b);if(!this.historyLoaded&&this.pendingNewRecipients.len gth===0)this.getHistory(false);this.inform('focus');},_onFocusUIActions:function (a){this.handleResize();this.scrollToBottom();this.focusChatInput(a);},_startBou nce:function(){var a=-8;this.bounceAnimation=animation(this.tabCount).to('top',16).duration(this.bounceDuration+40).checkpoint().to('top',a).duration(this.boun ceDuration).checkpoint().to('top',-16).duration(this.bounceDuration+40).checkpoi nt().to('top',a).duration(this.bounceDuration).checkpoint().to('top',-12).durati on(this.bounceDuration).checkpoint().to('top',-10).duration(this.bounceDuration) .checkpoint().to('top',a).duration(this.bounceDuration).checkpoint().go();},_sto pBounce:function(){if(this.bounceAnimation){this.bounceAnimation.stop();this.bou nceAnimation=null;}},close:function(){if(this.inDock)Dock.unregisterNubControlle r(this.tabHandle);while(this._handlers.length)this._handlers.pop().remove();this ._subscriptions.each(Arbiter.unsubscribe);MessagingEvents.unsubscribe(this._mess agingToken);this._callIncomingToken&&VideoEvents.unsubscribe(this._callIncomingT oken);if(this._textareaListener){var a=DataStore.get(this.chatInput,'DOMControl' );a.unsubscribe(this._textareaListener);delete this._textareaListener;this._text areaListener=null;}this.tabHandle.parentNode.removeChild(this.tabHandle);},newTy ping:function(c){var b=c.from;var e=c.to;var f=c.st;var a=c.fl;if(!ChatConfig.ge t('typing_notifications')){return;}else if((new Date()-this.lastMessageAt)<this. typingIndicator.notifyDelay)return;presence.debug('typing from '+b+': '+f);var d =(f==TypingIndicator.TYPING)&&(this.numMissed==0);if(e!=this.id){if(presence.inP opoutWindow)CSS.conditionClass(this.popoutTab,'typing',d);CSS.conditionClass(thi s.tabHandle,'typing',d);AvailableList.set(this.id,AvailableList.ACTIVE,a);}},new Msg:function(e){var a=e.from;var i=e.to;var j=e.type;var c=e.msg;var h=c.time;va r d=c.msgID;this.lastMessageAt=new Date();var f=this.chatDisplay.addToHistory(th is.id,e);if(a!=this.chatDisplay.user){var g=this.chatDisplay.isSquelched() this .chatDisplay.isSquelchedTab(this.id);this._isFragileMode=false;if(g){this._markR ead(h);}else{if(this.focused){this._markRead(h);if(!this.isWindowFocused)this.pl aySound();}else this._markUnread(h);this._messagingMarkAsRead();}if(presence.inP opoutWindow)CSS.removeClass(this.popoutTab,'typing');CSS.removeClass(this.tabHan dle,'typing');}else{this._markRead();if(this._removeDuplicatePendingMessage(d))f =false;}f=this.getMessageTypeInfo(j).visible&&f;if(f){var b=this.isUserScrolled( );this.renderMsg(a,i,h,c);this._toggleClearChatHistory(true);!b&&this.scrollToBo ttom();this.lastLogItem=e;}},_removeDuplicatePendingMessage:function(b){for(var a=0;a<this.pendingSentMsgs.length;a++)if(b==this.pendingSentMsgs[a].msgID){var c =this.pendingSentMsgs.splice(a,1);this._popSendQueue();this.chatDisplay.reportLa tency(new Date().getTime()-c[0].created);return true;}return false;},getInputEle m:function(){return this.chatInput;},_messagingMarkAsRead:function(){if(!ChatCon fig.get('titan'))return;this._clearMessagingMarkAsRead();var a=chatOptions.getSe tting('idle_cutoff');if(a&&UserActivity.isActive(a)){this._messagingMarkThreadAs Read(this.id);}else this._pendingMessagingMarkAsRead=UserActivity.subscribe(this ._messagingMarkAsRead.bind(this));},_messagingMarkThreadAsRead:function(a){Messa ging.markUserThreadAsRead(a);},_clearMessagingMarkAsRead:function(){if(this._pen dingMessagingMarkAsRead){UserActivity.unsubscribe(this._pendingMessagingMarkAsRe ad);delete this._pendingMessagingMarkAsRead;}},_markRead:function(){this._update NumMissed(0);this._stopBounce();},_markUnread:function(a){this._updateNumMissed(

this.numMissed+1,a);this._startBounce();this.playSound();},squelch:function(){th is._markRead();},_updateNumMissed:function(a,b){if(a==this.numMissed (b&&b<=thi s.missedTime))return;if(a>99)a=99;this.numMissed=a;this.missedTime=b;this._updat eNumMissedDisplay();},_updateNumMissedDisplay:function(){DOM.setContent(this.tab Count,this.numMissed);if(this.inDock)window.chatTabSlider&&chatTabSlider.updateM issedCount();CSS.conditionClass(this.tabHandle,'highlight',this.numMissed>0);CSS .conditionShow(this.tabCount,this.numMissed>0);},_checkDateBreak:function(d){var c=new Date();c.setTime(d);var b=new Date();if(this.lastLogItem)b.setTime(this.l astLogItem.time);var a=null;if(!this.lastLogItem c.getDate()!==b.getDate() c.g etMonth()!==b.getMonth()){a=this.chatDisplay.templates['chat-msg-date-break'].re nder();DOM.setContent(a,renderDate(c,!presence.inPopoutWindow));DOM.appendConten t(this.chatConvContent,a);this.currentMsgGroup=null;}},_renderVideoMsg:function( a,b){if(presence.inPopoutWindow)return;ChatUserInfoManager.get(this.id,function( c){this._renderVideoMsgWithName(a,b,c.firstName);}.bind(this));},_renderVideoMsg WithName:function(f,g,b){var d=this.chatDisplay.templates['chat-video-msg'].rend er();var e=XHPTemplate.getNode(d,'message');var k=XHPTemplate.getNode(d,'timesta mp');var a=true;var i=g.start_time presence.getTime();var h=this.chatDisplay.re nderServerTime(i);this._checkDateBreak(i);DOM.setContent(k,h);if(f=='missed-call '){Bootloader.loadComponents('VideoChatPlugin',function(){DOM.setContent(e,_tx(" {firstname} te ha llamado",{firstname:b}));if(ChatConfig.get('video.can_call',fa lse)&&VideoChatPlugin.isSupported()){var l=$N('a',{href:'#',className:'callBackL ink'},_tx("Volver a llamar"));Event.listen(l,'click',(function(){VideoEvents.inf orm(VideoEvents.START_CALL_UI,{idTarget:this.id});return false;}).bind(this));DO M.appendContent(e,[HTML(' &middot; '),l]);}DOM.appendContent(this.chatConvConten t,d);}.bind(this));a=false;}else{var c=f=='caller-history' (f=='connected-call' &&g.to==presence.user);var j=c?_tx("Has llamado a {firstname}",{firstname:b}):_t x("{firstname} te ha llamado",{firstname:b});DOM.setContent(e,HTML(j));}a&&DOM.a ppendContent(this.chatConvContent,d);this.currentMsgGroup=null;},renderMsg:funct ion(g,v,u,m,p,i,d){this._checkDateBreak(u);var k=this.chatDisplay.templates['cha t-msg'].render();k.id='msg_'+this.id+'_'+p;if(ChatConfig.get('messaging_future') )CSS.conditionClass(k,'old',new Date()-u>ChatConfig.get('chat_grayout_time_ms')) ;var h=m.text.substr(0,4)=='?OTR';var s=false;CSS.conditionClass(k,'cyphertext', h);if(h){DOM.setContent(k,_tx("[mensaje encriptado]"));}else{var n=[];var o=m.te xt;var t;var q;var j;if(m.spoof){q=new RegExp('^\\s*<([^<>]+?)>\\s+');j=o.match( q);if(j){o=o.substr(j[0].length);d=this._renderMsgWarning(j[1]);}}if(m.truncated m.forward m.attachment){q=new RegExp('(?:\\.{3}\\s+)?'+'(?:<([^<>]+?)>\\s+)?' +'(?:<([^<>]+?)>\\s+)?'+'(\\S+)\\s*$');j=o.match(q);if(j){o=o.substr(0,o.lastInd exOf(j[0]));var t=j[3];if(m.truncated){n.push(HTML('&hellip; '));var l=$N('a',{h ref:t,className:'more'},_tx("Ver todo"));n.push(l);}if(m.forward){var f=this.cha tDisplay.templates['chat-msg-forward'].render();f.href=t;var e=XHPTemplate.getNo de(f,'label');DOM.setContent(e,j[1]);n.push($N('div',f));s=true;}if(m.attachment ){var b=this.chatDisplay.templates['chat-msg-attachment'].render();b.href=t;var a=XHPTemplate.getNode(b,'label');DOM.setContent(a,j[2] j[1]);n.push($N('div',b) );s=true;}}}if(!s&&URLScraper.match(o))s=true;if(!this.chatDisplay.user this.ch atDisplay.user==g)s=false;n.unshift(HTML(this._renderMsgHtmlize(o)));DOM.setCont ent(k,n);}var c=this.getCurrentMsgGroup(g,v,u);if(s&&ChatConfig.get('report')){C SS.show(XHPTemplate.getNode(c,'reportLinkWithDot'));var r=URI(this.chatDisplay.r eportURL).addQueryData({id:g}).addQueryData({src:'timestamp_report_link'});repor tLink=XHPTemplate.getNode(c,'reportLink');reportLink.setAttribute('href',r);}thi s.addMessageToGroup(k,c);d&&this.addMessageToGroup(d,c);},_renderMsgHtmlize:func tion(a){return html_hyperlink(a '',this._processStyledText.bind(this,this.convT extEmoteProcessor),null,true);},newVideoMsg:function(e,c){var d=c.time presence .getTime();var b={type:'videochat',videoMsg:e,time:d,params:c};if(e==='missed-ca ll')if(this.focused){this._markRead(d);this._messagingMarkAsRead();if(!this.isWi ndowFocused)this.playSound();}else this._markUnread(d);var a=this.isUserScrolled ();this._renderVideoMsg(e,c);this._toggleClearChatHistory(true);!a&&this.scrollT oBottom();this.lastLogItem=b;this.chatDisplay.addToHistory(this.id,b);},_process StyledText:function(b,a){return b(a).replace(/\b_([^_\*]+)_\b/g,'<u>$1</u>').rep lace(/(\s ^)\*([^_\*]+)\*(?=$ \s)/g,'$1<b>$2</b>');},playSound:function(){if(Cha tConfig.get('sound_enabled')&&chatOptions.getSetting('sound'))Sound.play('/sound

/pling.mp3',true);},getMessageTypeInfo:function(a){if(a=='videochat'){return {vi sible:true,user:false,preserveHistory:true,videoMsg:true};}else return {visible: true,user:true,preserveHistory:false,msg:true};},addMessageToGroup:function(b,a) {DOM.appendContent(XHPTemplate.getNode(a,'messages'),b);},getCurrentMsgGroup:fun ction(a,i,g){if(!this.currentMsgGroup !this.lastLogItem this.lastLogItem.from! =a (g-this.lastLogItem.time)>this.msgBunchTime){var c=this.chatDisplay.template s[this.msgGroupRendererName].render();var d=XHPTemplate.getNode(c,'profileLink') ;var e=XHPTemplate.getNode(c,'profilePhoto');var f=function(j){if(CSS.hasClass(d ,'profileTooltipLink')){TooltipLink.setTooltipText(d,j);}else if(j){e.setAttribu te('title',j);}else e.removeAttribute('title');};var b=a==this.chatDisplay.user; !b&&f('');ChatUserInfoManager.get(a,function(j){e.src=j.thumbSrc;d.setAttribute( 'href',this.chatDisplay.profileURL+'?id='+a);!b&&f(j.name this.name);}.bind(thi s));var h=this.chatDisplay.renderServerTime(g);DOM.setContent(XHPTemplate.getNod e(c,'timestamp'),h);DOM.appendContent(this.chatConvContent,c);this.currentMsgGro up=c;}return this.currentMsgGroup;},getAvailability:function(){return AvailableL ist.get(this.id);},getTabDOM:function(){return this.tabHandle;},_isFragileMode:f alse,setFragileMode:function(){this._isFragileMode=true;this._subscriptions.push (Arbiter.subscribe('page_transition',this._removeFragileTab.bind(this)));},_remo veFragileTab:function(){if(!this._isFragileMode)return;this.chatDisplay.closeTab (this.id);},_toggleClearChatHistory:function(a){if(this.actions)this.actions.set Visible('clearHistory',a).setVisible('reportLink',a).refresh();}});function rend erDate(a,e){if(e){var f=new Date();f.setHours(0);f.setMinutes(0);f.setSeconds(0) ;f.setMilliseconds(0);var b=24*60*60*1000;var c=f.getTime()-a.getTime();if(c<=0) {return _tx("Hoy");}else if(c<b)return _tx("Ayer");}var d='';switch(a.getMonth() ){case 0:d=_tx("enero");break;case 1:d=_tx("febrero");break;case 2:d=_tx("marzo" );break;case 3:d=_tx("abril");break;case 4:d=_tx("mayo");break;case 5:d=_tx("jun io");break;case 6:d=_tx("julio");break;case 7:d=_tx("agosto");break;case 8:d=_tx ("septiembre");break;case 9:d=_tx("octubre");break;case 10:d=_tx("noviembre");br eak;case 11:d=_tx("diciembre");break;}return _tx("{date} de {month}",{month:d,da te:a.getDate()});}onloadRegister(function(){if(ua.firefox()){var a=function(){re turn CSS.getStyle(document.body,'overflowX')+' '+CSS.getStyle(document.body,'ove rflowY');};var b=a();document.body.addEventListener('DOMAttrModified',function(e vent){if(event.getTarget()===document.body&&(event.attrName==='class' event.att rName==='style')){var c=a();if(c!==b){b=c;Arbiter.inform('overflow-applied-to-bo dy');}}},false);}}); function ChatDisplayInterim(e,c,a,d,b,f){this.histories=e;this.everSentMessage=c ;this.user=presence.user;var g=env_get('www_base');this.profileURL=g+'profile.ph p';this.messageURL=g+'ajax/messaging/composer.php';this.settingsURL='/ajax/chat/ settings.php';this.tabsURL='/ajax/chat/tabs.php';this.reportURL='/ajax/chat/repo rt.php';this.templates=f;this.controllers=copy_properties({friend:'ChatTab',grou p:'ChatGroupTab',thread:'ChatThreadTab'},b);this.useUICookieCache=ChatConfig.get ('ui_cookie_cache');this.renderServerTime=ChatConfig.get('24h_times')?this._rend erServerTime24hr:this._renderServerTime12hr;this.jabberSquelchInterval=300000;th is._squelchUntil=null;this._squelchedIds={};this._reportedLatencies=0;this._init (a,d);}ChatDisplayInterim.prototype={blinkTime:1500,initialBlinkDelay:3000,maxNu mTabs:20,_init:function(a,b){this.loaded=false;this.tabs={};this.tabList=[];this .numTabs=0;this.lastFocused=null;this.newMsgNames=[];this.newMsgNamesIndex=0;thi s.blinkingTimer=null;this.chatActivityTime=0;if(this.useUICookieCache){this.uiCh angeTime=0;this.uiCookieCacheTime=(Env.rep_lag+presence.sitevars.CHAT_UI_COOKIE_ CACHE_WINDOW)*1000;}this.initialFocusedChat=b;this.initialActiveChats=a;presence .registerStateStorer(this._store.bind(this));presence.registerStateLoader(this._ load.bind(this));var c=['unfocus_chat','focus_chat','close_chat','group_msg','th read_msg','msg','typ','video','chat_event','buddylist_overlay','start_multichat' ,'update_multichat_participants'].map(PresenceMessage.getArbiterMessageType);Arb iter.subscribe(c,this._handlePresenceMessage.bind(this));Arbiter.subscribe(Prese nceMessage.STARTED,this.start.bind(this));Arbiter.subscribe(PresenceMessage.SHUT DOWN,this.shutdown.bind(this));Arbiter.subscribe(PresenceMessage.RESTARTED,this. restart.bind(this));Arbiter.subscribe(PresenceMessage.WINDOW_RESIZED,this.handle Resize.bind(this));Arbiter.subscribe('channel/invalid_history',this.handleInvali dHistory.bind(this));Event.listen(window,'focus',this.onWindowFocus.bind(this));

Event.listen(window,'blur',this.onWindowBlur.bind(this));if(!presence.inPopoutWi ndow){var d=$('fbDockChatTabs');Toggler.createInstance(d);}},onWindowFocus:funct ion(){this.isWindowFocused=true;this.doStopBlinking();},onWindowBlur:function(){ this.isWindowFocused=false;},start:function(){for(var a in this.tabs)this.tabs[a ].start();},shutdown:function(){this._stopBlinking();},restart:function(){for(va r a in this.tabs)this.tabs[a].restart();},loadInitialUserInfo:function(c,d,a,b,e ){if(ChatUserInfos[c])return;ChatUserInfos[c]={name:d,firstName:a,thumbSrc:'',ge nder:b GenderConst.UNKNOWN,type:e 'friend'};},_loadInitialTabs:function(a,d){i f(!hasArrayNature(a)){var l=[];for(var b in a)l.push(copy_properties(a[b],{i:b}) );a=l;}for(var e=0,g=a.length;e<g;e++){var k=a[e];var f=k.i;if(this.tabs[f])cont inue;var i,c,m;if(f in ChatUserInfos){i=ChatUserInfos[f].name;c=ChatUserInfos[f] .firstName;m=ChatUserInfos[f].type;}else{i=k.n;if(!i)continue;c=k.fn getFirstNa me(i);m=k.type 'friend';}var j=k.m 0;var h=k.t 0;this.createTab(m,f,i,c,j,h); if(k.tb&&k.tt)this.updateMultichatToolbar(f,i,k.tb,k.tt);}if(presence.inPopoutWi ndow&&!d&&a.length)d=a[0].i;if(d&&(d!=this.focused))this._focusTab(d);window.cha tTabSlider&&chatTabSlider.addTab();},load:function(){Arbiter.subscribe('availabl e-list/initialized',function(){this._load(presence.state);Arbiter.inform('chat-d isplay/loaded',this,Arbiter.BEHAVIOR_PERSISTENT);}.bind(this));},loadTabFragile: function(b,c,a,d){if(presence.isOnline()&&!this.tabs[b]){this._loadInitialTabs([ {i:b,n:c,fn:a,type:d}]);this.tabs[b].setFragileMode();window.EagleEye&&EagleEye. log('chat-tab',{id:b});}},_load:function(f){var c=false;if(f){if(this.blinkingTi mer&&f.sb)this._stopBlinking();this._squelchUntil=f.sq;this.chatActivityTime=ver ifyNumber(f.ct)*1000;if(this.useUICookieCache){var d=presence.getTime();this.uiC hangeTime=Math.max(this.uiChangeTime,verifyNumber(f.uct)*1000);if(!this.loaded)i f(d-this.uiChangeTime<this.uiCookieCacheTime){presence.debug('chatDisplay: loadi ng tabs from cookie cache');var e=(d-f.ut>60*60*1000);if(f.t)for(var a=0,b=f.t.l ength;a<b;a++){if(e)f.t[a].m=0;if(f.t[a].n)continue;f.t[a].n=f.t[a].fn;}this._lo adInitialTabs.bind(this,f.t,f.f).defer();c=true;}}}if(!this.loaded&&!c){presence .debug('chatDisplay: loading tabs from server state');this._loadInitialTabs.bind (this,this.initialActiveChats,this.initialFocusedChat).defer();this.initialFocus edChat=this.initialActiveChats=false;}this.loaded=true;},_store:function(d){d.ct =Math.floor(this.chatActivityTime*.001);d.sb=(this.blinkingTimer==null)?1:0;var e=this.getSquelchUntil();if(e!==null)d.sq=e;if(this.useUICookieCache){d.t=[];d.f =null;d.uct=0;var c=presence.getTime();if(c-this.uiChangeTime<this.uiCookieCache Time){for(var a=0,b=this.tabList.length;a<b;a++){var g=this.tabList[a];var f={i: g.id,m:g.numMissed};if(g.firstName==g.name){f.fn=g.name;}else{f.n=g.name;if(g.is Canonical()&&g.firstName!=getFirstName(g.name))f.fn=g.firstName;}d.t.push(f);}d. f=this.focused;d.uct=Math.floor(this.uiChangeTime*.001);}}return d;},handleResiz e:function(){if(!this.focused)return;var a=this.tabs[this.focused];a.handleResiz e();},handleInvalidHistory:function(){var a=this.focused&&this.tabs[this.focused ];if(a)a.getHistory(true);},_sendTabStateChange:function(a){a.window_id=presence .windowID;new AsyncRequest().setURI(this.tabsURL).setData(a).setHandler(this._on CheckTabStateChangeResponse.bind(this,a)).setErrorHandler(bagofholding).setAllow CrossPageTransition(true).send();},_sendDeferredTabStateChange:function(a){clear Timeout(this._deferredTabStateChange);this._deferredTabStateChange=this._sendTab StateChange.bind(this,a).defer();},_onCheckTabStateChangeResponse:function(b,d){ var a=(b&&b.focus_chat) null;var e=a&&AvailableList.get(a);var c=d.getPayload() ;if(c&&c.overlay){AvailableList.addLegacyOverlay(c.overlay);if(e&&!AvailableList .get(a))presence.error("presence:ol_on_to_off:id="+a);}},reloadTabs:function(){f or(var a in this.tabs)this.tabs[a].loadData();},_closeTab:function(a){if(!this.t abs[a])return;var c=this.tabList.indexOf(this.tabs[a]);if(this.focused==a)if(pre sence.inPopoutWindow){var b=this.tabList.length;var d=this.tabList[((c+(c?-1:1)) +b)%b].id;if(d!=a){this.focusTab(d);}else this.focused=null;}else this.focused=n ull;this.tabs[a].close();this.tabList.splice(c,1);delete this.tabs[a];this.numTa bs--;Arbiter.inform('chat/conversation-closed',{id:a});window.chatTabSlider&&cha tTabSlider.close();},uiChanged:function(){if(this.useUICookieCache){this.uiChang eTime=presence.getTime();presence.doSync();}},closeTab:function(a){this._closeTa b(a);this._sendTabStateChange({close_chat:a});this.uiChanged();},_unfocus:functi on(b){var a=this.focused;if(!a (b&&a!=b))return false;this.focused=null;if(pres ence.inPopoutWindow)this.tabs[a].deselectPopoutChat();this.tabs[a].unfocus();ret

urn true;},unfocus:function(a,b){if(this._unfocus(a)&&b!==false){this._sendDefer redTabStateChange({unfocus_chat:1});this.uiChanged();}this.lastFocused=null;},un focusNoSync:function(){this._unfocus();},refocus:function(){if(!this.lastFocused !this.tabs[this.lastFocused])return null;this._focusTab(this.lastFocused);},_f ocusTab:function(d,b,e,a,f){if(d==this.focused)return this.tabs[d];if(!this.tabs [d]){if(typeof e=='undefined')if(ChatUserInfos[d]&&ChatUserInfos[d].name){e=Chat UserInfos[d].name;a=ChatUserInfos[d].firstName;}else{presence.warn("chat:tab cre ation aborted:couldn't create tab "+d+" since no name is specified");return null ;}if(typeof a=='undefined')a=e;if(typeof f=='undefined')if(ChatUserInfos[d]&&Cha tUserInfos[d].type){f=ChatUserInfos[d].type;}else f='friend';this.createTab(f,d, e,a);window.chatTabSlider&&chatTabSlider.addTab(d);}window.chatTabSlider&&chatTa bSlider.gotoTab(d);if(this.focused){this.tabs[this.focused].unfocus();if(presenc e.inPopoutWindow)this.tabs[this.focused].deselectPopoutChat();}this.focused=d;th is.lastFocused=d;if(this.focused){var c=!presence.inPopoutWindow&&presence.poppe dOut;if(this.tabs[this.focused])this.tabs[this.focused].focus(c,this.loaded,b);i f(presence.inPopoutWindow)this.tabs[d].selectPopoutChat();}return this.tabs[d];} ,focusTab:function(c,b,d,a,e){presence.pauseSync();this._focusTab(c,b,d,a,e);thi s._sendDeferredTabStateChange({focus_chat:c});this.uiChanged();this.chatActivity Time=(new Date()).getTime();this.doStopBlinking();presence.resumeSync();},toggle Tab:function(c,b,d,a){if(this.focused==c){this.unfocus();}else this.focusTab(c,b ,d,a);},getNextTabId:function(a,e){if(!(a in this.tabs))return -1;var c=this.tab List.indexOf(this.tabs[a]);if(!presence.inPopoutWindow)e=!e;var d=a;if(c>=0){if( e){c--;}else c++;var b=this.tabList.length;d=this.tabList[(c+b)%b].id;}return pa rseInt(d,10);},_handleBlinking:function(b,a){var c=(b==this.user);if(c){this.doS topBlinking(true);}else if(this.isWindowFocused){setTimeout(this.doStopBlinking. bind(this,true),500);}else if(!presence.isOpera){this.newMsgNames.push(a);if(!th is.blinkingTimer)this.blinkingTimer=setTimeout(function(){this.blinkingTimer=set Interval(this._doBlink.bind(this),this.blinkTime);}.bind(this),this.initialBlink Delay);}},_doBlink:function(){if(this._isBlinking){DocumentTitle.set(DocumentTit le.get());this._isBlinking=false;}else{if(this.newMsgNames&&this.newMsgNames.len gth>0){if(this.newMsgNamesIndex>=this.newMsgNames.length)this.newMsgNamesIndex=0 ;var a=this.newMsgNames[this.newMsgNamesIndex++];DocumentTitle.set(_tx("\u00a1{n ame} te ha enviado un mensaje!",{name:a}),true);}else DocumentTitle.set(_tx("Nue vo mensaje"),true);this._isBlinking=true;}},doStopBlinking:function(a){if(this.b linkingTimer a){this._stopBlinking();presence.doSync();}},_stopBlinking:functio n(){if(this.blinkingTimer){if(this._isBlinking)this._doBlink();clearInterval(thi s.blinkingTimer);this.blinkingTimer=null;this.newMsgNames=[];this.newMsgNamesInd ex=0;}},_isChatMessage:function(a){return a.type=='msg' a.type=='group_msg' a. type=='thread_msg';},_handlePresenceMessage:function(n,a){if(!Chat.isOnline())re turn;var h=a.obj;if(h.window_id==presence.windowID)return;var f=null;if(h.from== this.user){f=h.id h.to;var e=!!h.csid;this.setSquelched(e);if(e)this._closeTab( f);}else f=h.id h.from;var l=this.tabs[f];var m=(ChatUserInfos[f]&&ChatUserInfo s[f].type) h.tab_type 'friend';var j=this.isSquelched();var k=this.isSquelched Tab(f);switch(h.type){case 'unfocus_chat':this._unfocus();break;case 'focus_chat ':if(!j&&!k)this._focusTab(f,undefined,undefined,undefined,m);break;case 'close_ chat':this._closeTab(f);break;case 'thread_msg':case 'group_msg':case 'msg':var c=(h.from==this.user);var g,b,d;if(m=='group'){g=h.to_name;b=g;d=GenderConst.UNK NOWN_PLURAL;}else if(c){g=h.to_name;b=h.to_first_name?h.to_first_name:getFirstNa me(g);d=h.to_gender;}else{g=h.from_name;b=h.from_first_name?h.from_first_name:ge tFirstName(g);d=h.from_gender;}this.loadInitialUserInfo(f,g,b,d,m);if(!c&&m=='fr iend')AvailableList.set(f,AvailableList.ACTIVE,h.fl);if(!j&&!k&&!l){l=this.creat eTab(m,f,g,b);window.chatTabSlider&&chatTabSlider.addTab(f);if(!this.focused){th is.focusTab(f);}else l.getHistory();}if(!j&&!k&&(presence.inPopoutWindow !prese nce.poppedOut))this._handleBlinking(h.from,b);h.time=h.msg.time;if(l){l.newMsg(h );if(h.type=='thread_msg'){l.setHasThread(true);this.updateMultichatToolbar(f,h. nub_name,h.titlebar,h.tooltip);this.setTabRecipients(f,h.recipients);}}else if(t his.histories[f])this.addToHistory(f,h);break;case 'typ':if(!j this.focused==f) l&&l.newTyping(h);break;case 'video':this._newVideoMessage(h);break;case 'chat_e vent':this._newChatEventMessage(h);break;case 'buddylist_overlay':for(var i in h .overlay)ChatUserInfoManager.get(i,function(){var o={};o[i]=h.overlay[i];Availab

leList.addLegacyOverlay(o);});break;case 'start_multichat':this.createMultichatT ab(f,h.nub_name,h.titlebar,h.tooltip);this.tabs[f].newActionLogMsg(h);break;case 'update_multichat_participants':this.updateMultichatToolbar(f,h.nub_name,h.titl ebar,h.tooltip);this.setTabRecipients(f,h.recipients);l&&l.newActionLogMsg(h);br eak;default:break;}},_newVideoMessage:function(a){Arbiter.subscribe('video-chat/ initialized',function(c,b){var e=a.from;var f=a.message_type;var g=a.parameters; var d=a.fl;b.handleMessage(e,f,g);if(e!=this.user&&f==b.START_SESSION){this.load InitialUserInfo(e,g.name,g.firstName,g.gender,'friend');AvailableList.set(e,Avai lableList.ACTIVE,d);}}.bind(this));},_newChatEventMessage:function(a){if(!presen ce.inPopoutWindow&&ChatConfig.get('video.can_be_called',false))this._handleVideo Event(a.from,a.event_name,a.parameters {});},_handleVideoEvent:function(b,a,c){ var d=this.tabs[b];switch(a){case 'missed-call':ChatUserInfoManager.get(b,functi on(e){if(!d)d=this.createTab('friend',b,e.name,e.firstName);if(!this.focused)thi s._focusTab(b);d.newVideoMsg(a,c);}.bind(this));break;case 'connected-call':if(b ==this.user)d=this.tabs[c.to];d&&d.newVideoMsg(a,c);break;}},_getBucketDescripti on:function(d){var a=[500,1000,2000,3000,5000];var b=["half_s","1s","2s","3s","5 s"];for(var c=0;c<a.length;c++)if(d<a[c])return b[c];return "over_5s";},reportLa tency:function(b){if(this._reportedLatencies<5){var a=this._getBucketDescription (b);presence.warn("presence:latency_"+a+":delay="+b+",sent="+this._reportedLaten cies);this._reportedLatencies++;}},_getIDsToNotifyVisibility:function(a){return keys(this.tabs);},getHistory:function(b,a){a=a false;if(!this.histories[b]&&a)t his.histories[b]=[];return this.histories[b];},addToHistory:function(e,g){var b= this.getHistory(e,true);var h=true;var f=null;for(var d=b.length-1;d>=0;d--)if(t his._isChatMessage(b[d])){f=b[d];break;}if(f&&g.time<=f.time){var a=false;for(d= 0;d<b.length;d++)if(this._isChatMessage(b[d])&&g.time==b[d].time){a=true;break;} if(a){presence.warn('tabs: already had this msg');return;}for(d=b.length-1;d>=0; d--){var c=b[d];if(this._isChatMessage(c)&&(c.to!=g.to (!c.time c.time<g.time) ))break;}presence.warn('tabs: merging new msg due to out-of-order server timesta mp');if(d==b.length-1){b.push(g);}else{b.splice(d+1,0,g);var i=this.tabs[e];if(i )i._setHistory(b);h=false;}}else this.histories[e].push(g);return h;},_renderSer verTime12hr:function(d){var e=new Date();e.setTime(d+presence.timeSkew);var b=e. getHours();var a='am';if(b>=12){a='pm';b-=12;}if(b==0)b=12;var c=e.getMinutes(); if(c<10)c='0'+c;var f=b+':'+c+a;return f;},_renderServerTime24hr:function(c){var d=new Date();d.setTime(c+presence.timeSkew);var a=d.getHours();if(a<10)a='0'+a; var b=d.getMinutes();if(b<10)b='0'+b;var e=a+':'+b;return e;},setSquelched:funct ion(c){if(c){var a=(new Date()).valueOf();var b=a+this.jabberSquelchInterval;thi s._squelchUntil=b;presence.doSync();}else if(this._squelchUntil){this._squelchUn til=null;presence.doSync();}},isSquelched:function(){return this.getSquelchUntil ()!==null;},setSquelchedTab:function(a,b){if(b){this._squelchedIds[a]=true;this. tabs[a]&&this.tabs[a].squelch();}else delete this._squelchedIds[a];},isSquelched Tab:function(a){return a in this._squelchedIds;},getSquelchUntil:function(){if(t his._squelchUntil===null)return null;var a=(new Date()).valueOf();var b=a+(this. jabberSquelchInterval+5000);if(b<this._squelchUntil){this.setSquelched(false);re turn null;}else if(a<this._squelchUntil){return this._squelchUntil;}else{this.se tSquelched(false);return null;}},_enforceTabLimit:function(){var a=0;while(this. numTabs>this.maxNumTabs&&a<this.numTabs-1)if(this.tabList[a].focused this.tabLi st[a].numMissed){++a;}else this.closeTab(this.tabList[a].id);},_addInitialRecipi ents:function(b,a){var c=this._getTypeaheadRecipients(b);c.push(''+b.id);a.addRe cipients(c);},_getTypeaheadRecipients:function(e){var f=DOM.find(e.tabHandle,'.A ddTypeahead');var c=DOM.scry(f,'input[type="hidden"]');var d=[];for(var a=0;a<c. length;a++){var b=c[a];if(b.name=='recipients[]')d.push(b.value);}return d;},tab HasTypeaheadRecipients:function(b){var a=this.tabs[b];return this._getTypeaheadR ecipients(a).length>0;},addMoreParticipants:function(c){var b=this.tabs[c];var a =this._getTypeaheadRecipients(b);b.addRecipients(a);if(b.getRecipients().length> 0&&!b.getHasThread())this.updateMultichatStatus(b.id,b.getRecipients(),a);},clos eAddTypeahead:function(a){var b=DOM.find(this.tabs[a].tabHandle,'.AddTypeahead') ;CSS.hide(b);},tabHasThread:function(a){return this.tabs[a].getHasThread();},upd ateMultichatStatus:function(d,c,b){var a={tid:d};if(c){a.recipients=c;a.newRecip ients=b;}new AsyncRequest().setURI('/ajax/chat/multichat_status.php').setData(a) .setHandler(bagofholding).setErrorHandler(bagofholding).send();},createMultichat

Tab:function(c,a,d,e){var b=this.tabs[this.focused];this.createTab('thread',c,a, a,0,0);this.tabs[c].setHasThread(false);this._addInitialRecipients(b,this.tabs[c ]);this.focusTab(c,true,a,a,'thread');this.tabs[c].setHistoryLoaded(true);this.u pdateMultichatToolbar(c,a,d,e);},setTabRecipients:function(b,a){if(this.tabs[b]) this.tabs[b].setRecipients(a);},updateMultichatToolbar:function(d,b,e,f){var c=t his.tabs[d];if(c){var a=DOM.find(c.getTabDOM(),'div.titlebarLabel');DOM.setConte nt(a,e);TooltipLink.setTooltipText(a.firstChild,f);c.updateName(b);}},createTab: function(h,c,e,b,f,d){var a=window[this.controllers[h]];var g=new a(this,c,e,b,f ,d);this.tabs[c]=g;this.tabList.push(g);this.numTabs++;Arbiter.inform('chat/conv ersation-opened',{id:c,conversation:g});this._enforceTabLimit();return g;}};func tion ChatDisplay(f,c,a,d,e,b,g){this.parent.construct(this,f,c,a,d,b,g);}ChatDis play.extend('ChatDisplayInterim'); function ChatBuddyList(){this.user=presence.user;this.buddyListID=ChatBuddyList. ID++;this.errorMode=false;this.shouldShowLoading=false;this.sortedList=[];this.f lMode=false;this.flData={};this.otherFriendsFlid='-1';this.botsFlid='-2';this.sh owingErrorMessage=false;this.flSortableGroup=null;this.reorderingLists=false;thi s.flOpts={};this.externalFlids=[];this.updateOverlay={};}copy_properties(ChatBud dyList,{ID:0,OVERLAY_ONLINE:0,OVERLAY_IDLE:1,OVERLAY_OFFLINE:-1,DEFAULT_OPTS:{fu llDisplay:true,excludeIds:{}},MAX_BUDDY_NAME_LENGTH:20});ChatBuddyList.mixin('Ar biter',{_lastRenderRev:null,_lastSortRev:null,_showTime:null,init:function(d,c,b ,a){this.root=d;this.flMode=b;this.flData=a;this.shouldShowLoading=c;this._log=E agleEye.createLogger('chat-buddylist',.1);this._init();Arbiter.subscribe(['buddy list/availability-changed','buddylist/updated'],this._render.bind(this));Arbiter .subscribe('buddylist/update-error',this._showLoadError.bind(this));Arbiter.subs cribe('buddylist/fl-changed',this._handleFlChange.bind(this));},initError:functi on(a){this.root=a;this.errorMode=true;this._init();},_init:function(){this.loade d=false;this._isVisible=false;this.updateDiff=0;this.rendered=false;this.showing Error=false;this.contentDiv=DOM.find(this.root,'div.content');this.buddyListErro r=DOM.find(this.root,'div.status');Arbiter.subscribe(PresenceMessage.getArbiterM essageType('fl_settings'),this._handleFLMessage.bind(this));Arbiter.subscribe('c hat/connect',this._showLoading.bind(this));this.setCompactDisplay(chatOptions.ge tSetting('compact_buddylist'));Arbiter.subscribe('chat/option-changed',this._upd ateSetting.bind(this));Arbiter.inform('buddylist/initialized',this,Arbiter.BEHAV IOR_PERSISTENT);this.inform('initialized',this,Arbiter.BEHAVIOR_PERSISTENT);},se tCompactDisplay:function(a){this.isCompactDisplay=a;if(this.isCompactDisplay){th is.itemHeight=18;}else this.itemHeight=22;if(this.rendered)this._render();},_han dleFLMessage:function(c,a){var b=a.obj;if(b.fl_mode)this._updateNames(b.fl_data) ;},_updateNames:function(b){for(var a in this.flData)if(typeof b[a]!='undefined' &&b[a].n!=this.flData[a].n){flname=b[a].n;elem=ge(this._getFriendListNameId(a)); if(elem)DOM.setContent(elem,flname);}},_flChanged:function(b,a){return (b!=this. flMode !are_equal(a,this.flData));},_onFlChange:function(d,c){this._dirtyRender ing();if(!this.rendered){this.flMode=d;this.flData=c;return;}var g=[];var h=[];v ar f=[];var e=[];if(this.flMode&&this.flMode==d){var b=this._groupAvailableListB yFl(true);for(var a in c)if(typeof this.flData[a]=='undefined'){if(c[a].h)contin ue;g.push(a);f.push(a);}else if(this.flData[a].h!=c[a].h){if(c[a].h){h.push(a);} else{g.push(a);if(c[a].o)f.push(a);}}else if(this.flData[a].o!=c[a].o)if(c[a].o) {f.push(a);}else e.push(a);for(var a in this.flData)if(typeof c[a]=='undefined') h.push(a);this.flMode=d;if(h.length!=0)this._removeFlidsFromBuddyList(h,b);if(e. length!=0)this._goOfflineToLists(e,true);this.flData=c;if(g.length!=0)this._addF lidsToDOM(g,b);if(f.length!=0)this._goOnlineToLists(f,true);}else if(this.flMode &&this.flMode!=d){var b=this._groupAvailableListByFl(true);h=keys(this.flData);t his.flMode=d;this.flData=c;this._addFlidsToDOM([null]);this._removeFlidsFromBudd yList(h,b);}else if(!this.flMode&&this.flMode!=d){for(var a in c){if(c[a].h)cont inue;g.push(a);if(c[a].o)f.push(a);}this.flMode=d;this.flData=c;this._removeFlid sFromDOM([null]);if(g.length>0)this._addFlidsToDOM(g);if(f.length>0)this._goOnli neToLists.bind(this,f,true).defer();}this._render();},_addFlidsToDOM:function(e, f){f=f this._groupAvailableListByFl(true);var a=this._getRenderedFriendLists(); var c=a[0];var h=$('fbChatBuddyListParent');for(var g=0;g<e.length;g++){var d=e[ g];if(this.flMode&&d){var b=DOM.create('div',{id:this._getFriendListId(d),classN ame:this._getFriendListItemClasses(d,f)});DOM.setContent(b,HTML(this._renderFrie

ndListHeader(d)));DOM.appendContent(b,HTML(this._renderFriendListContent(d,[]))) ;if(c==d){DOM.prependContent(h,b);}else{var j=a.indexOf(d);var i=a[j-1];DOM.inse rtAfter(ge(this._getFriendListId(i)),b);}this._addFlSortable(d);}else DOM.prepen dContent(h,HTML(this._renderFriendListContent(null,[])));}this._addFriendListLis teners(e);},_removeFlidsFromDOM:function(b){for(var c=0;c<b.length;c++){var a=b[ c];if(a){if(ge(this._getFriendListId(a))){DOM.remove($(this._getFriendListId(a)) );this._removeFlSortable(a);}}else{DOM.remove($(this._getAvailableMarkerId(a))); DOM.remove($(this._getIdleMarkerId(a)));}}},contentChanged:function(){this.infor m('content-changed');},show:function(){if(this._isVisible)return;this._showTime= this._showTime new Date();AvailableList.update();this._isVisible=true;if(!this. rendered){this.shouldShowLoading=true;this._firstRender();if(AvailableList.haveF ullList)this._render.bind(this).defer();}CSS.show(this.root);},hide:function(){i f(!this._isVisible)return;this._showTime=null;this._isVisible=false;this.exitReo rderingFlMode();CSS.hide(this.root);},_getUserFlid:function(c,a){if(a===null a= ==undefined){var b=this._getUserFlids(c);a=b[0];}return a;},_getSortedList:funct ion(){if(this._lastSortRev!=AvailableList.getRev()){this.sortedList=this._sort(A vailableList.getAvailableIDs());this._lastSortRev=AvailableList.getRev();}return this.sortedList;},getSortedListUI:function(a){if(!a&&this.flMode){var b=this._g roupAvailableListByFl(true);var c=[];for(var a in b)c=c.concat(b[a]);var d={};re turn c.filter(function(e){return !d[e]&&(d[e]=true);});}return this._getSortedLi st();},getFriendLists:function(){var a={};copy_properties(a,this.flData);delete a[this.otherFriendsFlid];delete a[this.botsFlid];return a;},_getRenderedFriendLi sts:function(){var b=[];for(var a in this.flData)if(!this.flData[a].h)b.push(a); return b;},_getFriendListsInChat:function(){var a=this._getRenderedFriendLists() ;a.remove(this.otherFriendsFlid);a.remove(this.botsFlid);return a;},updateUserIn fos:function(a){copy_properties(ChatUserInfos,a);},_sort:function(b){var a=this. _compareFunction.bind(this);b.sort(a);return b;},_compareFunction:function(a,d,b ,e){if(typeof b=='undefined')b=AvailableList.isIdle(a);if(typeof e=='undefined') e=AvailableList.isIdle(d);if(b^e)return b?1:-1;var c=ChatUserInfos[a].name.toLow erCase();var f=ChatUserInfos[d].name.toLowerCase();return (c<f)?-1:1;},itemOnCli ck:function(c){var b=DataStore.get(c,'id');var a=DataStore.get(c,'flid');presenc e.pauseSync();Chat.openTab(b);if(!this.isSticky())Chat.closeBuddyList();this.inf orm('buddylist/buddy-clicked',{flid:a,id:b});presence.resumeSync();},_renderItem :function(c,a,d){var i=ChatUserInfos[c];var f=i.name;var h=i.thumbSrc;var e=['<a ',' href="#"',' id="',this._getBuddyListItemId(c,a),'"',' class="clearfix friend ',(d?' idle':''),'"',' title="',f,'"',' data-id="',parseInt(c,10),'"',' data-fli d="',a,'"','>'];var b=!this.isCompactDisplay;var g=this._getFlOpts(a);b&=g.fullD isplay;if(b)e=e.concat('<img src="',h,'" />');e=e.concat('<span id="',this._getB uddyListItemNameId(c,a),'">',htmlize(f),'</span>','</a>');return e.join('');},_g roupAvailableListByFl:function(c,a){if(!this.flMode !this.flData)return null;c= c false;a=a false;var e={};for(var b in this.flData)e[b]=[];if(a)return e;var d=c?this._getSortedList():AvailableList.getAvailableIDs();d.forEach(function(h){ var g=FriendLists.get(h);if(g)for(var i=0;i<g.length;++i){var f=g[i];e[f]&&e[f]. push(h);}});return e;},_listNameInUse:function(b){for(var a in this.flData)if(th is.flData[a].n==b)return true;return false;},createFriendList:function(b){if(thi s._listNameInUse(b)){ErrorDialog.show(_tx("Se ha producido un error."),_tx("No p uedes tener dos listas con el mismo nombre. Crea un nombre distinto para esta li sta."));return;}var a={create:b};this._saveBuddyListSetting(a,function(){for(var c in this.flData)if(this.flData[c].n==b){this.scrollIntoView($(this._getFriendL istId(c)));Arbiter.inform('friend-list/new',{flid:c,fl_name:b});break;}}.bind(th is));},handleFlInChat:function(b,a){if(b){this._unHideFriendListFromChat(a);}els e this._hideFriendListFromChat(a);},_unHideFriendListFromChat:function(b){var d= this._getFriendListsInChat().length==0;var c=[b];var a={unhide_from_chat:1,flids :c};this.flData[b].h=0;this._saveBuddyListSetting(a,function(){this._showEmptyLi stMomentarily(b);this.scrollIntoView($(this._getFriendListId(b)));}.bind(this)); if(d){this._onFlChange(true,this.flData);}else this._addFlidsToDOM(c);},_hideFri endListFromChat:function(b){var d=this._getFriendListsInChat().length==1;var c=[ b];var a={hide_from_chat:1,flids:c};this.flData[b].h=1;this._saveBuddyListSettin g(a);if(d){this._onFlChange(false,this.flData);}else this._removeFlidsFromBuddyL ist(c);},_friendListHandleSwitchThrown:function(b){var a=this.flData[b].o;if(a){

this._goOfflineToLists([b]);}else this._goOnlineToLists([b]);},_friendListHandle SwitchMouseDown:function(b){var a=Event.listen(document,'mouseup',function(){a.r emove();this._friendListHandleSwitchThrown(b);}.bind(this));},_friendListHandleM ouseOver:function(a){if(this.reorderingLists)return;CSS.addClass($(this._getFrie ndListId(a)),'hover');},_friendListHandleMouseOut:function(a){CSS.removeClass($( this._getFriendListId(a)),'hover');},_saveBuddyListSetting:function(b,a){b.user= this.user;a=a bagofholding;new AsyncRequest().setData(b).setURI('/ajax/chat/bud dy_list_settings.php').setHandler(this._onBuddyListSettingSave.bind(this,a)).set AllowCrossPageTransition(true).send();},_goOnlineToLists:function(b,d){d=d fals e;var a={online_to_list:1,flids:b,read_only:d};var c=chatDisplay._getIDsToNotify Visibility(true);if(c)a.notify_ids=c;this._handleFlVisibilityChange(b,1);this._s aveBuddyListSetting(a);},_handleFlVisibilityChange:function(d,f,a){for(var e=0;e <d.length;e++){var c=d[e];var b=ge(this._getFriendListId(c));if(!b)continue;this .flData[c].o=f;if(f){CSS.addClass(b,'online');CSS.removeClass(b,'offline');if(c= =this.otherFriendsFlid)this._showEmptyListMomentarily(c);}else{CSS.addClass(b,'o ffline');CSS.removeClass(b,'online');}var g=DOM.scry(b,'div.titletip strong')[0] ;g&&DOM.setContent(g,this._getFriendListTooltipText(c));a&&a(c);}},_showEmptyLis tMomentarily:function(b){this.shownEmptyFlids=this.shownEmptyFlids {};this.show nEmptyFlids[b]=1;var a=ge(this._getFriendListId(b));if(a)CSS.addClass(a,'show_em pty_list');(function(){delete this.shownEmptyFlids[b];var c=ge(this._getFriendLi stId(b));if(c)CSS.removeClass(c,'show_empty_list');}).bind(this).defer(8000);},_ goOfflineToLists:function(b,e){e=e false;var c=this._groupAvailableListByFl();t his._handleFlVisibilityChange(b,0);if(!e){var a={offline_to_list:1,flids:b};var d=chatDisplay._getIDsToNotifyVisibility(true);if(d)a.notify_ids=d;this._saveBudd yListSetting(a);}},_removeFlidsFromBuddyList:function(a,b){this._removeFlidsFrom DOM(a);},_onBuddyListSettingSave:function(b,a){var d=a.getPayload();if(d){d.user Infos&&this.updateUserInfos(d.userInfos);d.availableList&&AvailableList.addLegac yAvailableList(d.availableList);if(d.flData){var c;if(typeof d.flMode!='undefine d'){c=d.flMode;}else c=true;this._onFlChange(c,d.flData);this._resetFlidClasses( );}b&&b();}},_resetFlidClasses:function(){if(!this.flMode)return;var c=this._gro upAvailableListByFl();for(var b in this.flData){var a=ge(this._getFriendListId(b ));if(a)CSS.setClass(a,this._getFriendListItemClasses(b,c));}},_getFriendListIte mClasses:function(b,e){var d=this.flData[b].o;var c=this.flData[b].h;var a=['fri end_list'];if(d){a.push('online');}else a.push('offline');if(!c&&this.shownEmpty Flids&&this.shownEmptyFlids[b])a.push('show_empty_list');if(b==this.otherFriends Flid){a.push('compact_friend_list');a.push('other_friends_list');}if(this.reorde ringLists&&(b==this.otherFriendsFlid b==this.botsFlid))a.push('suppress');retur n a.join(' ');},_renderFriendListHeader:function(c){var b=this.flData[c].n;var e =this.flData[c].o;var a='';var f=typeof this.flData[c].s!='undefined';if(!f&&c!= this.otherFriendsFlid)var a='<a href="/friends/ajax/edit_list.php?list_id='+c+'" '+'rel="dialog-post">'+_tx("Editar")+'</a>';var d=['<div class="friendlist_name ">','<span class="title"><a href="#" id="'+this._getFriendListNameId(c)+'">',htm lize(b),'</a></span>','<span class="edit_link">',a,'</span>','</div>'];if(!f)d.p ush('<div class="switch"><a class="online_status" ','>','<div class="titletip">< strong>',this._getFriendListTooltipText(c),'</strong></div>','</a>','</div>');re turn d.join('');},_getFriendListTooltipText:function(a){return this.flData[a].o? _tx("Desconectar"):_tx("Conectar");},registerExternalFriendList:function(b){if(! this.rendered)this._firstRender();var a='xfl_'+this.externalFlids.length;this.ex ternalFlids.push(a);this.flOpts[a]=b;return a;},_renderFriendListContent:functio n(a,i){var l;var d=this.flMode&&a;if(d){l=['<div id="',this._getFriendListContai nerId(a),'"','class="friend_list_container">'];}else l=[];l.push('<div id="',thi s._getAvailableMarkerId(a),'" class="suppress"></div>');var g=[];var b=false,c=f alse;for(var k=0;k<i.length;k++){var e=i[k];var f=this._isIdle(e);var j=[this._r enderItem(e,a,f)];if(f){b=true;g=g.concat(j);}else{c=true;l=l.concat(j);}}var h= (b&&c)?'':' hide_idle_marker';l.push('<div id="',this._getIdleMarkerId(a),'" cla ss="subheader',h,'"></div>');l=l.concat(g);if(d)l.push('</div>');return l.join(' ');},_isIdle:function(a){return AvailableList.isIdle(a);},_addFriendListListener s:function(c){if(!this.flMode)return;c=c this._getRenderedFriendLists();for(var d=0;d<c.length;d++){var b=c[d];if(typeof this.flData[b].s!='undefined')continue ;var a=$(this._getFriendListId(b));Event.listen(a,'mouseover',this._friendListHa

ndleMouseOver.bind(this,b));Event.listen(a,'mouseout',this._friendListHandleMous eOut.bind(this,b));var e=DOM.find(a,'a.online_status');Event.listen(e,'mousedown ',this._friendListHandleSwitchMouseDown.bind(this,b));}},_renderBuddyContent:fun ction(){var a=(AvailableList.getCount()?'hide_empty_item':'');var g=['<div class ="subgroup">','<div id="fbChatBuddyListParent" class="list_select">','<div id="' ,this._getBuddyListEmptyItemId(),'" class="info_text ',a,'">',_tx("No hay nadie disponible para charlar."),'</div>'];var c;var d={};if(this.flMode){c=keys(this. flData);d=this._groupAvailableListByFl(true);}else c=[null];for(var e=0;e<c.leng th;++e){var b=c[e];var f=[];if(this.flMode&&b){if(this.flData[b].h)continue;g.pu sh('<div id="',this._getFriendListId(b),'"','class="',this._getFriendListItemCla sses(b,d),'">',this._renderFriendListHeader(b));f=d[b];}else f=this._getSortedLi st();g.push(this._renderFriendListContent(b,f));if(this.flMode&&b)g.push('</div> ');}g.concat(['</div>','</div>']);return g.join('');},_render:function(){if(!thi s._isVisible this._lastRenderRev==AvailableList.getRev())return;this._lastRende rRev=AvailableList.getRev();this._getSortedList();CSS.conditionClass(this.conten tDiv,'compact',this.isCompactDisplay);DOM.setContent(this.contentDiv,HTML(this._ renderBuddyContent()));if(this.rendered){this._hideError();this._addFriendListLi steners();}if(this.errorMode)this._showLoadError();if(this.shouldShowLoading){th is._showLoading();this.shouldShowLoading=false;}else if(this._showTime){var a=ne w Date()-this._showTime;this._showTime=null;this._log({buddy_list_open:a});}},_f irstRender:function(){this._render();this.rendered=true;Event.listen(this.conten tDiv,'click',function(event){var a=Parent.byClass(event.getTarget(),'friend');a& &this.itemOnClick(a);}.bind(this));},updateItemDisplay:function(d){var a=Availab leList.get(d);if(!a)return;var g=this._getUserFlids(d);for(var c=0;c<g.length;c+ +){var b=g[c];var f=ge(this._getBuddyListItemId(d,b));if(!f)return;var e=a==Avai lableList.IDLE;f=HTML(this._renderItem(d,b,e)).getRootNode();}},_showLoadError:f unction(){this._showError(_tx("No se ha podido cargar la lista de amigos disponi bles."));},_showLoading:function(){this._showError(_tx("Cargando..."));},_hideEr ror:function(){this.showingError=false;CSS.removeClass(this.root,'error');this.c ontentChanged();},_showError:function(a){this._dirtyRendering();this.showingErro r=true;DOM.setContent(this.buddyListError,HTML(a));CSS.addClass(this.root,'error ');this.contentChanged();},isSticky:function(){return chatOptions.getSetting('st icky_buddylist');},enterErrorMode:function(a){this.exitErrorMode();this.exitReor deringFlMode();this.showingErrorMessage=true;var b=$N('div',{id:'error_fl_alert' },[$N('span',{className:'helper_text'},a),$N('input',{type:'button',className:'i nputbutton',value:_tx("Aceptar"),onclick:this.exitErrorMode.bind(this)})]);DOM.i nsertBefore(b,this.contentDiv);},exitErrorMode:function(){if(this.showingErrorMe ssage){DOM.remove($('error_fl_alert'));this.showingErrorMessage=false;}return fa lse;},enterReorderingFlMode:function(){if(this.reorderingLists)return;Bootloader .loadComponents('sort',function(){this.exitErrorMode();this.reorderingLists=true ;CSS.addClass(this.root,'reorder_fl');var a=this._getRenderedFriendLists();this. flSortableGroup=new SortableGroup();for(var c=0;c<a.length;c++){var b=a[c];if(b= =this.otherFriendsFlid b==this.botsFlid){CSS.addClass(this._getFriendListId(b), 'suppress');}else this._addFlSortable(b);}var d=$N('div',{id:'reorder_fl_alert'} ,[$N('span',{className:'helper_text'},_tx("Arrastra las listas para ordenarlas") ),$N('input',{type:'button',className:'inputbutton',value:_tx("Finalizar"),oncli ck:this.exitReorderingFlMode.bind(this)})]);DOM.insertBefore(d,this.contentDiv); this.inform('reorder-mode/enter');this.contentChanged();}.bind(this));},exitReor deringFlMode:function(){if(!this.reorderingLists)return;this._reorderFlids();DOM .remove($('reorder_fl_alert'));CSS.removeClass(this.root,'reorder_fl');var a=thi s._getRenderedFriendLists();for(var c=0;c<a.length;c++){var b=a[c];if(b==this.ot herFriendsFlid b==this.botsFlid){CSS.removeClass(this._getFriendListId(b),'supp ress');}else this._removeFlSortable(b);}this.reorderingLists=false;this.flSortab leGroup.destroy();this.flSortableGroup=null;this.inform('reorder-mode/exit');thi s.contentChanged();},_addFlSortable:function(a){if(this.flSortableGroup!=null)th is.flSortableGroup.addSortable(a,$(this._getFriendListId(a)));},_removeFlSortabl e:function(a){if(this.flSortableGroup!=null)this.flSortableGroup.removeSortable( a);},_reorderFlids:function(){var a={reorder:1,flids:this.flSortableGroup.getOrd er()};this._saveBuddyListSetting(a);},_getGlobalFlids:function(a){var b=this.flM ode&&this.flData?keys(this.flData):[null];return a?b:b.concat(this.externalFlids

);},_getUserFlids:function(d,a,b){var c=(a&&a.fl)?a.fl:FriendLists.get(d);if(!b) c=this._addExternalFlids(d,c);return c;},_addExternalFlids:function(d,b){b=b?$A( b):[];for(var c=0;c<this.externalFlids.length;c++){var a=this.externalFlids[c];v ar e=this._getFlOpts(a);if(!e.excludeIds[d])b.push(a);}return b;},_getFlOpts:fun ction(a){return this.flOpts[a] ChatBuddyList.DEFAULT_OPTS;},_getAvailableMarker Id:function(a){return this._encodeFlid('buddy_list_avail_marker',a);},_getIdleMa rkerId:function(a){return this._encodeFlid('buddy_list_idle_marker',a);},_getBud dyListItemId:function(b,a){return this._encodeFlid('buddy_list_item_'+b,a);},_ge tBuddyListItemNameId:function(b,a){return this._encodeFlid('buddy_list_item_name _'+b,a);},_getBuddyListEmptyItemId:function(){return 'buddy_list_empty_item';},_ encodeFlid:function(a,b){return (b?(b+'_'+a):a)+'_'+this.buddyListID;},_getFrien dListId:function(a){return this._encodeFlid('friend_list_item',a);},_getFriendLi stNameId:function(a){return this._encodeFlid('friend_list_name',a);},_getFriendL istContainerId:function(a){return this._encodeFlid('friend_list_container',a);}, debugPrintUpdateOverlay:function(){var b=this.updateOverlay;for(var a in b);},_u pdateSetting:function(a,b){this._dirtyRendering();switch(b.name){case 'compact_b uddylist':this.setCompactDisplay(b.value);break;}this._render();},_dirtyRenderin g:function(){this._lastRenderRev=null;},_handleFlChange:function(a,c){var d=c.fl Mode;var b=c.flData;if(this._flChanged(d,b))this._onFlChange(d,b);}}); function ChatBuddyListDropdown(){}ChatBuddyListDropdown.prototype={init:function (a){this.root=a;Selector.listen(a,'open',function(){this._resizeAndFlip();var b= Event.listen(window,'resize',this._resizeAndFlip.bind(this));var c=Selector.list en(a,'close',function(){b.remove();Selector.unsubscribe(c);});}.bind(this));},_r esizeAndFlip:function(){var a=Vector2.getElementPosition(this.root,'viewport');v ar g=Vector2.getViewportDimensions();var f=a.y>g.y/2;CSS.conditionClass(this.roo t,'uiSelectorBottomUp',f);if(!ua.ie() ua.ie()>7){var b=Selector.getSelectorMenu (this.root);var c=Vector2.getElementPosition(b,'viewport');if(f){availableHeight =a.y;}else availableHeight=g.y-c.y;var d=DOM.find(b,'ul.uiMenuInner');var e=b.sc rollHeight-d.scrollHeight;availableHeight-=e;CSS.setStyle(b,'max-height',availab leHeight+'px');}}}; function ChatBuddyListFriendListsDropdown(){this.parent.construct(this);}ChatBud dyListFriendListsDropdown.extend('ChatBuddyListDropdown');ChatBuddyListFriendLis tsDropdown.prototype={init:function(b,c,a){this.parent.init(b);this.template=c;t his.form=a;this.menu=DOM.find(b,'div.menu');this.noListsEl=DOM.find(b,'li.noList sAvailable');Arbiter.subscribe('buddylist/initialized',this._initBuddyList.bind( this));},_initBuddyList:function(a,b){this.buddyList=b;Event.listen(this.form,'s ubmit',this._onSubmitForm.bind(this));Selector.listen(this.root,'open',this._onO pen.bind(this));Selector.listen(this.root,'toggle',this._onToggle.bind(this));}, _clearFriendLists:function(){var a=Selector.getOptions(this.root);a.forEach(DOM. remove);},_onOpen:function(){var c=this.buddyList.getFriendLists();this._clearFr iendLists();if(count(c)>0){CSS.hide(this.noListsEl);var e=[$N('option')];var f=[ ];for(var b in c){var a=c[b].n;var g=this.template.render();g.setAttribute('data -label',a);var d=DOM.find(g,'span.itemLabel');DOM.setContent(d,a);DOM.insertBefo re(g,this.noListsEl);e.push($N('option',{value:b}));c[b].h===0&&f.push(b);}Selec tor.attachMenu(this.root,this.menu,$N('select',e));f.forEach(function(h){Selecto r.setSelected(this.root,h,true);}.bind(this));}else CSS.show(this.noListsEl);},_ onSubmitForm:function(event){if(!this.nameInput)this.nameInput=DOM.find(this.for m,'input.nameInput');var a=this.nameInput.value;this.buddyList.createFriendList( a);this.nameInput.value='';this.nameInput.blur();Selector.toggle(this.root);retu rn event.kill();},_onToggle:function(a){var c=a.option;var b=Selector.getOptionV alue(c);var d=Selector.isOptionSelected(c);this.buddyList.handleFlInChat(d,b);Se lector.toggle(this.root);}}; function ChatBuddyListOptionsDropdown(){this.parent.construct(this);}ChatBuddyLi stOptionsDropdown.extend('ChatBuddyListDropdown');ChatBuddyListOptionsDropdown.p rototype={init:function(a){this.parent.init(a);Arbiter.subscribe('buddylist/init ialized',this._initBuddyList.bind(this));Arbiter.subscribe('chat/option-changed' ,this._onOptionChanged.bind(this));},_initBuddyList:function(a,b){this.buddyList =b;Selector.listen(this.root,'open',this._onOpen.bind(this));Selector.listen(thi s.root,'select',this._onSelect.bind(this));Selector.listen(this.root,'toggle',th is._onToggle.bind(this));},changeSetting:function(c,d,a){var b={};b[c]=d;new Asy

ncRequest(chatDisplay.settingsURL).setHandler(this._onChangeSettingResponse.bind (this,c,d)).setErrorHandler(this._onChangeSettingError.bind(this,c,d)).setFinall yHandler(a).setData(b).setAllowCrossPageTransition(true).send();},_onChangeSetti ngResponse:function(a,c,b){chatOptions.setSetting(a,c);presence.doSync();},_onCh angeSettingError:function(a,c,b){Selector.setSelected(this.root,a,!c);Chat.enter ErrorMode(_tx("No es posible guardar tu configuraci\u00f3n de {Chat}",{Chat:_tx( "Chat")}));},_onOpen:function(){var b=Selector.getOption(this.root,'reorder');va r a=this.buddyList._getFriendListsInChat().length;Selector.setOptionEnabled(b,a> 1);},_onOptionChanged:function(a,b){var c=b.name;if(c==='sound')Selector.setSele cted(this.root,c,b.value);},_onSelect:function(b){if(this._pendingChange)return false;var a=Selector.getOptionValue(b.option);switch(a){case 'offline':return th is.toggleVisibility();case 'reorder':return this.reorderLists();case 'popin':ret urn this.popin();case 'popout':return this.popout();case 'upgrade':return this.u pgrade();}},_onToggle:function(a){if(this._pendingChange)return false;this._pend ingChange=true;CSS.addClass(a.option,'async_saving');var b=Selector.getOptionVal ue(a.option);var c=Selector.isOptionSelected(a.option);this.changeSetting(b,c,th is._doneToggling.bind(this,a));},_doneToggling:function(a){this._pendingChange=f alse;CSS.removeClass(a.option,'async_saving');},popin:function(){presence.popin( );Selector.toggle(this.root);return false;},popout:function(){presence.popout(); Selector.toggle(this.root);return false;},reorderLists:function(){this.buddyList .enterReorderingFlMode();Selector.toggle(this.root);return false;},toggleVisibil ity:function(){chatOptions.toggleVisibility();Selector.toggle(this.root);return false;},upgrade:function(){var a='/chat/upgrade.php?ref=optionsmenu';new Dialog( ).setAsyncURL(a).show();}}; var ChatConfig=window.ChatConfig (function(){var a={};return {get:function(c,b) {return c in a?a[c]:b;},set:function(b){if(arguments.length>1){var c={};c[b]=arg uments[1];b=c;}copy_properties(a,b);}};})(); function ChatOptions(b,a){this.visibility=!!b;this.settings=a;}ChatOptions.proto type={load:function(){presence.registerStateStorer(this._storeState.bind(this)); presence.registerStateLoader(this._loadState.bind(this));Arbiter.inform('chat-op tions/initialized',this,Arbiter.BEHAVIOR_PERSISTENT);},_storeState:function(a){a .vis=this.visibility?1:0;a.bls=this.getSetting('sticky_buddylist');a.blc=this.ge tSetting('compact_buddylist');a.snd=this.getSetting('sound');return a;},_loadSta te:function(a){if(a.vis!=this.visibility)this.setVisibility(!!a.vis);this.setSet ting('sticky_buddylist',a.bls);this.setSetting('compact_buddylist',a.blc);this.s etSetting('sound',a.snd);},setVisibility:function(a){if(a===this.visibility)retu rn;this.visibility=a;if(!ChatConfig.get('always_connect'))if(a){channelManager.i sActionRequest=true;channelManager.rebuild(ChannelRebuildReasons.UIRestart);}els e channelManager.setReady(false);Arbiter.inform('chat/visibility-changed',{sende r:this});},_onVisibilityResponse:function(a){presence.pauseSync();if(a)this.setV isibility(a);if(!presence.inPopoutWindow&&!a)chatDisplay.unfocus();presence.resu meSync();if(presence.poppedOut)presence.popout();},_onVisibilityError:function(b ){this.setVisibility(b);var a=_tx("Chat");Chat.enterErrorMode(_tx("No es posible guardar tu configuraci\u00f3n de {Chat}",{Chat:a}));},toggleVisibility:function (){this.sendVisibility(!this.visibility);},sendVisibility:function(c){if(this.vi sibility==c)return;var a={visibility:c};var b=chatDisplay._getIDsToNotifyVisibil ity(c);if(b)a.notify_ids=b;if(!c)this.setVisibility(c);this.visibilityAsync=new AsyncRequest().setHandler(this._onVisibilityResponse.shield(this,c)).setErrorHan dler(this._onVisibilityError.shield(this,!c)).setData(a).setURI(chatDisplay.sett ingsURL).setAllowCrossPageTransition(true).send();Arbiter.inform(c?'chat/connect ':'chat/disconnect');},getSetting:function(a){return this.settings[a];},setSetti ng:function(a,b){if(this.getSetting(a)==b)return;this.settings[a]=b;Arbiter.info rm('chat/option-changed',{name:a,value:b});}}; function ChatTabSlider(){this.inDock=!presence.inPopoutWindow;this.handleWidth=C hatConfig.get('bigbird_ui')?264:150;this.animationTime=210;this._init();}ChatTab Slider.prototype={_init:function(){this.org_s=0;this.numToShow=0;this.numShift=1 ;this.shiftByNumTabs=false;this.timer=null;this.skipAnimation=false;this.chatWid th=null;if(this.inDock){var a=$('fbDockChatTabSlider');this.chat=ge('fbDockChatT absWrapper');this.chatTabBar=ge('fbDockChatTabs');this.nextTab=DOM.find(a,'div.n ext');Event.listen(this.nextTab,'click',this.next.bind(this));this.prevTab=DOM.f

ind(a,'div.previous');Event.listen(this.prevTab,'click',this.prev.bind(this));th is.nextCounter=DOM.find(this.nextTab,'span.numTabs');this.prevCounter=DOM.find(t his.prevTab,'span.numTabs');this.numMissedNextCounter=DOM.find(this.nextTab,'spa n.numMessages');this.numMissedPrevCounter=DOM.find(this.prevTab,'span.numMessage s');Toggler.createInstance(this.chatTabBar);}else{this.chat=ge('chat');this.chat TabBar=ge('chat_tab_bar');this.nextTab=ge('chat_next_tab');this.prevTab=ge('chat _previous_tab');this.nextCounter=ge('next_count');this.prevCounter=ge('prev_coun t');this.numMissedNextCounter=ge('next_num_missed');this.numMissedPrevCounter=ge ('prev_num_missed');}this.numNext=0;this.numPrev=0;this.prevTabs={};this.nextTab s={};presence.registerStateLoader(this._load.bind(this));presence.registerStateS torer(this._store.bind(this));Event.listen(window,'resize',this._resize.bind(thi s,false));},load:function(){this._load(presence.state);this._resize(true);},_loa d:function(a){var b=0;if(a)b=(a.s?a.s:b);this._setPos(b);},_store:function(a){a. s=this._s;return a;},_calculate:function(a){this._setMaxWidth();if(a)this.maxWid th-=16;if(presence.poppedOut){this.numToShow=chatDisplay.numTabs;}else{this.numT oShow=parseInt(this.maxWidth/this.handleWidth);this.numToShow=this.numToShow>0?t his.numToShow:1;}if(this.shiftByNumTabs)this.numShift=this.numToShow;if(this._s! =null)this._setPos(this._s);},_setMaxWidth:function(){if(this.inDock){var d=docu ment.body.clientWidth;var a=Parent.byClass(this.chat,'fbDock').firstChild;for(;a ;a=a.nextSibling)d-=a.clientWidth;d+=this.chat.clientWidth;this.maxWidth=d-70;}e lse{var d=document.body.offsetWidth;if(ChatTabSlider.presenceWidthTest)var d=$(' presence_ui').offsetWidth;var b=['buddy_list_tab','presence_notifications_tab']; for(var c=0;c<b.length;c++)d-=(ge(b[c])&&$(b[c]).clientWidth!=undefined)?ge(b[c] ).clientWidth:0;this.maxWidth=(presence.poppedOut?d-254:d-138);}},_setPos:functi on(a){if(a<0)a=0;this._s=a;this._e=this._s+this.numToShow;},_doSync:function(){v ar a=(this.org_s!=this._s);this.org_s=0;if(a)presence.doSync();},_build:function (){if(presence.poppedOut)return;var a=(this.numToShow>=chatDisplay.numTabs)?true :false;this.setVisibleTabs(a);if(a){this.resetCounters();}else this.updateCounte rs();this.updateMissedCount();},_resize:function(a){this.org_s=this._s;this._cal culate(a);this._build();this._doSync();if(chatDisplay.lastFocused!=null)this.got oTab(chatDisplay.lastFocused);},addTab:function(a){this._build();},gotoTab:funct ion(a){if(!(a in chatDisplay.tabs))return;var b=chatDisplay.tabList.indexOf(chat Display.tabs[a]);if(!this._inRange(b)){var c=(b-this.numToShow)+1;this._setPos(c );this._build();}},close:function(){this._setPos(((this.numPrev>0 this.numNext> 0)&&this._s>0)?this._s-1:0);this._calculate();this._build();},setVisibleTabs:fun ction(a){var d=chatDisplay.tabList;for(var b=0,c=d.length;b<c;++b)if(this._inRan ge(b,d[b].id) a){d[b].show();}else d[b].hide();},_inRange:function(c,b){var d,a =false;if(c>=this._s){d=true;delete this.prevTabs[b];}else this.prevTabs[b]=b;if (c<this._e){a=true;delete this.nextTabs[b];}else this.nextTabs[b]=b;return (d&&a );},updateMissedCount:function(){var c=0;var b=0;for(var a in this.prevTabs)c+=c hatDisplay.tabs[a]?chatDisplay.tabs[a].numMissed:0;this.numMissedPrevCounter.inn erHTML=c;CSS.conditionClass(this.numMissedPrevCounter,'hidden_elem',!c);for(var a in this.nextTabs)b+=chatDisplay.tabs[a]?chatDisplay.tabs[a].numMissed:0;this.n umMissedNextCounter.innerHTML=b;CSS.conditionClass(this.numMissedNextCounter,'hi dden_elem',!b);},updateCounters:function(){this.numNext=chatDisplay.numTabs-this ._e;this.numPrev=this._s;if(this.numNext<=0){this.numNext=0;CSS.addClass(this.ne xtTab,'disabled');}else CSS.removeClass(this.nextTab,'disabled');if(this.numPrev <=0){this.numPrev=0;CSS.addClass(this.prevTab,'disabled');}else CSS.removeClass( this.prevTab,'disabled');if(this.numPrev>0 this.numNext>0){if(this.inDock){CSS. show(this.nextTab);CSS.show(this.prevTab);}else{show('chat_next_tab');show('chat _previous_tab');}}else if(this.inDock){CSS.hide(this.nextTab);CSS.hide(this.prev Tab);}else{hide('chat_next_tab');hide('chat_previous_tab');}this.nextCounter.inn erHTML=this.numNext;this.prevCounter.innerHTML=this.numPrev;},resetCounters:func tion(){this._setPos(0);this.updateCounters();},shift:function(a){this.org_s=this ._s;chatDisplay.unfocusNoSync();this._shift.bind(this,a).defer();},_shift:functi on(a){this._setPos(this._s<0?0:this._s+a);this._slide(a);if(this.timer this.ski pAnimation){this._slideReset();this.skipAnimation=true;var b=setTimeout(function (){this.skipAnimation=false;}.bind(this),500);}else this.timer=setTimeout(functi on(){this._slideReset();}.bind(this),this.animationTime);},_slide:function(a){th is._slideSetup(false);this.setVisibleTabs(true);this.slideInc=(a*(this.handleWid

th));this.leftPos=-(a)*(this.numNext*(this.slideInc));this.chatTabBar.style.left =this.leftPos+'px';animation(this.chatTabBar).by('left',this.slideInc).duration( this.animationTime-10).go();},_slideSetup:function(a){this.chat.style.position=a ?'':'relative';this.chat.style.overflow=a?'visible':'hidden';if(!this.chatWidth) this.chatWidth=this.chatTabBar.clientWidth;if(a)this.chatWidth=null;this.chat.st yle.width=a?'':this.chatWidth+'px';this.chatTabBar.style.width=a?'':chatDisplay. numTabs*this.handleWidth+'px';this.chatTabBar.style.position=a?'':'absolute';},_ slideReset:function(){clearTimeout(this.timer);this.timer=null;this._slideSetup( true);this._build();var a=chatDisplay.lastFocused;if(a){var b=chatDisplay.tabLis t.indexOf(chatDisplay.tabs[a]);if(this._inRange(b)){chatDisplay.refocus();}else chatDisplay.lastFocused=null;}this._doSync();},next:function(){this.numNext&&thi s.shift(this.numShift);return false;},prev:function(){this.numPrev&&this.shift(this.numShift);return false;}};

Sign up to vote on this title
UsefulNot useful