Skip to content

Commit 1589e45

Browse files
authored
Update script.js
1 parent fbb39e0 commit 1589e45

File tree

1 file changed

+2
-32
lines changed

1 file changed

+2
-32
lines changed

script.js

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,8 @@
11
(async function() {
2-
// Use the ACCEPT environment
3-
const apiRoot = "https://digitalcollections-accept.library.maastrichtuniversity.nl/api";
4-
const itemSetId = 60514; // Maastricht History Clinic (accept)
5-
62
try {
7-
// Step 1: Get all people in that item set
8-
const peopleRes = await fetch(`${apiRoot}/item_sets/${itemSetId}/items`);
9-
const people = await peopleRes.json();
10-
11-
const rootData = { name: "Maastricht History Clinic", children: [] };
12-
13-
// Step 2: For each person, find linked objects
14-
for (const person of people) {
15-
const personNode = { name: person["o:title"] || "Unnamed", children: [] };
16-
17-
const relatedUrl =
18-
`${apiRoot}/items?property[0][joiner]=and&property[0][property]=schema:about` +
19-
`&property[0][type]=resource&property[0][text]=${encodeURIComponent(person["@id"])}`;
20-
const relatedRes = await fetch(relatedUrl);
21-
const relatedObjects = await relatedRes.json();
3+
const res = await fetch("data.json");
4+
const rootData = await res.json();
225

23-
for (const obj of relatedObjects) {
24-
personNode.children.push({
25-
name: obj["o:title"] || "Memory Object",
26-
url: obj["@id"].replace("/api", "")
27-
});
28-
}
29-
30-
rootData.children.push(personNode);
31-
}
32-
33-
// Step 3: Draw the D3 tree
346
const width = 1000, height = 700;
357
const treeLayout = d3.tree().size([height - 80, width - 160]);
368
const root = d3.hierarchy(rootData);
@@ -70,9 +42,7 @@
7042
.on("click", (e, d) => {
7143
if (d.data.url) window.open(d.data.url, "_blank");
7244
});
73-
7445
} catch (err) {
7546
console.error("Error loading data:", err);
7647
}
7748
})();
78-

0 commit comments

Comments
 (0)