aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2023-12-27 16:44:42 +0200
committerkaotisk <kaotisk@arching-kaos.org>2023-12-27 16:44:42 +0200
commit8237ac12e5c040417c753cb325ce9766232c7854 (patch)
treefef22a9868ac88241ec9c7928a8fc434bd78ec27
parent15fc5bf25975004fa461a8d8fdf1ffc5abf020c6 (diff)
downloadarching-kaos-web-ui-8237ac12e5c040417c753cb325ce9766232c7854.tar.gz
arching-kaos-web-ui-8237ac12e5c040417c753cb325ce9766232c7854.tar.bz2
arching-kaos-web-ui-8237ac12e5c040417c753cb325ce9766232c7854.zip
Extracted news module renderer to function and file
-rw-r--r--src/js/arching-kaos-modules-news.js29
-rw-r--r--src/js/arching-kaos-tools.js11
2 files changed, 31 insertions, 9 deletions
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"));
+ }
+}
diff --git a/src/js/arching-kaos-tools.js b/src/js/arching-kaos-tools.js
index 5edb6d9..821d152 100644
--- a/src/js/arching-kaos-tools.js
+++ b/src/js/arching-kaos-tools.js
@@ -371,15 +371,8 @@ function exe(action,dataIPFSHash,blockObject,zblockIPFSHash,zchainIPNSLink,zbloc
akModuleFiles(zblockIPFSHash, blockObject, json);
}
else if (action == "news/add") {
- var divs = document.querySelector('#news-section');
- var art = document.createElement("article");
- art.id = dataIPFSHash;
- if(json.title){
- var h3 = document.createElement("h3");
- h3.innerText = json.title;
- art.appendChild(h3);
- }
- if(json.datetime){
+ akModuleNews(zblockIPFSHash, zblockObject, blockObject, json);
+ }
var small = document.createElement("p");
small.innerText="Published: " +json.datetime;
art.appendChild(small);