function embedPodcast(rssUrl, id, reverse) { container = document.getElementById(id); fetch(rssUrl, {mode: 'no-cors'}) .then(response => response.text()) .then(str => new window.DOMParser().parseFromString(str, "text/xml")) .then(data => { const items = data.querySelectorAll("item"); items.forEach(el => { curDiv = document.createElement("div"); curDiv.setAttribute("class","col-sm-12"); html = `
${el.querySelector("description").textContent}
Duration: ${Math.floor(Number(el.querySelector("duration").textContent)/60)}:${(Number(el.querySelector("duration").textContent)%60).toString().padStart(2,"0")}
`; curDiv.innerHTML = html; if(reverse && container.hasChildNodes()) { container.insertBefore(curDiv, container.firstChild); } else { container.appendChild(curDiv); } }); }); }