2026-01-06 17:33:25 -08:00
|
|
|
const makeArtistImg = function(artistImg) {
|
2025-12-28 13:36:31 -08:00
|
|
|
let imgDiv = document.createElement("div");
|
|
|
|
|
imgDiv.classList.add("fit-contain");
|
2026-01-06 17:33:25 -08:00
|
|
|
|
2025-12-28 13:36:31 -08:00
|
|
|
let img = document.createElement("img");
|
2026-01-06 17:33:25 -08:00
|
|
|
img.src = artistImg.src;
|
2026-01-06 17:57:56 -08:00
|
|
|
|
2026-01-06 18:10:40 -08:00
|
|
|
/* handle single-line or multi-line alts */
|
2026-01-06 17:57:56 -08:00
|
|
|
if (typeof artistImg.alt === "string") img.alt = artistImg.alt;
|
|
|
|
|
else {
|
|
|
|
|
let fullAlt = `a ${artistImg.alt.length} image collage.`
|
|
|
|
|
for (let i = 0; i < artistImg.alt.length; i++)
|
|
|
|
|
fullAlt += ` ${i}: ${artistImg.alt[i]}`
|
|
|
|
|
img.alt = fullAlt;
|
|
|
|
|
}
|
2025-12-28 13:36:31 -08:00
|
|
|
|
2026-01-06 17:33:25 -08:00
|
|
|
imgDiv.append(img);
|
|
|
|
|
return imgDiv;
|
|
|
|
|
}
|
2025-12-28 13:36:31 -08:00
|
|
|
|
2026-01-06 17:33:25 -08:00
|
|
|
const makeArtistDesc = function(bio, contact) {
|
2025-12-28 13:36:31 -08:00
|
|
|
let descDiv = document.createElement("div");
|
|
|
|
|
descDiv.classList.add("description");
|
2026-01-06 17:33:25 -08:00
|
|
|
|
2026-01-06 18:10:40 -08:00
|
|
|
/* multi-line bio array */
|
2026-01-06 17:33:25 -08:00
|
|
|
for (const bioLine of bio) {
|
|
|
|
|
let p = document.createElement("p");
|
|
|
|
|
p.innerHTML = bioLine;
|
|
|
|
|
descDiv.append(p);
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-06 18:10:40 -08:00
|
|
|
/* artist contact info */
|
2025-12-28 13:36:31 -08:00
|
|
|
let contacts = document.createElement("p");
|
2026-01-06 17:33:25 -08:00
|
|
|
for (let i = 0; i < contact.length; i++) {
|
2025-12-28 13:36:31 -08:00
|
|
|
let a = document.createElement("a");
|
2026-01-06 17:33:25 -08:00
|
|
|
a.href = contact[i].href;
|
|
|
|
|
a.innerHTML = contact[i].title;
|
2025-12-28 13:36:31 -08:00
|
|
|
a.target = "_blank";
|
|
|
|
|
contacts.append(a);
|
|
|
|
|
|
2026-01-06 17:33:25 -08:00
|
|
|
if (i !== contact.length - 1) contacts.append(" ● ");
|
2025-12-28 13:36:31 -08:00
|
|
|
}
|
|
|
|
|
descDiv.append(contacts);
|
|
|
|
|
|
2026-01-06 17:33:25 -08:00
|
|
|
return descDiv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const makeArtist = function(artist) {
|
|
|
|
|
let container = document.createElement("div");
|
|
|
|
|
container.classList.add("artist");
|
|
|
|
|
container.id = artist.id;
|
|
|
|
|
|
|
|
|
|
/* artist img */
|
|
|
|
|
container.append(makeArtistImg(artist.img));
|
|
|
|
|
|
|
|
|
|
/* artist name */
|
|
|
|
|
let h3 = document.createElement("h3");
|
|
|
|
|
h3.innerHTML = artist.name;
|
|
|
|
|
container.append(h3);
|
|
|
|
|
|
|
|
|
|
/* artist description */
|
|
|
|
|
container.append(makeArtistDesc(artist.bio, artist.contact));
|
2025-12-28 13:36:31 -08:00
|
|
|
return container;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let artistContainer = document.getElementById("artists");
|
|
|
|
|
|
|
|
|
|
const makeArtistPage = function(artists) {
|
|
|
|
|
for (const artist of artists)
|
|
|
|
|
artistContainer.append(makeArtist(artist));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let script = document.currentScript;
|
|
|
|
|
let artistsfile = script.dataset.artists;
|
|
|
|
|
|
|
|
|
|
fetch(artistsfile)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
if (!response.ok) {
|
|
|
|
|
throw new Error(`HTTP error, status = ${response.status}`);
|
|
|
|
|
}
|
|
|
|
|
return response.json();
|
|
|
|
|
})
|
|
|
|
|
.then((artists) => makeArtistPage(artists))
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
console.log(`Error: ${error.message}`);
|
|
|
|
|
});
|