diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2023-12-27 17:08:06 +0200 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2023-12-27 17:08:06 +0200 |
commit | b738d838180e36bf1edda16e4f0d7a5c797c97f0 (patch) | |
tree | 257c039f950a4f2fd490f105916002f6585cbf91 /src/js | |
parent | 0a3005e70b1dff7d827ee7a70abb71f8744adfaf (diff) | |
download | arching-kaos-web-ui-b738d838180e36bf1edda16e4f0d7a5c797c97f0.tar.gz arching-kaos-web-ui-b738d838180e36bf1edda16e4f0d7a5c797c97f0.tar.bz2 arching-kaos-web-ui-b738d838180e36bf1edda16e4f0d7a5c797c97f0.zip |
Mixtape render rewrite
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/arching-kaos-tools.js | 114 |
1 files changed, 58 insertions, 56 deletions
diff --git a/src/js/arching-kaos-tools.js b/src/js/arching-kaos-tools.js index 7d73cf5..300d50b 100644 --- a/src/js/arching-kaos-tools.js +++ b/src/js/arching-kaos-tools.js @@ -425,63 +425,65 @@ function exe(action,dataIPFSHash,blockObject,zblockIPFSHash,zchainIPNSLink,zbloc } } else if (action == "mixtape/add") { - var divs = document.querySelector('#mixtapes-section'); - var art = document.createElement("article"); - art.id = dataIPFSHash; - if(json.title){ - var h3 = document.createElement("h3"); - h3.innerText = json.title; - art.appendChild(h3); - } - if(json.artist){ - var h4 = document.createElement("h4"); - h4.innerText = json.artist; - art.appendChild(h4); - } - if(json.timestamp){ - var small = document.createElement("h5"); - small.innerText="Published: " + new Date(json.timestamp*1000); - art.appendChild(small); - } - if(json.ipfs){ - var audio = document.createElement("audio"); - audio.setAttribute('controls',''); - audio.id = 'mixtape-'+zblockIPFSHash; - mixtapeIds.push(audio.id); - var source = document.createElement("source"); - source.src = getIPFSURL(json.ipfs); - var rs = source.cloneNode(true); - audio.appendChild(source); - radio.appendChild(rs); - art.appendChild(audio); - audio.addEventListener( "loadedmetadata", ()=>{ - if ( mixtapes[zblockIPFSHash] === undefined ){ - mixtapes[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, - audioDuration:audio.duration - }; - } - console.log( - zblockIPFSHash+"'s duration is: "+ - audio.duration + - " Ceiled: " + Math.ceil(audio.duration) + - " added on " + blockObject.timestamp + " or " - + json.timestamp + - " DIFF: " + (blockObject.timestamp - json.timestamp) - ); - }, false ); + if(!document.querySelector('#mixtape-'+zblockIPFSHash)){ + var divs = document.querySelector('#mixtapes-section'); + var art = document.createElement("article"); + art.id = 'mixtape-'+zblockIPFSHash; + if(json.title){ + var h3 = document.createElement("h3"); + h3.innerText = json.title; + art.appendChild(h3); + } + if(json.artist){ + var h4 = document.createElement("h4"); + h4.innerText = json.artist; + art.appendChild(h4); + } + if(json.timestamp){ + var small = document.createElement("h5"); + small.innerText="Published: " + new Date(json.timestamp*1000); + art.appendChild(small); + } + if(json.ipfs){ + var audio = document.createElement("audio"); + audio.setAttribute('controls',''); + audio.id = 'mixtape-player-'+zblockIPFSHash; + mixtapeIds.push(audio.id); + var source = document.createElement("source"); + source.src = getIPFSURL(json.ipfs); + var rs = source.cloneNode(true); + audio.appendChild(source); + radio.appendChild(rs); + art.appendChild(audio); + audio.addEventListener( "loadedmetadata", ()=>{ + if ( mixtapes[zblockIPFSHash] === undefined ){ + mixtapes[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, + audioDuration:audio.duration + }; + } + console.log( + zblockIPFSHash+"'s duration is: "+ + audio.duration + + " Ceiled: " + Math.ceil(audio.duration) + + " added on " + blockObject.timestamp + " or " + + json.timestamp + + " DIFF: " + (blockObject.timestamp - json.timestamp) + ); + }, false ); + } + if (document.querySelector("#mixtapes-sec-not-found")) document.querySelector("#mixtapes-sec-not-found").hidden=true; + divs.appendChild(art); } - if (document.querySelector("#mixtapes-sec-not-found")) document.querySelector("#mixtapes-sec-not-found").hidden=true; - divs.appendChild(art); } else { archingKaosLog(action + " module not found"); |