aboutsummaryrefslogtreecommitdiff
path: root/src/js/arching-kaos-modules-news.js
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-11-11 23:37:28 +0200
committerkaotisk <kaotisk@arching-kaos.org>2024-11-11 23:37:28 +0200
commit22bdc082a3fb26144f861732a971e091718a215f (patch)
treef6724e9983441c1d59068f0dba8d40e9eb3b7064 /src/js/arching-kaos-modules-news.js
parent075ef0c6213585094266cceaaac6a281afa1099e (diff)
downloadarching-kaos-web-ui-22bdc082a3fb26144f861732a971e091718a215f.tar.gz
arching-kaos-web-ui-22bdc082a3fb26144f861732a971e091718a215f.tar.bz2
arching-kaos-web-ui-22bdc082a3fb26144f861732a971e091718a215f.zip
Refactoring using ak-generator
Diffstat (limited to 'src/js/arching-kaos-modules-news.js')
-rw-r--r--src/js/arching-kaos-modules-news.js52
1 files changed, 32 insertions, 20 deletions
diff --git a/src/js/arching-kaos-modules-news.js b/src/js/arching-kaos-modules-news.js
index 9292fad..0a1652a 100644
--- a/src/js/arching-kaos-modules-news.js
+++ b/src/js/arching-kaos-modules-news.js
@@ -9,34 +9,46 @@
function akModuleNews(zblockIPFSHash, zblockObject, blockObject, json){
if (!document.querySelector('#news-'+zblockIPFSHash)){
var newsSectionDivElement = document.querySelector('#news-section');
- var articleContainerElement = document.createElement("article");
- articleContainerElement.id = 'news-'+zblockIPFSHash;
+ var articleContainerElement = {
+ element:"article",
+ id:'news-'+zblockIPFSHash
+ };
+ makeElement(articleContainerElement, newsSectionDivElement);
+ articleContainerElement = document.querySelector(`#news-${zblockIPFSHash}`);
if(json.title){
- var ubs = document.createElement("a");
- ubs.innerText = json.title;
- ubs.href = '#news-'+zblockIPFSHash;
- articleContainerElement.appendChild(ubs);
- var ahref = document.createElement("a");
- ahref.innerText = '[permalink]';
- ahref.target = '_blank';
- ahref.href = 'https://news.arching-kaos.net/?from_zblock='+zblockIPFSHash;
- articleContainerElement.appendChild(ahref);
+ var ubs = {
+ element:"a",
+ innerText : json.title,
+ href : '#news-'+zblockIPFSHash
+ };
+ makeElement(ubs, articleContainerElement);
+ var ahref = {
+ element:"a",
+ innerText:'[permalink]',
+ target: '_blank',
+ href:'https://news.arching-kaos.net/?from_zblock='+zblockIPFSHash
+ };
+ makeElement(ahref, articleContainerElement);
}
if(json.datetime){
- var small = document.createElement("p");
- small.innerText="Published: " + new Date(blockObject.timestamp*1000);
- articleContainerElement.appendChild(small);
+ var small = {
+ element:"p",
+ innerText:"Published: " + new Date(blockObject.timestamp*1000)
+ };
+ makeElement(small, articleContainerElement);
}
- var small = document.createElement("p");
- small.innerText="Contributor: " + getNicknameAssossiatedWithGPG(blockObject.gpg);
- articleContainerElement.appendChild(small);
- articleContainerElement.appendChild(document.createElement("hr"));
+ var small = {
+ element:"p",
+ innerText:"Contributor: " + getNicknameAssossiatedWithGPG(blockObject.gpg)
+ };
+ makeElement(small, articleContainerElement);
+ var hr = { element:"hr" };
+ makeElement(hr, articleContainerElement);
if(json.ipfs){
getipfstext(json.ipfs,articleContainerElement.id);
}
if (document.querySelector("#news-sec-not-found")) document.querySelector("#news-sec-not-found").hidden=true;
- newsSectionDivElement.appendChild(articleContainerElement);
- newsSectionDivElement.appendChild(document.createElement("hr"));
+ makeElement(hr, newsSectionDivElement);
}
}
// @license-end