From 310aaa47899d0ca2406dd80c90170a05a47779fe Mon Sep 17 00:00:00 2001 From: Benjamin Degenhart Date: Thu, 23 May 2024 14:41:46 +0200 Subject: [PATCH] Show the tree-path in the missing df label --- public/index.html | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/public/index.html b/public/index.html index e9ae62f..1c394f7 100644 --- a/public/index.html +++ b/public/index.html @@ -249,7 +249,7 @@

Report

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) { @@ -275,6 +275,32 @@

Report

} } + 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 @@ -447,7 +473,6 @@

Report

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