diff --git a/index.html b/index.html index 4841fbe..daebfb1 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,7 @@
- +
@@ -41,16 +41,15 @@ async function buildArticle(target, mastopost) { - const link = document.createElement('a'); - link.href = mastopost.url; + const article = document.createElement('article'); populateHeader(article, mastopost); - populateSection(article, mastopost); + populateSection(article, mastopost); populateAside(article, mastopost); populateFooter(article, mastopost); - target.appendChild(link).appendChild(article); + target.appendChild(article); } @@ -84,23 +83,33 @@ function populateHeader(item, obj) { const myHeader = document.createElement('header'); - const myCW = document.createElement('summary'); const myDateTime = document.createElement('time'); + const link = document.createElement('a'); + link.href = obj.url; 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); + myDateTime.textContent = creation_date.toLocaleString('de-DE',{ day: "2-digit", month: "short", year: "numeric", hour:"2-digit", minute:"2-digit"}); + if(obj.spoiler_text.length > 0){ + const myCW = document.createElement('summary'); + const myButton = document.createElement('button'); + myButton.textContent = "+"; + myCW.textContent = obj.spoiler_text; + myHeader.appendChild(myCW); + myHeader.appendChild(myButton); + + } + + myHeader.appendChild(link).appendChild(myDateTime); item.appendChild(myHeader); } - function populateSection(item, obj){ - const mySection = document.createElement('section'); - mySection.innerHTML = `${obj['content']}`; - item.appendChild(mySection); + function populateSection(item, obj){ + + const mySection = document.createElement('section'); + mySection.innerHTML = `${obj['content']}`; + item.appendChild(mySection); } function populateAside(item, obj){ @@ -113,7 +122,7 @@ const myH = document.createElement('hgroup'); const myP = document.createElement('div'); myH.innerHTML = `

${obj.account['display_name']}

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

`; - myP.innerHTML = ``; + myP.innerHTML = ``; aside.appendChild(myH); aside.appendChild(myP); @@ -135,6 +144,7 @@ } buildCommentTree("107735248507147283"); +// buildCommentTree("107724981153178707"); diff --git a/style.css b/style.css index 8f20c30..19cc036 100644 --- a/style.css +++ b/style.css @@ -9,6 +9,12 @@ html { text-decoration: none; } +time { + display:inline-block; + font-size: 0.7em; + color:#b4b5ba; +} + article { font-family: monospace, sans-serif; color: #fff; @@ -33,6 +39,7 @@ article a { article header { width:100%; grid-area: header; + text-align:right; } article header summary { @@ -41,6 +48,10 @@ article header summary { } +article header time { + padding-right:1em; +} + article aside { grid-area: profile; text-align:center; @@ -73,12 +84,11 @@ article aside img { } article > aside > div { - + } article > aside > div > time { - font-size: 0.7em; - color:#b4b5ba; + } article section {