Updated comment script.
This commit is contained in:
parent
78ef146ee7
commit
b7606c466a
|
@ -53,19 +53,39 @@ function write_comments(root, data)
|
||||||
|
|
||||||
const p = document.createElement("p");
|
const p = document.createElement("p");
|
||||||
p.setAttribute("class", "mastodon-api-comment");
|
p.setAttribute("class", "mastodon-api-comment");
|
||||||
p.appendChild(author_html(status.account));
|
p.appendChild(author_html(status));
|
||||||
p.innerHTML += content;
|
if (status.spoiler_text.length > 0)
|
||||||
|
{
|
||||||
|
const subject_p = document.createElement("p");
|
||||||
|
subject_p.setAttribute("class", "mastodon-api-comment-subject");
|
||||||
|
const subject = document.createElement("strong");
|
||||||
|
subject.appendChild(document.createTextNode(status.spoiler_text));
|
||||||
|
subject_p.appendChild(subject);
|
||||||
|
p.appendChild(subject_p);
|
||||||
|
}
|
||||||
|
const content_p = document.createElement("p");
|
||||||
|
content_p.setAttribute("class", "mastodon-api-comment-content");
|
||||||
|
content_p.innerHTML = content;
|
||||||
|
p.appendChild(content_p);
|
||||||
root.appendChild(p);
|
root.appendChild(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function author_html(account)
|
function author_html(status)
|
||||||
{
|
{
|
||||||
const p = document.createElement("p");
|
const p = document.createElement("p");
|
||||||
p.setAttribute("class", "mastodon-api-comment-author");
|
p.setAttribute("class", "mastodon-api-comment-author");
|
||||||
const strong = document.createElement("strong");
|
const strong = document.createElement("strong");
|
||||||
strong.appendChild(document.createTextNode(account.display_name));
|
strong.appendChild(document.createTextNode(status.account.display_name));
|
||||||
p.appendChild(strong);
|
p.appendChild(strong);
|
||||||
p.appendChild(document.createTextNode(" (" + account.acct + ") wrote:"));
|
p.appendChild(
|
||||||
|
document.createTextNode(" (" + status.account.acct + ") wrote on "
|
||||||
|
+ get_status_time(status) + ":"));
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Human readable time, YYYY-MM-DD HH:MM.
|
||||||
|
function get_status_time(status)
|
||||||
|
{
|
||||||
|
return status.created_at.substr(0, 16).replace('T', ' ');
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue