diff --git a/index.html b/index.html
index 7995303..4841fbe 100644
--- a/index.html
+++ b/index.html
@@ -13,11 +13,8 @@
@@ -30,7 +27,7 @@
function buildCommentTree(statusID){
const target = document.querySelector('#comments');
- buildArticle(target, statusID);
+ buildStatus(target, statusID);
buildDescendants(target, statusID);
}
@@ -42,9 +39,8 @@
}
- async function buildArticle(target, statusID) {
- const url = buildStatusURL(statusID);
- const mastopost = await getJSONObject(url);
+ async function buildArticle(target, mastopost) {
+
const link = document.createElement('a');
link.href = mastopost.url;
const article = document.createElement('article');
@@ -58,17 +54,28 @@
}
+ async function buildStatus(target, statusID) {
+ const url = buildStatusURL(statusID);
+ const mastopost = await getJSONObject(url);
+
+ buildArticle(target, mastopost);
+ }
+
+
async function buildDescendants(target, statusID){
const url = buildStatusURL(statusID);
const contextURL = url+'/context';
const context = await getJSONObject(contextURL);
const sorted_descendants = context.descendants.sort(
function (a, b) {
- return a.created_at - b.created_at;
+ aDate = new Date(a.created_at).getTime();
+ bDate = new Date(b.created_at).getTime();
+ diff = aDate - bDate;
+ return diff;
});
for (const descendant of sorted_descendants) {
- buildArticle(target, descendant.id);
+ buildArticle(target, descendant);
}
}
@@ -103,8 +110,12 @@
myDate = new Date(obj.account['created_at']);
aside.appendChild(myImg);
- const myP = document.createElement('hgroup');
- myP.innerHTML = `
${obj.account['display_name']}
`;
+ const myH = document.createElement('hgroup');
+ const myP = document.createElement('div');
+ myH.innerHTML = `${obj.account['display_name']}
`;
+ myP.innerHTML = ``;
+
+ aside.appendChild(myH);
aside.appendChild(myP);
item.appendChild(aside);