Files
fedizinefest-deprecated/scripts/zines.js
T

66 lines
1.6 KiB
JavaScript
Raw Normal View History

2024-12-20 15:37:21 +00:00
function makeZine({ name, blurb, format, site, fedi }) {
2024-12-13 23:04:38 +00:00
let zine = document.createElement("li");
2024-12-20 15:37:21 +00:00
2024-12-13 02:01:49 +00:00
let h2 = document.createElement("h2");
2024-12-20 15:37:21 +00:00
if (site) {
let a = document.createElement("a");
a.innerHTML = name;
a.href = site;
h2.append(a);
} else {
h2.innerHTML = name;
}
2024-12-13 02:01:49 +00:00
zine.append(h2);
2024-12-20 15:37:21 +00:00
2024-12-13 01:14:39 +00:00
let p = document.createElement("p");
2024-12-20 04:30:38 +00:00
p.innerHTML = " is making a " + format + " zine:";
2024-12-13 01:14:39 +00:00
zine.append(p);
2024-12-20 15:37:21 +00:00
2024-12-13 01:26:43 +00:00
let bq = document.createElement("blockquote");
let bqP = document.createElement("p");
bqP.innerHTML = blurb;
bq.append(bqP);
zine.append(bq);
2024-12-20 15:37:21 +00:00
2024-12-13 01:14:39 +00:00
return zine;
}
2025-05-23 15:39:43 +00:00
function makeZinePage(zines) {
for (let i = 0; i < zines.length; i++) {
zineContainer.append(makeZine(zines[i]));
}
let zineCounter = document.getElementById("zine-count");
let total = zines.length;
let physical = zines.filter(
(zine) => zine.format == "physical" || zine.format == "physical/digital"
).length;
let digital = zines.filter(
(zine) => zine.format == "digital" || zine.format == "physical/digital"
).length;
let p = document.createElement("p");
p.innerHTML =
total +
" artists. " +
physical +
" physical zines. " +
digital +
" digital zines.";
zineCounter.append(p);
2024-12-20 15:37:21 +00:00
}
2024-12-23 03:25:58 +00:00
2025-05-23 15:51:31 +00:00
let zineContainer = document.getElementById("zine-container");
fetch("/scripts/zines2025.json")
2025-05-23 15:39:43 +00:00
.then((response) => {
if (!response.ok) {
2025-05-23 15:51:31 +00:00
throw new Error(`HTTP error, status = ${response.status}`);
2025-05-23 15:39:43 +00:00
}
return response.json();
})
2025-05-23 15:51:31 +00:00
.then((zines) => makeZinePage(zines))
.catch((error) => {
console.log(`Error: ${error.message}`);
});