WIP copy U Game link to sender
This commit is contained in:
parent
ed2885f19d
commit
432fd849b8
4 changed files with 47 additions and 10 deletions
|
|
@ -17,7 +17,7 @@ import authHtml from "./chat.html?raw";
|
|||
import { getUser } from "@app/auth";
|
||||
import { listBuddies } from "./chatHelperFunctions/listBuddies";
|
||||
import { getProfil } from "./chatHelperFunctions/getProfil";
|
||||
import { addMessage } from "./chatHelperFunctions/addMessage";
|
||||
import { addInviteMessage, addMessage } from "./chatHelperFunctions/addMessage";
|
||||
import { broadcastMsg } from "./chatHelperFunctions/broadcastMsg";
|
||||
import { openProfilePopup } from "./chatHelperFunctions/openProfilePopup";
|
||||
import { actionBtnPopUpBlock } from "./chatHelperFunctions/actionBtnPopUpBlock";
|
||||
|
|
@ -209,7 +209,13 @@ function initChatSocket() {
|
|||
});
|
||||
|
||||
socket.on("privMessageCopy", (message: string) => {
|
||||
addMessage(message);
|
||||
const htmlBaliseRegex = /<a\b[^>]*>[\s\S]*?<\/a>/;
|
||||
const htmlBaliseMatch = message.match(htmlBaliseRegex);
|
||||
|
||||
if (htmlBaliseMatch)
|
||||
addInviteMessage(message);
|
||||
else
|
||||
addMessage(message);
|
||||
});
|
||||
|
||||
//receives broadcast of the next GAME
|
||||
|
|
|
|||
|
|
@ -12,4 +12,30 @@ export function addMessage(text: string) {
|
|||
chatWindow.appendChild(messageElement);
|
||||
chatWindow.scrollTop = chatWindow.scrollHeight;
|
||||
return ;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
export function addInviteMessage(text: string) {
|
||||
const htmlBaliseRegex = new RegExp(/<a\b[^>]*>[\s\S]*?<\/a>/g);
|
||||
const htmlBaliseMatch = text.match(htmlBaliseRegex);
|
||||
|
||||
if (!htmlBaliseMatch) return;
|
||||
const chatWindow = document.getElementById("t-chatbox") as HTMLDivElement;
|
||||
if (!chatWindow) return;
|
||||
const messageElement = document.createElement("div-test");
|
||||
messageElement.innerHTML = `🏓${text.replaceAll(htmlBaliseRegex, "").replaceAll("🔒", '').replaceAll("invites you", "You have invited")}${htmlBaliseMatch[0]}🔒`
|
||||
chatWindow.appendChild(messageElement);
|
||||
chatWindow.scrollTop = chatWindow.scrollHeight;
|
||||
return ;
|
||||
};
|
||||
|
||||
|
||||
// if (chatWindow && data.message.destination === "inviteMsg") {
|
||||
// const messageElement = document.createElement("div-private");
|
||||
// const chatWindow = document.getElementById(
|
||||
// "t-chatbox",
|
||||
// ) as HTMLDivElement;
|
||||
// messageElement.innerHTML = `🏓${data.message.SenderUserName}: ${data.message.innerHtml}`;
|
||||
// chatWindow.appendChild(messageElement);
|
||||
// chatWindow.scrollTop = chatWindow.scrollHeight;
|
||||
// }
|
||||
Loading…
Add table
Add a link
Reference in a new issue