diff options
| -rw-r--r-- | webAO/master.js | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/webAO/master.js b/webAO/master.js index f2711d2..72ce833 100644 --- a/webAO/master.js +++ b/webAO/master.js @@ -10,6 +10,22 @@ const options = {fonts: {extendedJsFonts: true, userDefinedFonts: ["Ace Attorney let oldLoading = false; +const server_description = []; +server_description[-1] = "This is your computer on port 50001"; +const online_counter = []; + +/** + * Unescapes a string to AO1 escape codes. + * @param {string} estring the string to be unescaped + */ +function unescapeChat(estring) { + return estring + .replace(/<num>/g, "#") + .replace(/<and>/g, "&") + .replace(/<percent>/g, "%") + .replace(/<dollar>/g, "$"); +} + if (window.requestIdleCallback) { requestIdleCallback(function () { Fingerprint2.get(options, function (components) { @@ -40,10 +56,6 @@ if (window.requestIdleCallback) { }, 500); } -const server_description = []; -server_description[-1] = "This is your computer on port 50001"; -const online_counter = []; - export function setServ(ID) { console.log(server_description[ID]); if (server_description[ID] !== undefined) { @@ -154,4 +166,12 @@ function onMessage(e) { const args = msg.split("#").slice(1); document.getElementById("serverinfo").innerHTML = `Master server version: ${args[0]}`; } + else if (header === "CT") { + const args = msg.split("#").slice(1); + const msChat = document.getElementById("masterchat"); + msChat.innerHTML += `${unescapeChat(args[0])}: ${unescapeChat(args[1])}\r\n`; + if (msChat.scrollTop > msChat.scrollHeight - 600) { + msChat.scrollTop = msChat.scrollHeight; + } + } } |
