mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-02 13:35:02 +08:00
leave room working
This commit is contained in:
parent
311e658340
commit
2310b9f98d
2 changed files with 18 additions and 2 deletions
|
|
@ -3042,7 +3042,7 @@
|
|||
<div class="groups"></div>
|
||||
</div>
|
||||
<div class="lobbyButtons">
|
||||
<div class="button"><i class="fas fa-door-open"></i>Leave room</div>
|
||||
<div class="button leaveRoomButton"><i class="fas fa-door-open"></i>Leave room</div>
|
||||
</div>
|
||||
<div class="chat">
|
||||
<div class="title">chat</div>
|
||||
|
|
|
|||
|
|
@ -87,6 +87,11 @@ function mp_syncConfig() {
|
|||
}});
|
||||
}
|
||||
|
||||
function mp_joinRoomByCode(code) {
|
||||
code = "room_" + code;
|
||||
MP.socket.emit("mp_room_join",{roomId:code});
|
||||
}
|
||||
|
||||
function mp_refreshConfig() {
|
||||
if (MP.room == undefined) return;
|
||||
$(".pageTribe .lobby .currentSettings .groups").empty();
|
||||
|
|
@ -299,6 +304,13 @@ MP.socket.on('mp_room_joined', data => {
|
|||
}
|
||||
})
|
||||
|
||||
MP.socket.on('mp_room_leave', () => {
|
||||
MP.state = 1;
|
||||
MP.room = undefined;
|
||||
mp_resetLobby();
|
||||
swapElements($('.pageTribe .lobby'), $(".pageTribe .prelobby"), 250);
|
||||
})
|
||||
|
||||
MP.socket.on('mp_room_user_left', data => {
|
||||
MP.room = data.room;
|
||||
mp_refreshUserList();
|
||||
|
|
@ -409,7 +421,7 @@ $(".pageTribe .prelobby #joinByCode .button").click(e => {
|
|||
if (code.length !== 6) {
|
||||
showNotification("Code required", 2000);
|
||||
} else {
|
||||
console.log(code);
|
||||
mp_joinRoomByCode(code);
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -435,4 +447,8 @@ $(".pageTribe .prelobby #joinByCode input").keyup(e => {
|
|||
$($(".pageTribe .prelobby #joinByCode .customInput .byte")[1]).text(text.substring(2,4));
|
||||
$($(".pageTribe .prelobby #joinByCode .customInput .byte")[2]).text(text.substring(4,6));
|
||||
},0)
|
||||
})
|
||||
|
||||
$(".pageTribe .lobby .lobbyButtons .leaveRoomButton").click(e => {
|
||||
MP.socket.emit('mp_room_leave');
|
||||
})
|
||||
Loading…
Add table
Reference in a new issue