messages = [ { messageid: 98568, timestamp: 1630000000000, author: { name: "Velecísař Empy", id: 1, }, content: "Test message 01", }, { messageid: 98868, timestamp: 1640000000000, author: { name: "Velecísař Empy 2", id: 2, }, content: "Test message 02", }, { messageid: 96666, timestamp: 1650000000000, author: { name: "Velecísař Empy", id: 1, }, content: "Test message 03\n\n\n\n\nPokračování\ntest\na\na\n\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\n\na\na\na\na\na\na\na\na\na\n\na\na\na\na\na\na\na\na\na\n\na\na\na\na\na\na\na\na\na\n", }, ]; const messagesDescending = messages.sort((a, b) => a.timestamp - b.timestamp); let htmlString = ""; const currentUser = { name: "Velecísař Empy", id: 1, }; messagesDescending.forEach((obj) => { var meAuthor = obj.author.id == currentUser.id; var tempString = ""; if (meAuthor) { tempString = '
'; } else { tempString = '
'; } tempString += "
" // console.log(event.toLocaleString('cs-CZ', { weekday: "long", year: "numeric", month:"long", day: "numeric", era: "long", hour: "numeric", minute: "numeric", second: "numeric"})); const locale = "cs-CZ"; const options = { weekday: "long", year: "numeric", month: "long", day: "numeric", hour: "numeric", minute: "numeric", second: "numeric", era: "long" }; tempString += `

${ obj.author.name}

`; tempString += "

" tempString += `

${ new Date(obj.timestamp).toLocaleString(locale, options)}

`; tempString += "
" //htmlString += `

ID: ${obj.messageid}, Timestamp: ${obj.timestamp}, Author Name: ${obj.author.name}, Author ID: ${obj.author.id}, Content: ${obj.content}

`; tempString += `

${obj.content.replaceAll("\n", "
")}

`; tempString += "
"; htmlString += tempString; }); $(".chatHier").html(htmlString);