aboutsummaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2023-12-27 16:41:24 +0200
committerkaotisk <kaotisk@arching-kaos.org>2023-12-27 16:41:24 +0200
commit15fc5bf25975004fa461a8d8fdf1ffc5abf020c6 (patch)
treea4b9c38543e446132fa5114c68fb602ead0f509d /src/js
parent5757847f4c68778378c978ba3bf04eb5c9dceef8 (diff)
downloadarching-kaos-web-ui-15fc5bf25975004fa461a8d8fdf1ffc5abf020c6.tar.gz
arching-kaos-web-ui-15fc5bf25975004fa461a8d8fdf1ffc5abf020c6.tar.bz2
arching-kaos-web-ui-15fc5bf25975004fa461a8d8fdf1ffc5abf020c6.zip
Extracted module renderer to file and function
Diffstat (limited to 'src/js')
-rw-r--r--src/js/arching-kaos-modules-files.js31
-rw-r--r--src/js/arching-kaos-tools.js28
2 files changed, 32 insertions, 27 deletions
diff --git a/src/js/arching-kaos-modules-files.js b/src/js/arching-kaos-modules-files.js
new file mode 100644
index 0000000..c85a6aa
--- /dev/null
+++ b/src/js/arching-kaos-modules-files.js
@@ -0,0 +1,31 @@
+function akModuleFiles(zblockIPFSHash, blockObject, json){
+ if (!document.querySelector('#file-'+zblockIPFSHash)){
+ var divs = document.querySelector('#files-section');
+ var art = document.createElement("article");
+ art.id = 'file-'+zblockIPFSHash;
+ if(json.title){
+ var h3 = document.createElement("h3");
+ h3.innerText = json.filename;
+ art.appendChild(h3);
+ }
+ if(json.datetime){
+ var small = document.createElement("p");
+ small.innerText="Published: " +json.datetime;
+ art.appendChild(small);
+ }
+ getNicknameAssossiatedWithGPG(blockObject.gpg);
+ var small = document.createElement("p");
+ small.innerText="Contributor: " + getNicknameAssossiatedWithGPG(blockObject.gpg);
+ art.appendChild(small);
+ if(json.ipfs){
+ // getipfstext(json.ipfs,art.id);
+ var small = document.createElement("a");
+ small.innerText=json.filename;
+ small.href="https://ipfs.arching-kaos.com/ipfs/"+json.ipfs+"?filename="+json.filename;
+ art.appendChild(small);
+ }
+ divs.appendChild(art);
+ if(document.querySelector("#files-sec-not-found")) document.querySelector("#files-sec-not-found").hidden = true;
+ divs.appendChild(document.createElement("hr"));
+ }
+}
diff --git a/src/js/arching-kaos-tools.js b/src/js/arching-kaos-tools.js
index db5276c..5edb6d9 100644
--- a/src/js/arching-kaos-tools.js
+++ b/src/js/arching-kaos-tools.js
@@ -368,33 +368,7 @@ function exe(action,dataIPFSHash,blockObject,zblockIPFSHash,zchainIPNSLink,zbloc
* - block_signature
*/
if (action == "files/add") {
- var divs = document.querySelector('#files-section');
- var art = document.createElement("article");
- art.id = dataIPFSHash;
- if(json.title){
- var h3 = document.createElement("h3");
- h3.innerText = json.filename;
- art.appendChild(h3);
- }
- if(json.datetime){
- var small = document.createElement("p");
- small.innerText="Published: " +json.datetime;
- art.appendChild(small);
- }
- getNicknameAssossiatedWithGPG(blockObject.gpg);
- var small = document.createElement("p");
- small.innerText="Contributor: " + getNicknameAssossiatedWithGPG(blockObject.gpg);
- art.appendChild(small);
- if(json.ipfs){
- // getipfstext(json.ipfs,art.id);
- var small = document.createElement("a");
- small.innerText=json.filename;
- small.href="https://ipfs.arching-kaos.com/ipfs/"+json.ipfs+"?filename="+json.filename;
- art.appendChild(small);
- }
- divs.appendChild(art);
- if(document.querySelector("#files-sec-not-found")) document.querySelector("#files-sec-not-found").hidden = true;
- divs.appendChild(document.createElement("hr"));
+ akModuleFiles(zblockIPFSHash, blockObject, json);
}
else if (action == "news/add") {
var divs = document.querySelector('#news-section');