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

Commit

Permalink
Cosmetics: simplify the callback syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminaaron committed May 23, 2024
1 parent f9eff44 commit 01e27ee
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,7 @@ <h3>Report</h3>
function addEntryToSubject(subject, predicate, objectValue) {
subject = "ff:" + subject.split("#")[1]
predicate = "ff:" + predicate.split("#")[1]
searchSubjectNodeRecursively(userProfile, subject, (node) => {
node[predicate] = objectValue
})
searchSubjectNodeRecursively(userProfile, subject, (node) => node[predicate] = objectValue)
}

function instantiateNewObjectClassUnderSubject(subject, predicate, objectClass) {
Expand Down Expand Up @@ -358,20 +356,12 @@ <h3>Report</h3>
}
}

function updateEntryValue(sKey, pKey, newValue) {
searchSubjectNodeRecursively(userProfile, sKey, (node) => {
node[pKey] = newValue
})
}

async function buildRemovalCell(td, sKey, pKey) {
td.textContent = "x"
td.addEventListener("click", async function() {
if (confirm("Do you want to remove this entry?")) {
console.log("Removing entry:", sKey, pKey)
searchSubjectNodeRecursively(userProfile, sKey, (node) => {
delete node[pKey]
})
searchSubjectNodeRecursively(userProfile, sKey, (node) => delete node[pKey])
await finalizeProfileChanges()
}
})
Expand All @@ -391,7 +381,7 @@ <h3>Report</h3>
let input = prompt(`Enter new value for ${label}`)
if (input !== null) {
console.log("Changing entry value:", subject, predicate, "-->", input)
updateEntryValue(subject, predicate, input)
searchSubjectNodeRecursively(userProfile, subject, (node) => node[predicate] = input)
await finalizeProfileChanges()
}
})
Expand Down

0 comments on commit 01e27ee

Please sign in to comment.