📄 chatui.as
字号:
var bytes = inText.split('!#@#!'); if(bytes.length == 3) { inText = bytes[0]; var toUser = this.getUser(this.selfUserId); var user = this.getUser(Number(bytes[1])); var text = bytes[2]; this.callModuleFunc('mOnUserBannedByIP', {username : toUser.label, mastername : user.label, msg : text}); //trace('Banned user ' + toUser.label + ' master ' + user.label + ' msg ' + text); } this.selfUserId = null; this.selfInitialized = false; this.layoutMinWidth = this.DEFAULT_LAYOUT_MIN_WIDTH; this.layoutMinHeight = this.DEFAULT_LAYOUT_MIN_HEIGHT; this.mc.txtSelfUserName.txt.htmlText = ''; for (var id in this.rooms) { delete this.rooms[id]; this.rooms[id] = null; } this.mc.roomChooser.removeAll(); this.mc.chatLog.clear(); this.mc.privateLog.clear(); if (this.settings.layout.showUserList) { this.mc.userList.removeAll(); } this.mc.msgTxt.text = ''; this.dialogManager.clear(); this.privateBoxManager.clear(); this.dialogManager.hideAllPanes(); this.setControlsVisible(false); //this.setControlsEnabled(false); if(!this.firstInit) { this.setInitialBigSkin(this.initialBigSkin); this.setInitialSkin(this.initialSkin); this.setInitialText(this.initialText); } else this.firstInit = false; this.settings = null; if ((this.languages == null) || (this.languages.length == 0)) { this.error('ChatUI: loggedout: language list is empty.'); } if (this.initialLanguageId == null) { this.error('ChatUI: loggedout: initial language id is empty.'); } var initialLanguage = this.languages[0]; //serach for initial language using id. for (var i = 0; i < this.languages.length; i ++) { if (this.languages[i].id == this.initialLanguageId) { initialLanguage = this.languages[i]; break; } } //XXX01 need to release all open dialog(s). var loginBox = this.dialogManager.createDialog('LoginBox'); loginBox.setHandler('onLoginBoxCompleted', this); loginBox.setLabelText(inText); loginBox.setLanguageList(this.languages); loginBox.setLanguageTarget(this); loginBox.setSelectedLanguage(initialLanguage); /* var languageSO = SharedObject.getLocal('chat_language'); if (languageSO.data.language != null) { this.selectedLanguage = languageSO.data.language; if (this.selectedLanguage == null) { trace('ChatUI: loggedout: selected language is empty.'); } else { loginBox.setSelectedLanguage(this.selectedLanguage); } } */ this.dialogManager.showDialog(loginBox);};ChatUI.prototype.roomAdded = function(id, label) { /* if (isNaN(parseInt(id))) { this.error('ChatUI: roomAdded: invalid id [' + id + '].'); } */ label = label.trim(); if (label == null || label.length == 0) { this.error('ChatUI: roomAdded: label is empty.'); return; } if (this.settings == null) { return; } if (this.rooms[id] != null) { //if there is a 'dummy' room already, just set room label and process as usual. if (this.rooms[id].label == null) { this.rooms[id].label = label; this.rooms[id].isprivate = true; } else { return; } } else { this.rooms[id] = new Room(id, label, this); } if(!this.settings.layout.isSingleRoomMode) this.mc.roomChooser.addItem(label, this.rooms[id]); if( this.settings.layout.showUserList) { this.mc.userList.addItem(this.rooms[id]); this.mc.userList.setSize(this.mc.userList.listWidth, this.mc.userList.listHeight); }};ChatUI.prototype.setRoomLock = function( id, inLock ) { var room = this.rooms[id]; if(room != null) { var ref = this.mc.userList.getItemRef( room ); ref.setLock( inLock ); }};/*ChatUI.prototype.notCreated = function(textId) { if (this.settings == null) { return; } //this.setControlsEnabled(false); var promptBox = this.dialogManager.createDialog('PromptBox'); var labelText = this.selectedLanguage.dialog.misc.roomnotcreated + '\n' + this.selectedLanguage.messages[textId]; 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('onNotCreatedCompleted', this); this.dialogManager.showDialog(promptBox);};*/ChatUI.prototype.removeRoom = function(id) { if (this.settings == null) { return; } if (this.rooms[id] == null) { this.error('ChatUI: removeRoom: room not found for this id [' + id + '].'); return; } //remove from user list and room chooser only if this is not a 'dummy' room. if (this.rooms[id].label != null) { if (this.settings.layout.showUserList) { this.userListClearRoom(this.rooms[id]); var userListIdx = this.getItemIdx(this.rooms[id]); if (userListIdx == -1) { this.error('ChatUI: removeRoom: room with id [' + id + '] not found in user list.'); return; } else { this.mc.userList.removeItemAt(userListIdx); } } for (var i = 0; i < this.mc.roomChooser.getLength(); i ++) { if (this.mc.roomChooser.getItemAt(i).data == this.rooms[id]) { this.mc.roomChooser.removeItemAt(i); break; } } if(!this.rooms[id].isprivate) { delete this.rooms[id]; this.rooms[id] = null; } else this.rooms[id].label = null; }};ChatUI.prototype.userAdded = function(id, label, roomid, ucolor, ustate, timestamp, roles, gender) { if (id == null) { this.error('ChatUI: userAdded: invalid id [' + id + '].'); return; } if (label == null) { this.error('ChatUI: userAdded: label is empty.'); return; } /* if (isNaN(parseInt(roomid))) { this.error('ChatUI: userAdded: invalid room id [' + roomid + '].'); } */ if (this.settings == null) { return; } if (this.getUser(id) != null) { return; } label = this.formatUserName(label); if(ucolor == undefined) ucolor = this.settings.skin.preset[this.settings.skin.defaultSkin].recommendedUserColor; if(ustate == undefined) ustate = this.USER_STATE_HERE; var user = new User(id, label, ucolor, ustate, roles, gender, this); //if room was not found for new user, we create a 'dummy' room with label==null. if (this.rooms[roomid] == null) { this.rooms[roomid] = new Room(roomid, null, this); } var room = this.rooms[roomid]; //trace('ChatUI: userAdded: room: ' + room); //trace('ChatUI: userAdded: user: ' + user); //check if it is not a 'dummy' room. if ((room.label != null) && this.settings.layout.showUserList) { this.userListClearRoom(room); } //this.users[id] = user; room.addUser(user); //trace('ChatUI: userAdded: room.users: ' + room.users); if (id == this.selfUserId) { if (room.label == null) { this.error('ChatUI: userAdded: self user cannot be added to a \'dummy\' room.'); } 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; } } room.setOpened(true); var welcomeStr = this.selectedLanguage.desktop.welcome; welcomeStr = this.replace(welcomeStr, 'USER_LABEL', label); this.mc.txtSelfUserName.txt.htmlText = welcomeStr; //!!!refresh setTextProperty('font', this.settings.user.text.itemToChange.title.fontFamily, this.mc.txtSelfUserName.txt, true); setTextProperty('size', this.settings.user.text.itemToChange.title.fontSize, this.mc.txtSelfUserName.txt, true); this.applyTitleStyle(this.settings.user.skin); //!!!refresh this.addClientMessage(this.selectedLanguage.messages.selfenterroom, null, room, true, timestamp, true); this.callModuleFunc('mOnUserLogin', {username : user.label}); } else { this.sendAvatar('mainchat', this.settings.user.avatars, true, id); this.sendAvatar('room', this.settings.user.avatars, true, id); } //check if it is not a 'dummy' room. if ((room.label != null) && this.settings.layout.showUserList) { //if this is logging in process and if user list is in autoExpand mode, open this room. if (!this.selfInitialized && this.settings.userListAutoExpand) { room.setOpened(true); } this.userListUpdateRoom(room); } if (this.selfInitialized && (id != this.selfUserId) && (room.id == this.selfRoomId)) { if (room.label == null) { this.error('ChatUI: userAdded: self room cannot be added a \'dummy\' one.'); } this.addClientMessage(this.selectedLanguage.messages.enterroom, user, room, true, timestamp); this.soundObj.attachSound('OtherUserEnters'); this.soundObj.start(); } this.setInputFocus();};ChatUI.prototype.userRemoved = function(id, timestamp) { if (id == null) { this.error('ChatUI: userRemoved: invalid id [' + id + '].'); return; } if (this.settings == null) { return; } var room = this.getRoomForUser(id); if (room == null) { return; } //check if it is not a 'dummy' room. if ((room.label != null) && this.settings.layout.showUserList) { this.userListClearRoom(room); } var user = room.getUser(id); room.removeUser(id); //this.users[id] = null; this.privateBoxManager.removeForUser(user); if ((room.getUserCount() == 0) || (id == this.selfUserId)) { room.setOpened(false); } //check if it is not a 'dummy' room. if ((room.label != null) && this.settings.layout.showUserList) { this.userListUpdateRoom(room); } if (room.id == this.selfRoomId) { //it is an error to be self room a 'dummy' one. if (room.label == null) { this.error('ChatUI: userRemoved: self user cannot be removed from a \'dummy\' room.'); return; } this.soundObj.attachSound('LeaveRoom'); this.soundObj.start(); if (id != this.selfUserId) { this.addClientMessage(this.selectedLanguage.messages.leaveroom, user, room, true, timestamp); } } this.setInputFocus();};ChatUI.prototype.userMovedTo = function(id, roomid, timestamp) { if (id == null) { this.error('ChatUI: userMovedTo: invalid id [' + id + '].'); return; } /* if (isNaN(parseInt(roomid))) { this.error('ChatUI: userMovedTo: invalid room id [' + roomid + '].'); return; } */ if (this.settings == null) { return; } var user = this.getUser(id); if (user == null) { return; } //remove user from old room. var oldRoom = this.getRoomForUser(id); if (oldRoom == null) { return; } //check if it is not a 'dummy' oldRoom. if ((oldRoom.label != null) && this.settings.layout.showUserList) { this.userListClearRoom(oldRoom); } oldRoom.removeUser(id); if ((oldRoom.getUserCount() == 0) || (id == this.selfUserId)) { oldRoom.setOpened(false); } //check if it is not a 'dummy' oldRoom. if ((oldRoom.label != null) && this.settings.layout.showUserList) { this.userListUpdateRoom(oldRoom); } if (oldRoom.id == this.selfRoomId) { //it is an error to be self room a 'dummy' one. if (oldRoom.label == null) { this.error('ChatUI: userMovedTo: self user cannot be removed from a \'dummy\' newRoom.'); return; } this.soundObj.attachSound('LeaveRoom'); this.soundObj.start(); if (id != this.selfUserId) { this.addClientMessage(this.selectedLanguage.messages.leaveroom, user, oldRoom, true, timestamp); } } //add user to new room. //if room was not found for new user, we create a 'dummy' room with label==null. if (this.rooms[roomid] == null) { this.rooms[roomid] = new Room(roomid, null, this); } var newRoom = this.rooms[roomid]; //check if it is not a 'dummy' newRoom. if ((newRoom.label != null) && this.settings.layout.showUserList) { this.userListClearRoom(newRoom); } newRoom.addUser(user); if (id == this.selfUserId) { //it is an error to be self room a 'dummy' one. if (newRoom.label == null) { this.error('ChatUI: userMovedTo: self user cannot be added to a \'dummy\' newRoom.'); return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -