From c4722060b8d24e5ada28b10e6d9b837ab63111a0 Mon Sep 17 00:00:00 2001 From: elijahr2411 Date: Fri, 27 Jan 2023 09:18:18 -0500 Subject: [PATCH] Staff usernames are now colored in chat messages --- src/index.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index a5da7a4..b0e1eba 100644 --- a/src/index.js +++ b/src/index.js @@ -479,12 +479,28 @@ function reloadVMList() { vmlist.children[0].innerHTML = ""; vms.forEach((v) => vmlist.children[0].appendChild(v.element)); } -function chatMessage(username, msg) { +function chatMessage(user, msg) { var tr = document.createElement("tr"); var td = document.createElement("td"); - if (username == "" || username === undefined) + if (user == "" || user === undefined) td.innerHTML = msg; - else td.innerHTML = `${username}> ${msg}`; + else { + var u = users.find(u => u.username === user); + var userclass = ""; + switch (u.rank) { + case 2: + userclass = "text-danger"; + break; + case 3: + userclass = "text-success"; + break; + case 0: + default: + userclass = "text-light"; + break; + } + td.innerHTML = `${user}> ${msg}`; + } tr.appendChild(td); chatList.appendChild(tr); }