This commit is contained in:
maaa 2023-07-12 18:57:14 +02:00
parent 500300cda0
commit 4fe1837659
1 changed files with 12 additions and 0 deletions

View File

@ -13,9 +13,21 @@ async function updateMessages(id) {
document.querySelectorAll(".messageParagraph").forEach(el => el.remove()); document.querySelectorAll(".messageParagraph").forEach(el => el.remove());
for (let i in messages) { for (let i in messages) {
let messageParagraph = document.createElement("p") let messageParagraph = document.createElement("p")
let timeParagraph = document.createElement("p")
messageParagraph.appendChild(document.createTextNode(messages[i]["creator"]["username"] + ": " + messages[i]["content"])) messageParagraph.appendChild(document.createTextNode(messages[i]["creator"]["username"] + ": " + messages[i]["content"]))
messageParagraph.classList.add("messageParagraph") messageParagraph.classList.add("messageParagraph")
messageParagraph.id = "messageParagraph" + messages[i]["id"] messageParagraph.id = "messageParagraph" + messages[i]["id"]
messageParagraph.appendChild(timeParagraph)
let date = new Date(Number(messages[i]["created"].split(".")[0]));
let utcHours = date.getUTCHours().toString().padStart(2, '0');
let utcMinutes = date.getUTCMinutes().toString().padStart(2, '0');
let timeZoneOffset = date.getTimezoneOffset();
let hours = (utcHours - timeZoneOffset / 60 + 1).toString().padStart(2, '0');
let minutes = utcMinutes.toString().padStart(2, '0');
let time = (hours + ":" + minutes)
messageParagraph.innerHTML = "<span style='color: #515051; font-size: 14px;'>" + time + "</span> " + messageParagraph.innerHTML
messageDiv.append(messageParagraph) messageDiv.append(messageParagraph)
} }
} }