From 70166ac86c25edee199d6a184e09c7771d020c6c Mon Sep 17 00:00:00 2001 From: maste9 Date: Tue, 15 Feb 2022 00:59:23 +0100 Subject: [PATCH] Fixed the broken sort function. Further improvement of css. Implemented Time fields. --- .gitignore | 1 + index.html | 31 +++++++++++++++++++++++-------- style.css | 9 +++++++-- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index df84038..7c3724b 100644 --- a/.gitignore +++ b/.gitignore @@ -168,3 +168,4 @@ cython_debug/ **/IntegrationServer/XAStore/ **/IntegrationServer/packages/Wm*/ +fontawesome diff --git a/index.html b/index.html index 21da5df..7995303 100644 --- a/index.html +++ b/index.html @@ -15,8 +15,10 @@
- - + + + +
@@ -43,6 +45,8 @@ async function buildArticle(target, statusID) { const url = buildStatusURL(statusID); const mastopost = await getJSONObject(url); + const link = document.createElement('a'); + link.href = mastopost.url; const article = document.createElement('article'); populateHeader(article, mastopost); @@ -50,7 +54,7 @@ populateAside(article, mastopost); populateFooter(article, mastopost); - target.appendChild(article); + target.appendChild(link).appendChild(article); } @@ -58,8 +62,12 @@ 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; + }); - for (const descendant of context.descendants.sort( function (a, b) { return a.id - b.id; })) { + for (const descendant of sorted_descendants) { buildArticle(target, descendant.id); } @@ -70,9 +78,14 @@ const myHeader = document.createElement('header'); const myCW = document.createElement('summary'); - + const myDateTime = document.createElement('time'); + + myDateTime.datetime = obj.created_at; + creation_date = new Date(obj.created_at); + myDateTime.textContent = creation_date.toLocaleString(); myCW.textContent = obj.spoiler_text; myHeader.appendChild(myCW); + myHeader.appendChild(myDateTime); item.appendChild(myHeader); } @@ -87,9 +100,11 @@ const aside = document.createElement('aside'); const myImg = document.createElement('img'); myImg.src = obj['account']['avatar']; + myDate = new Date(obj.account['created_at']); + aside.appendChild(myImg); const myP = document.createElement('hgroup'); - myP.innerHTML = `

${obj.account['display_name']}

(${obj.account['username']})

`; + myP.innerHTML = `

${obj.account['display_name']}

(${obj.account['username']})

`; aside.appendChild(myP); item.appendChild(aside); @@ -97,8 +112,8 @@ function populateFooter(item, obj){ const footer = document.createElement('footer'); - const stats = document.createElement('dl'); - stats.innerHTML = `
${obj.replies_count}
${obj.favourites_count}
${obj.reblogs_count}
`; + const stats = document.createElement('ul'); + stats.innerHTML = `
  • ${obj.replies_count}
  • ${obj.favourites_count}
  • ${obj.reblogs_count}
  • `; footer.appendChild(stats); item.appendChild(footer); } diff --git a/style.css b/style.css index 6681762..dbe5c61 100644 --- a/style.css +++ b/style.css @@ -5,6 +5,10 @@ html { font-weight: 200; } +#comments > a { + text-decoration: none; +} + article { font-family: 'Oswald', sans-serif; color: #fff; @@ -76,8 +80,9 @@ article > footer > ul { gap:0em; } -article > footer > ul > li { - width: 25%; +article > footer > ul > li:before { + padding:0 1em; + } article > footer > ul > li.replies {