From 8237ac12e5c040417c753cb325ce9766232c7854 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Wed, 27 Dec 2023 16:44:42 +0200 Subject: Extracted news module renderer to function and file --- src/js/arching-kaos-modules-news.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/js/arching-kaos-modules-news.js (limited to 'src/js/arching-kaos-modules-news.js') diff --git a/src/js/arching-kaos-modules-news.js b/src/js/arching-kaos-modules-news.js new file mode 100644 index 0000000..b4c6819 --- /dev/null +++ b/src/js/arching-kaos-modules-news.js @@ -0,0 +1,29 @@ + +function akModuleNews(zblockIPFSHash, zblockObject, blockObject, json){ + if (!document.querySelector('#news-'+zblockIPFSHash)){ + var divs = document.querySelector('#news-section'); + var art = document.createElement("article"); + art.id = 'news-'+zblockIPFSHash; + if(json.title){ + var ahref = document.createElement("a"); + ahref.innerText = json.title +' [permalink]'; + ahref.href = 'https://news.arching-kaos.net/?from_block='+zblockObject.block; + art.appendChild(ahref); + } + if(json.datetime){ + var small = document.createElement("p"); + small.innerText="Published: " + new Date(blockObject.timestamp*1000); + art.appendChild(small); + } + var small = document.createElement("p"); + small.innerText="Contributor: " + getNicknameAssossiatedWithGPG(blockObject.gpg); + art.appendChild(small); + art.appendChild(document.createElement("hr")); + if(json.ipfs){ + getipfstext(json.ipfs,art.id); + } + if (document.querySelector("#news-sec-not-found")) document.querySelector("#news-sec-not-found").hidden=true; + divs.appendChild(art); + divs.appendChild(document.createElement("hr")); + } +} -- cgit v1.2.3