📄 chatui.as
字号:
} this.selfRoomId = roomid; for (var i = 0; i < this.mc.roomChooser.getLength(); i ++) { if (this.mc.roomChooser.getItemAt(i).data.id == this.selfRoomId) { this.mc.roomChooser.setChangeHandler(null); this.mc.roomChooser.setSelectedIndex(i); this.mc.roomChooser.setChangeHandler('onRoomChanged', this); break; } } newRoom.setOpened(true); this.addClientMessage(this.selectedLanguage.messages.selfenterroom, null, newRoom, true, timestamp); this.callModuleFunc('mOnRoomChanged', {room : newRoom.label}); } //check if it is not a 'dummy' newRoom. if ((newRoom.label != null) && this.settings.layout.showUserList) { this.userListUpdateRoom(newRoom); if(id == this.selfUserId) { for(var i = 0; i < newRoom.users.length; i++) { var mc_ref = this.mc.userList.getItemRef( newRoom.users[i] ); if(mc_ref.blink_type == 1) { mc_ref.stopBlinking(1); } } } } if (this.selfInitialized && (id != this.selfUserId) && (newRoom.id == this.selfRoomId)) { if (newRoom.label == null) { this.error('ChatUI: userMovedTo: self newRoom cannot be added a \'dummy\' one.'); } this.addClientMessage(this.selectedLanguage.messages.enterroom, user, newRoom, true, timestamp); this.soundObj.attachSound('OtherUserEnters'); this.soundObj.start(); } else if(id == this.selfUserId) this.soundObj.attachSound('EnterRoom'); this.setInputFocus();};ChatUI.prototype.formatUserName = function(inUserName) { var username = replaceHTMLSpecChars(inUserName); var usernam = str_replace(username,"<b>",""); usernam = str_replace(usernam,"</b>",""); usernam = str_replace(usernam,"<i>",""); usernam = str_replace(usernam,"</i>",""); usernam = str_replace(usernam,"<B>",""); usernam = str_replace(usernam,"</B>",""); usernam = str_replace(usernam,"<I>",""); usernam = str_replace(usernam,"</I>",""); username = str_replace(username, usernam, areplaceHTMLSpecChars(usernam)); return username;}//args - additional optional argument.ChatUI.prototype.messageAddedTo = function(senderid, receiverid, roomid, text, label, args, timestamp) { if (senderid == null) { this.error('ChatUI: messageAddedTo: invalid senderid [' + senderid + '].'); return; } /* if (isNaN(parseInt(roomid))) { this.error('ChatUI: messageAddedTo: invalid room id [' + roomid + '].'); return; } */ if (text == null) { this.error('ChatUI: messageAddedTo: text is empty.'); return; } if (this.settings == null) { return; } if (this.waitingForResponse) { this.waitingForResponse = false; this.enableSendButton(); } //If label is set then use it to show the message. Also, use self color as a message color. var toshow = ''; var sender = this.getUser(senderid); var user = (label != null)? label : sender.label; var lbl = this.settings.labelFormat; if(sender != null) { lbl = _global.str_replace(lbl, 'USER', user); lbl = _global.str_replace(lbl, 'TIMESTAMP', this.getCurrentTime(timestamp)); } else return; //we do not check here for sender==null, because it is OK with message received in response to 'back' //command. //if we have a private message (roomid==0) and if private chat log is disabled, //try to find a user for this private session. var privateSessionUser = null; if ((roomid == 0) && !this.settings.layout.showPrivateLog) { if (senderid != this.selfUserId) { privateSessionUser = this.getUser(senderid); } else if ((receiverid != this.selfUserId) && (receiverid != null)) { privateSessionUser = this.getUser(receiverid); } else if ((senderid == receiverid) && (senderid == this.selfUserId)) { privateSessionUser = this.getUser(senderid); } //if we were able to detect user for private session, check if private box is already //opened for this user. if not - open it explicitly. if(privateSessionUser != null) { if ( !this.privateBoxManager.existsForUser(privateSessionUser) || (this.settings.liveSupportMode && this.selfUserRole == privateSessionUser.ROLE_CUSTOMER) ) { this.privateBoxManager.createPrivateBox(privateSessionUser); privateSessionUser.minIconVisible = true; } else if(this.privateBoxManager.getUserPrivateBox(privateSessionUser).state == 'minimized') { //if listbox minimized if(!this.userListPane.content_mc._visible) { //this.userListPane.startBlinking(0); } var privateSessionRoom = this.getRoomForUser(privateSessionUser.id); var mc_ref = null; if( privateSessionRoom.getOpened()) { mc_ref = this.mc.userList.getItemRef( privateSessionUser ); } else { privateSessionUser.minIconVisible = true; privateSessionUser.blink_id = -1; mc_ref = this.mc.userList.getItemRef( privateSessionRoom ) } mc_ref.startBlinking(0); //this.privateBoxManager.maximizeForUser(privateSessionUser); } } } var messageColor = null; //set 'system' color for the message if it is marked as 'urgent', i.e. was sent using /me command. if (args == 'isUrgent') { messageColor = this.settings.user.skin.bodyText; toshow = sender.label + ' ' + text; lbl = ''; } else { if (label != null) { var selfUser = this.getUser(this.selfUserId); var color = (sender != undefined)? sender.color : selfUser.color; messageColor = color; } else { messageColor = sender.color; } toshow = text; } //dirty solutuion. true indicates that message was sent to message log inside one of open //popup private dialogs. added primarily not to break message processing code below. var messageShown = false; //if privateSessionUser is not empty, send message to private box manager. if (privateSessionUser != null) { this.privateBoxManager.addMessageForUser(privateSessionUser, lbl, toshow, messageColor, senderid); } else { if ((roomid == 0) && this.settings.layout.showPrivateLog) { this.mc.privateLog.addText(lbl, toshow, messageColor, senderid); } else { if ((this.selfRoomId == roomid) || (roomid == 0)) { this.mc.chatLog.addText(lbl, toshow, messageColor, senderid); } } } //this.setInputFocus(); //trace("------> " + toshow); if ( senderid != this.selfUserId ) { if(roomid == 0) { //private message received this.soundObj.attachSound('PrivateMessageReceived'); } else if (roomid == this.selfRoomId) { //public message received this.soundObj.attachSound('ReceiveMessage'); this.soundObj.start(); } if(Selection.getFocus() == null && this.settings.splashWindow) this.mc.getURL("javascript:setFocus();"); }};ChatUI.prototype.invitedTo = function(userid, roomid, text) { if (userid == null) { this.error('ChatUI: invitedTo: invalid userid [' + userid + '].'); return; } /* if (isNaN(parseInt(roomid))) { this.error('ChatUI: invitedTo: invalid room id [' + roomid + '].'); return; } */ if (text == null) { this.error('ChatUI: invitedTo: text is empty.'); return; } if (this.settings == null) { return; } //this.setControlsEnabled(false); var promptBox = this.dialogManager.createDialog('PromptBox'); var user = this.getUser(userid); if (user == null) { return; } var room = this.rooms[roomid]; if (room.label == null) { this.error('ChatUI: invitedTo: \'dummy\' room encountered.'); } //var labelText = 'User \'' + user.label + '\' invited you to room \'' + room.label + '\':\n' + text; var labelText = this.selectedLanguage.dialog.invitenotify.userinvited; labelText = this.replace(labelText, 'USER_LABEL', user.label); labelText = this.replace(labelText, 'ROOM_LABEL', room.label); if ((text == '') || (text == null)) { labelText += '.'; } else { labelText += ':\n' + text; } promptBox.setResizable(true); promptBox.setLabelTextVisible(true); promptBox.setInputTextVisible(true); promptBox.setRightButtonVisible(true); promptBox.setValidateRightButton(true); promptBox.setCloseButtonEnabled(false); promptBox.setLeftButtonLabel(this.selectedLanguage.dialog.invitenotify.acceptBtn); promptBox.setRightButtonLabel(this.selectedLanguage.dialog.invitenotify.declineBtn); promptBox.setLabelText(labelText); promptBox.setHandler('onInvitedToCompleted', this); promptBox.setUserData([userid, roomid]); this.dialogManager.showDialog(promptBox); this.soundObj.attachSound('InvitationReceived');};ChatUI.prototype.invitationAccepted = function(userid, roomid, text) { if (userid == null) { this.error('ChatUI: invitationAccepted: invalid userid [' + userid + '].'); return; } /* if (isNaN(parseInt(roomid))) { this.error('ChatUI: invitationAccepted: invalid room id [' + roomid + '].'); return; } */ if (text == null) { this.error('ChatUI: invitationAccepted: text is empty.'); return; } if (this.settings == null) { return; } //this.setControlsEnabled(false); var promptBox = this.dialogManager.createDialog('PromptBox'); var user = this.getUser(userid); if (user == null) { return; } var room = this.rooms[roomid]; if (room.label == null) { this.error('ChatUI: invitationAccepted: \'dummy\' room encountered.'); return; } //var labelText = 'User \'' + user.label + '\' accepted your invitation to room \'' + room.label + '\':\n' + text; var labelText = this.selectedLanguage.dialog.misc.invitationaccepted; labelText = this.replace(labelText, 'USER_LABEL', user.label); labelText = this.replace(labelText, 'ROOM_LABEL', room.label); if ((text == '') || (text == null)) { labelText += '.'; } else { labelText += ':\n' + text; } promptBox.setLabelTextVisible(true); promptBox.setInputTextVisible(false); promptBox.setRightButtonVisible(false); promptBox.setValidateRightButton(false); promptBox.setCloseButtonEnabled(true); promptBox.setLeftButtonLabel(this.selectedLanguage.dialog.common.okBtn); promptBox.setLabelText(labelText); promptBox.setHandler('onInvitationAcceptedCompleted', this); this.dialogManager.showDialog(promptBox);};ChatUI.prototype.invitationDeclined = function(userid, roomid, text) { if (userid == null) { this.error('ChatUI: invitationDeclined: invalid userid [' + userid + '].'); return; } /* if (isNaN(parseInt(roomid))) { this.error('ChatUI: invitationDeclined: invalid room id [' + roomid + '].'); return; } */ if (text == null) { this.error('ChatUI: invitationDeclined: text is empty.'); return; } if (this.settings == null) { return; } //this.setControlsEnabled(false); var promptBox = this.dialogManager.createDialog('PromptBox'); var user = this.getUser(userid); if (user == null) { return; } var room = this.rooms[roomid]; if (room.label == null) { this.error('ChatUI: invitationDeclined: \'dummy\' room encountered.'); return; } //var labelText = 'User \'' + user.label + '\' declined your invitation to room \'' + room.label + '\':\n' + text; var labelText = this.selectedLanguage.dialog.misc.invitationdeclined; labelText = this.replace(labelText, 'USER_LABEL', user.label); labelText = this.replace(labelText, 'ROOM_LABEL', room.label); if ((text == '') || (text == null)) { labelText += '.'; } else { labelText += ':\n' + text; } promptBox.setLabelTextVisible(true); promptBox.setInputTextVisible(false); promptBox.setRightButtonVisible(false); promptBox.setValidateRightButton(false); promptBox.setCloseButtonEnabled(true); promptBox.setLeftButtonLabel(this.selectedLanguage.dialog.common.okBtn); promptBox.setLabelText(labelText); promptBox.setHandler('onInvitationDeclinedCompleted', this); this.dialogManager.showDialog(promptBox);};ChatUI.prototype.ignored = function(fromUserId, toUserId, text) { if (fromUserId == null) { this.error('ChatUI: ignored: invalid fromUserId [' + fromUserId + '].'); return; } if (toUserId == null) { this.error('ChatUI: ignored: invalid toUserId [' + toUserId + '].'); return; } if (text == null) { this.error('ChatUI: ignored: text is empty.'); return; } if (this.settings == null) { return; } //this.setControlsEnabled(false); var toUser = this.getUser(toUserId); if (toUser == null) { this.error('ChatUI: ignored: toUser not found.'); return; } if (toUserId == this.selfUserId) { var promptBox = this.dialogManager.createDialog('PromptBox'); var user = this.getUser(fromUserId); if (user == null) { return; } //var labelText = 'You were ignored by user \'' + user.label + '\':\n' + text; var labelText = this.selectedLanguage.dialog.misc.ignored; labelText = this.replace(labelText, 'USER_LABEL', user.label); if ((text == '') || (text == null)) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -