diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2023-12-27 16:50:17 +0200 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2023-12-27 16:50:17 +0200 |
commit | e59538dfb7f5e8ecc1a22173bcd00a9a794a4bdb (patch) | |
tree | 5aff268a9cdbf0af534119f498133f2e1b34bc4a /src/js/arching-kaos-tools.js | |
parent | 8237ac12e5c040417c753cb325ce9766232c7854 (diff) | |
download | arching-kaos-web-ui-e59538dfb7f5e8ecc1a22173bcd00a9a794a4bdb.tar.gz arching-kaos-web-ui-e59538dfb7f5e8ecc1a22173bcd00a9a794a4bdb.tar.bz2 arching-kaos-web-ui-e59538dfb7f5e8ecc1a22173bcd00a9a794a4bdb.zip |
Comments and References module
Diffstat (limited to 'src/js/arching-kaos-tools.js')
-rw-r--r-- | src/js/arching-kaos-tools.js | 54 |
1 files changed, 44 insertions, 10 deletions
diff --git a/src/js/arching-kaos-tools.js b/src/js/arching-kaos-tools.js index 821d152..2398df1 100644 --- a/src/js/arching-kaos-tools.js +++ b/src/js/arching-kaos-tools.js @@ -126,9 +126,13 @@ function blockRenderAndProceed(json, params){ if ( x === getArrayLength(zchain) ){ archingKaosLog("Everything is completed!"); sortedMixtapes = mixtapes.sort(function(a,b){return a.timestamp - b.timestamp}); - } } + for( entry in references ){ + var comment = document.querySelector('#comment-'+references[entry].dataExpansion.reference); + var article = document.querySelector('#news-'+references[entry].dataExpansion.refer_to); + article.appendChild(comment); + } } else { seekzblock(json.previous, zchainIPNSLink); } @@ -373,19 +377,49 @@ function exe(action,dataIPFSHash,blockObject,zblockIPFSHash,zchainIPNSLink,zbloc else if (action == "news/add") { akModuleNews(zblockIPFSHash, zblockObject, blockObject, json); } + else if (action == "comments/add") { + if (!document.querySelector('#comment-'+zblockIPFSHash)){ + var divs = document.querySelector('#comments-section'); + var art = document.createElement("article"); + art.id = 'comment-'+zblockIPFSHash; + /* + if(json.title){ + var h3 = document.createElement("h3"); + h3.innerText = json.title; + art.appendChild(h3); + } + */ + if(json.datetime){ + var small = document.createElement("p"); + small.innerText="Published: " + new Date(json.datetime*1000); + art.appendChild(small); + } var small = document.createElement("p"); - small.innerText="Published: " +json.datetime; + small.innerText="Contributor: " + getNicknameAssossiatedWithGPG(blockObject.gpg); art.appendChild(small); + if(json.ipfs){ + getipfstext(json.ipfs,art.id); + } + if (document.querySelector("#comments-sec-not-found")) document.querySelector("#comments-sec-not-found").hidden=true; + divs.appendChild(art); + divs.appendChild(document.createElement("hr")); } - var small = document.createElement("p"); - small.innerText="Contributor: " + getNicknameAssossiatedWithGPG(blockObject.gpg); - art.appendChild(small); - if(json.ipfs){ - getipfstext(json.ipfs,art.id); + } + else if (action == "references/add"){ + if ( references[zblockIPFSHash] === undefined ){ + references[zblockIPFSHash]={ + zblock:zblockIPFSHash, + block:zblockObject.block, + block_signature:zblockObject.block_signature, + action:action, + previous:blockObject.previous, + data:blockObject.data, + dataExpansion:json, + detach:blockObject.detach, + gpg:blockObject.gpg, + timestamp:blockObject.timestamp + }; } - if (document.querySelector("#news-sec-not-found")) document.querySelector("#news-sec-not-found").hidden=true; - divs.appendChild(art); - divs.appendChild(document.createElement("hr")); } else if (action == "mixtape/add") { var divs = document.querySelector('#mixtapes-section'); |