1 line
684 B
JavaScript
1 line
684 B
JavaScript
document.addEventListener("DOMContentLoaded",function(){const e=document.getElementById("story-modal"),t=document.getElementById("modal-content"),n=document.getElementById("close-modal");document.querySelectorAll(".open-modal").forEach(n=>{n.addEventListener("click",async function(){const n=this.getAttribute("data-story-url");try{const o=await fetch(n),i=await o.text(),a=new DOMParser,s=a.parseFromString(i,"text/html"),r=s.querySelector("article")||s.body;t.innerHTML=r.innerHTML,e.classList.add("show-story-modal")}catch{t.innerHTML="<p>Failed to load content.</p>",e.classList.add("show-story-modal")}})}),n.addEventListener("click",()=>e.classList.remove("show-story-modal"))}) |