diff options
| -rw-r--r-- | webAO/index.html | 2 | ||||
| -rw-r--r-- | webAO/master.js | 28 | ||||
| -rw-r--r-- | webAO/styles/master.css | 32 |
3 files changed, 43 insertions, 19 deletions
diff --git a/webAO/index.html b/webAO/index.html index 129cac6..9bd24b7 100644 --- a/webAO/index.html +++ b/webAO/index.html @@ -56,6 +56,8 @@ <div id="header"> <p id="serverinfo">Masterserver version - ...</p> <p id="clientinfo">Client version - ...</p> + <br> + <textarea id="masterchat" readonly></textarea> </div> <div id="content"> <div id="serverdescription_box"> 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; + } + } } diff --git a/webAO/styles/master.css b/webAO/styles/master.css index 243dfba..5cfc6f3 100644 --- a/webAO/styles/master.css +++ b/webAO/styles/master.css @@ -1,18 +1,3 @@ -#serverinfo { - margin-top: 75px; - margin-bottom: 0px; - float: left; - font-size:0.6em; -} - -#clientinfo { - margin: 0px; - display: block; - float: left; - clear: both; - font-size:0.6em; -} - .button { padding: 5px; vertical-align: middle; @@ -47,6 +32,23 @@ padding: 1px; } +#header { + display: block; + float: left; + margin-top: 75px; + position: absolute; + left: 0; + font-size: 0.8em; +} + +#masterchat { + width: 260px; + height: 260px; + font-size: inherit; + background-color: darkgrey; + color: black; +} + #serverdescription_box { display: inline-block; position: fixed; |
