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); }