Add date & time, add support for subjects.
This commit is contained in:
parent
14ae5910c2
commit
0ccc62ece5
13
README.adoc
13
README.adoc
@ -49,11 +49,13 @@ The generated HTML uses these classes:
|
||||
|
||||
[options="header"]
|
||||
|===============================================================
|
||||
| Name | Description
|
||||
| mastodon-api-comments | Encompasses everything.
|
||||
| mastodon-api-comment-intro | The introduction sentence.
|
||||
| mastodon-api-comment | A complete comment.
|
||||
| mastodon-api-comment-author | The author portion the comment.
|
||||
| Name | Description
|
||||
| mastodon-api-comments | Encompasses everything.
|
||||
| mastodon-api-comment-intro | The introduction sentence.
|
||||
| mastodon-api-comment | A complete comment.
|
||||
| mastodon-api-comment-author | The author line the comment.
|
||||
| mastodon-api-comment-subject | The subject of the comment.
|
||||
| mastodon-api-comment-content | The text the comment.
|
||||
|===============================================================
|
||||
|
||||
==== Example CSS
|
||||
@ -64,7 +66,6 @@ The generated HTML uses these classes:
|
||||
{
|
||||
margin-left: 1em;
|
||||
border: 0.1em solid black;
|
||||
padding: 0.1em 1em;
|
||||
}
|
||||
.mastodon-api-comment:nth-child(even)
|
||||
{
|
||||
|
@ -53,19 +53,39 @@ function write_comments(root, data)
|
||||
|
||||
const p = document.createElement("p");
|
||||
p.setAttribute("class", "mastodon-api-comment");
|
||||
p.appendChild(author_html(status.account));
|
||||
p.innerHTML += content;
|
||||
p.appendChild(author_html(status));
|
||||
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.appendChild(document.createTextNode(content));
|
||||
p.appendChild(content_p);
|
||||
root.appendChild(p);
|
||||
}
|
||||
}
|
||||
|
||||
function author_html(account)
|
||||
function author_html(status)
|
||||
{
|
||||
const p = document.createElement("p");
|
||||
p.setAttribute("class", "mastodon-api-comment-author");
|
||||
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(document.createTextNode(" (" + account.acct + ") wrote:"));
|
||||
p.appendChild(
|
||||
document.createTextNode(" (" + status.account.acct + ") wrote on "
|
||||
+ get_status_time(status) + ":"));
|
||||
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…
x
Reference in New Issue
Block a user