diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2023-12-27 16:37:46 +0200 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2023-12-27 16:37:46 +0200 |
commit | 3d9ea1a957bca08fdf3e51f543a409c869f829cc (patch) | |
tree | bae4313524d0bfeb758d6f8bfb4c331e4f1488df /src/js | |
parent | 461285585c6ea332685a86f7c752dd3d77cdbb28 (diff) | |
download | arching-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
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/arching-kaos-tools.js | 24 |
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); |