diff options
| author | sD <stoned@derpymail.org> | 2020-03-20 22:34:59 +0100 |
|---|---|---|
| committer | sD <stoned@derpymail.org> | 2020-03-20 22:34:59 +0100 |
| commit | e45a35ed1109e62f5ddcaf8c19d9531d5ec4ddcb (patch) | |
| tree | d6f39c28248cbac38faa9637d607abce3b89f633 /webAO/master.js | |
| parent | f017aabd3f99730e7e03da12f4efa5938d9ee291 (diff) | |
add text decoding magic
Diffstat (limited to 'webAO/master.js')
| -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; + } + } } |
