-
-
Save cionman/df497c2c075a20fab6a5cc4cf5413517 to your computer and use it in GitHub Desktop.
초대
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
/** | |
* 초기 필드 변수 할당 | |
*/ | |
FirebaseChat.prototype.init = function(){ | |
//...생략 | |
this.aConfirmInvite =document.getElementById('aConfirmInvite'); | |
} | |
/** | |
* 초기 이벤트 바인딩 | |
*/ | |
FirebaseChat.prototype.initEvent = function(){ | |
//...생략 | |
this.aConfirmInvite.addEventListener('click', this.onConfirmInviteClick.bind(this)); | |
} | |
/** | |
* 초대 | |
*/ | |
FirebaseChat.prototype.onConfirmInviteClick = function(){ | |
var arrInviteUserList = Array.prototype.slice.call(this.ulAddUserList.getElementsByClassName('blue-text')); | |
var arrInviteUserListLength = arrInviteUserList.length; | |
var arrInviteUserName = []; | |
var updates = {}; | |
for(var i=0; i < arrInviteUserListLength; i++){ | |
var inviteUserUid = arrInviteUserList[i].getAttribute('data-targetUserUid'); | |
var inviteUserName = arrInviteUserList[i].getAttribute('data-username') + '님'; | |
updates['RoomUsers/'+ this.roomId +'/'+ inviteUserUid] = true; | |
arrInviteUserList[i].outerHTML = ''; | |
this.roomUserlist.push(inviteUserUid); | |
this.roomUserName.push(inviteUserName); | |
arrInviteUserName.push(inviteUserName); | |
} | |
this.roomUserlist.sort(); | |
this.database.ref().update(updates); | |
//초대 메세지 | |
this.saveMessages(arrInviteUserName.join() + '이 초대되었습니다.'); | |
} | |
/** | |
* 메세지 전송 | |
*/ | |
FirebaseChat.prototype.saveMessages = function(inviteMessage){ //파라미터 추가 | |
var user = this.auth.currentUser; | |
var msg = inviteMessage ? inviteMessage : this.dvInputChat.innerHTML.trim(); | |
//...생략 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment