This commit is contained in:
Oliver
2025-06-23 12:27:48 -03:00
parent 8f60e78152
commit 24d316a60e
107 changed files with 1359 additions and 13255 deletions

29
assets/js/main.js Normal file
View File

@@ -0,0 +1,29 @@
document.addEventListener("DOMContentLoaded", function () {
const modal = document.getElementById("story-modal");
const content = document.getElementById("modal-content");
const close = document.getElementById("close-modal");
document.querySelectorAll(".open-modal").forEach((btn) => {
btn.addEventListener("click", async function () {
const url = this.getAttribute("data-story-url");
try {
const res = await fetch(url);
const html = await res.text();
const parser = new DOMParser();
const doc = parser.parseFromString(html, "text/html");
// Optional: target only the article content
const article = doc.querySelector("article") || doc.body;
content.innerHTML = article.innerHTML;
modal.classList.add("show-story-modal");
} catch (err) {
content.innerHTML = "<p>Failed to load content.</p>";
modal.classList.add("show-story-modal");
}
});
});
close.addEventListener("click", () => modal.classList.remove("show-story-modal"));
});