chat
diff --git a/public/js/account.js b/public/js/account.js
index 8e671567a..142889009 100644
--- a/public/js/account.js
+++ b/public/js/account.js
@@ -256,11 +256,20 @@ firebase.auth().onAuthStateChanged(function (user) {
} else {
console.log('user is not logged in');
}
- if (!MP.socket.connected) {
- if (MP.state === -1) {
- mp_init();
+ setTimeout(f => {
+ if (/\/tribe_.+/.test(window.location.pathname)) {
+ changePage('tribe');
+ let code = window.location.pathname.split('/')[1];
+ code = code.substring(5);
+ code = "room" + code;
+ MP.autoJoin = code;
}
- }
+ if (!MP.socket.connected && MP.autoJoin != undefined) {
+ if (MP.state === -1) {
+ mp_init();
+ }
+ }
+ }, 250);
});
function getAccountDataAndInit() {
diff --git a/public/js/script.js b/public/js/script.js
index c6a19ec37..053578fc1 100644
--- a/public/js/script.js
+++ b/public/js/script.js
@@ -2836,7 +2836,7 @@ function changePage(page) {
pageTransition = false;
history.pushState("tribe", null, "tribe");
$(".page.pageTribe").addClass("active");
- if (!MP.socket.connected && firebase.auth().currentUser !== null) {
+ if (!MP.socket.connected) {
if (MP.state === -1) {
mp_init();
}
@@ -4883,11 +4883,7 @@ $(document).ready(() => {
history.replaceState("/", null, "/");
} else if (window.location.pathname !== "/") {
if (/\/tribe_.+/.test(window.location.pathname)) {
- changePage('tribe');
- let code = window.location.pathname.split('/')[1];
- code = code.substring(5);
- code = "room" + code;
- MP.autoJoin = code;
+
} else {
let page = window.location.pathname.replace("/", "");
changePage(page);
diff --git a/public/js/tribe.js b/public/js/tribe.js
index 576d436a9..6632c849a 100644
--- a/public/js/tribe.js
+++ b/public/js/tribe.js
@@ -36,6 +36,14 @@ function mp_resetLobby(){
}
function mp_applyRoomConfig(cfg) {
+ changeMode(cfg.mode);
+ if (cfg.mode === "time") {
+ changeTimeConfig(cfg.mode2);
+ } else if (cfg.mode === "words") {
+ changeWordCount(cfg.mode2);
+ } else if (cfg.mode === "quote") {
+ changeQuoteLength(cfg.mode2);
+ }
setDifficulty(cfg.difficulty, true);
setBlindMode(cfg.blindMode, true);
changeLanguage(cfg.language, true);
@@ -44,6 +52,132 @@ function mp_applyRoomConfig(cfg) {
setConfidenceMode(cfg.confidenceMode, true);
}
+function mp_refreshConfig() {
+ $(".pageTribe .lobby .currentSettings .groups").empty();
+
+ $(".pageTribe .lobby .currentSettings .groups").append(`
+
+ ${MP.room.config.mode}
+
+ `);
+
+ if (MP.room.config.mode === "time") {
+ $(".pageTribe .lobby .currentSettings .groups").append(`
+
+ ${MP.room.config.mode2}
+
+ `);
+ } else if (MP.room.config.mode === "words") {
+ $(".pageTribe .lobby .currentSettings .groups").append(`
+
+ ${MP.room.config.mode2}
+
+ `);
+ } else if (MP.room.config.mode === "quote") {
+
+ let qstring = "all";
+ let num = MP.room.config.mode2;
+ if (num == 0) {
+ qstring = "short";
+ } else if (num == 1) {
+ qstring = "medium";
+ } else if (num == 2) {
+ qstring = "long";
+ } else if (num == 3) {
+ qstring = "thicc";
+ }
+
+ $(".pageTribe .lobby .currentSettings .groups").append(`
+
+ ${qstring}
+
+ `);
+ }
+
+
+
+ $(".pageTribe .lobby .currentSettings .groups").append(`
+
+ ${MP.room.config.language}
+
+ `);
+
+ if (MP.room.config.difficulty === "normal") {
+ $(".pageTribe .lobby .currentSettings .groups").append(`
+
+ normal
+
+ `);
+ } else if (MP.room.config.difficulty === "expert") {
+ $(".pageTribe .lobby .currentSettings .groups").append(`
+
+ expert
+
+ `);
+ } else if (MP.room.config.difficulty === "master"){
+ $(".pageTribe .lobby .currentSettings .groups").append(`
+
+ master
+
+ `);
+ }
+
+ if (MP.room.config.blindMode) {
+ $(".pageTribe .lobby .currentSettings .groups").append(`
+
+ blind
+
+ `);
+ } else {
+ $(".pageTribe .lobby .currentSettings .groups").append(`
+
+ off
+
+ `);
+ }
+
+ $(".pageTribe .lobby .currentSettings .groups").append(`
+
+ ${MP.room.config.funbox}
+
+ `);
+
+ if (MP.room.config.confidenceMode === "off") {
+ $(".pageTribe .lobby .currentSettings .groups").append(`
+
+ off
+
+ `);
+ } else if (MP.room.config.confidenceMode === "on") {
+ $(".pageTribe .lobby .currentSettings .groups").append(`
+
+ confidence
+
+ `);
+ } else if (MP.room.config.confidenceMode === "max"){
+ $(".pageTribe .lobby .currentSettings .groups").append(`
+
+ max
+
+ `);
+ }
+
+ if (MP.room.config.stopOnError === "off") {
+ $(".pageTribe .lobby .currentSettings .groups").append(`
+
+ off
+
+ `);
+ } else {
+ $(".pageTribe .lobby .currentSettings .groups").append(`
+
+ stop on ${MP.room.config.stopOnError}
+
+ `);
+ }
+
+}
+
MP.socket.on('connect', (f) => {
MP.state = 1;
MP.reconnectionAttempts = 0;
@@ -55,12 +189,15 @@ MP.socket.on('connect', (f) => {
MP.id = MP.socket.id;
MP.name = name;
MP.socket.emit("mp_system_name_set", { name: name });
+ $(".pageTribe .lobby div").removeClass('hidden');
+ $(".pageTribe .prelobby div").removeClass('hidden');
if (MP.autoJoin) {
MP.socket.emit("mp_room_join", { roomId: MP.autoJoin });
MP.autoJoin = undefined;
+ swapElements($(".pageTribe .preloader"), $(".pageTribe .lobby"), 250);
+ } else {
+ swapElements($(".pageTribe .preloader"), $(".pageTribe .prelobby"), 250);
}
- $(".pageTribe .prelobby .button").removeClass('hidden');
- swapElements($(".pageTribe .preloader"), $(".pageTribe .prelobby"), 250);
})
MP.socket.on('disconnect', (f) => {
@@ -110,17 +247,26 @@ MP.socket.on('mp_room_joined', data => {
MP.room.isLeader = true;
}
mp_refreshUserList();
- mp_applyRoomConfig(MP.room.config);
if (MP.state === 10) {
//user is already in the room and somebody joined
} else if(MP.state === 1) {
//user is in prelobby and joined a room
+ mp_applyRoomConfig(MP.room.config);
+ mp_refreshConfig();
let link = "www.monkey-type.com/tribe" + MP.room.id.substring(4);
$(".pageTribe .lobby .inviteLink").text(link);
- swapElements($(".pageTribe .prelobby"), $(".pageTribe .lobby"), 250, () => {MP.state = 10});
+ swapElements($(".pageTribe .prelobby"), $(".pageTribe .lobby"), 250, () => {
+ MP.state = 10;
+ // $(".pageTribe .prelobby").addClass('hidden');
+ });
}
})
+MP.socket.on('mp_room_user_left', data => {
+ MP.room = data.room;
+ mp_refreshUserList();
+})
+
MP.socket.on('mp_chat_message', data => {
let cls = "message";
let author = '';
@@ -144,8 +290,18 @@ $(".pageTribe #createPrivateRoom").click(f => {
activateFunbox("none");
changeLanguage("english");
changeMode("quote");
+ let mode2;
+ if (config.mode === "time") {
+ mode2 = config.time;
+ } else if (config.mode === "words") {
+ mode2 = config.words;
+ } else if (config.mode === "quote") {
+ mode2 = config.quoteLength === undefined ? "-1" : config.quoteLength;
+ }
MP.socket.emit("mp_room_create", {
config: {
+ mode: config.mode,
+ mode2: mode2,
difficulty: config.difficulty,
blindMode: config.blindMode,
language: config.language,