aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2023-12-27 16:37:46 +0200
committerkaotisk <kaotisk@arching-kaos.org>2023-12-27 16:37:46 +0200
commit3d9ea1a957bca08fdf3e51f543a409c869f829cc (patch)
treebae4313524d0bfeb758d6f8bfb4c331e4f1488df
parent461285585c6ea332685a86f7c752dd3d77cdbb28 (diff)
downloadarching-kaos-web-ui-3d9ea1a957bca08fdf3e51f543a409c869f829cc.tar.gz
arching-kaos-web-ui-3d9ea1a957bca08fdf3e51f543a409c869f829cc.tar.bz2
arching-kaos-web-ui-3d9ea1a957bca08fdf3e51f543a409c869f829cc.zip
Placeholder check and create to new function
-rw-r--r--src/js/arching-kaos-tools.js24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/js/arching-kaos-tools.js b/src/js/arching-kaos-tools.js
index a97ed56..a531290 100644
--- a/src/js/arching-kaos-tools.js
+++ b/src/js/arching-kaos-tools.js
@@ -6,20 +6,28 @@ function getArrayLength(array){
return len;
}
-function akidRender(json, stellarAddress){
+function renderStellarAddressPlaceholder(stellarAddress){
var divs = document.querySelector('#'+stellarAddress);
if ( divs === null ){
- divs = document.createElement('div');
- divs.id = '#'+stellarAddress;
- document.querySelector('.stellar-network').querySelector('summary').appendChild(divs);
- divs = document.querySelector('#'+stellarAddress);
+ var d = document.createElement('div');
+ d.id = '#'+stellarAddress;
+ d.innerText = stellarAddress;
+ document.querySelector('.stellar-network').appendChild(d);
}
+ divs = document.querySelector('#'+stellarAddress);
+ return divs;
+}
+function akidRender(json, stellarAddress){
+ var divs = renderStellarAddressPlaceholder(stellarAddress);
for( key in Object.keys(json) ){
if ( typeof(json[Object.keys(json)[key]]) === "string" ) {
- var p = document.createElement("p")
- p.innerText = Object.keys(json)[key] + ": " +json[Object.keys(json)[key]];
- divs.appendChild(p);
+ if(!document.querySelector('#'+Object.keys(json)[key]+'-'+stellarAddress)){
+ var p = document.createElement("p");
+ p.id = Object.keys(json)[key]+'-'+stellarAddress;
+ p.innerText = Object.keys(json)[key] + ": " +json[Object.keys(json)[key]];
+ divs.appendChild(p);
+ }
}
else if ( typeof(json[Object.keys(json)[key]]) === "Object"||"Array" ) {
akidRender(json[Object.keys(json)[key]], stellarAddress);