htdocs/board/displayComments.js

31 lines
1.2 KiB
JavaScript
Raw Normal View History

2024-11-18 22:52:13 +01:00
function daysIntoYear(date){
return (Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()) - Date.UTC(date.getFullYear(), 0, 0)) / 24 / 60 / 60 / 1000;
}
function secondsIntoDay(time) {
let hour = time.getUTCHours();
let minute = time.getUTCMinutes();
let second = time.getUTCSeconds();
return ((hour * 3600) + (minute * 60) + second)
}
2024-11-19 18:07:11 +01:00
let pfps = [["deadvey","/images/pfp6.png"]]
2024-11-18 22:52:13 +01:00
let divText = document.getElementById("comments").innerHTML;
newPageHTML="";
2024-11-19 18:07:11 +01:00
for (let comment = 0; comment < comments.length; comment++) {
for (let i = 0; i < pfps.length; i++) {
if (pfps[i][0] == comments[comment][0]) {
comments[comment][0] = `<img src="${pfps[i][1]}" height="20"> ` + comments[comment][0]
}
}
2024-11-18 22:52:13 +01:00
if (typeof comments[comment][2] == 'undefined') {
newPageHTML+=`<b>${comments[comment][0]}</b>: <i>${comments[comment][1]}</i><br/>`
}
else {
let time = new Date(comments[comment][2])
let second = Math.round((secondsIntoDay(time) / (86400/65536))).toString(16);
let day = daysIntoYear(time).toString(16);
let year = time.getUTCFullYear().toString(16);
2024-11-19 18:07:11 +01:00
newPageHTML+=`[${second} ${day}/${year}] <b>${comments[comment][0]}</b>: ${comments[comment][1]}<br/>`
2024-11-18 22:52:13 +01:00
}
};
document.getElementById("comments").innerHTML = newPageHTML