Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
Show the tree-path in the missing df label
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminaaron committed May 23, 2024
1 parent 8d4fe7b commit 310aaa4
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ <h3>Report</h3>
div.appendChild(spanEl)
let a = document.createElement("a")
a.href = "#"
a.textContent = entry.label
a.textContent = collectSubjectClassLabelsAlongPath(entry)
a.addEventListener("click", async function(event) {
event.preventDefault()
if (entry.objectHasClass) {
Expand All @@ -275,6 +275,32 @@ <h3>Report</h3>
}
}

function collectSubjectClassLabelsAlongPath(entry) { // prioritizedListEntry
if (shortenLongUri(entry.subject) === "ff:mainPerson") {
return entry.label
}
let sUri = shortenLongUri(entry.subject)
let path = ""
let finalPath
function recurse(node, arrIndex, sUri, path) {
if (node["@type"] !== "ff:Citizen") path += ", " + metadata.df[expandShortUri(node["@type"])].label + " " + arrIndex
for (let objectOrArray of Object.values(node)) {
if (objectOrArray === sUri) {
finalPath = path.substring(1)
}
if (Array.isArray(objectOrArray)) {
for (let i = 0; i < objectOrArray.length; i++) {
let arrayEl = objectOrArray[i]
recurse(arrayEl, i, sUri, path)
}
}
}

}
recurse(userProfile, 0, sUri, path)
return finalPath + ": " + entry.label
}

function searchNodeRecursively(node, predicateValue, objectValue, action) {
for (let [predicate, objectOrArray] of Object.entries(node)) {
if (objectValue && objectOrArray === objectValue) { // e.g. ff:child0 as the value, key would be @id
Expand Down Expand Up @@ -447,7 +473,6 @@ <h3>Report</h3>

async function clearUserProfile() {
localStorage.clear()
userProfile = EMPTY_PROFILE
localStorage.setItem("userProfile", JSON.stringify(userProfile))
await update()
}
Expand Down

0 comments on commit 310aaa4

Please sign in to comment.