From 3ed3e750db6eeba43218861bff93fb560ce09b2e Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Mon, 24 Feb 2020 12:56:42 -0500 Subject: [PATCH] Display owner information for characters when available --- macrovision.js | 22 ++++++++++++++++++++++ media/attribution.js | 30 ++++++++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/macrovision.js b/macrovision.js index 7406e851..ba81912f 100644 --- a/macrovision.js +++ b/macrovision.js @@ -684,9 +684,11 @@ function clearAttribution() { function displayAttribution(file) { document.querySelector("#options-attribution").style.display = "inline"; const authors = authorsOfFull(file); + const owners = ownersOfFull(file); const source = sourceOf(file); const authorHolder = document.querySelector("#options-attribution-authors"); + const ownerHolder = document.querySelector("#options-attribution-owners"); const sourceHolder = document.querySelector("#options-attribution-source"); if (authors === []) { @@ -709,6 +711,26 @@ function displayAttribution(file) { } + if (owners === []) { + ownerHolder.innerText = "Unknown"; + } else if (owners === undefined) { + ownerHolder.innerText = "Not yet entered"; + } else { + ownerHolder.innerHTML = ""; + + const list = document.createElement("ul"); + ownerHolder.appendChild(list); + owners.forEach(owner => { + const ownerEntry = document.createElement("li"); + const link = document.createElement("a"); + link.href = owner.url; + link.innerText = owner.name; + ownerEntry.appendChild(link); + list.appendChild(ownerEntry); + }); + + } + if (source === null) { sourceHolder.innerText = "No Link" } else if (source === undefined) { diff --git a/media/attribution.js b/media/attribution.js index 50d7acdd..f6f38ea9 100644 --- a/media/attribution.js +++ b/media/attribution.js @@ -120,7 +120,7 @@ const attributionData = { ] } ], - authors: { + people: { "cardboardhead": { name: "cardboardhead", url: "https://twitter.com/cardboardhead" @@ -173,6 +173,7 @@ function prepareAttribution() { citation.files.forEach(file => { attribution.files[citation.prefix + file.name] = { authors: citation.authors, + owners: citation.owners, source: file.source } }) @@ -190,7 +191,7 @@ function authorsOfFull(file) { if (attribution.files[file]) { const result = []; attribution.files[file].authors.forEach(author => { - result.push(attributionData.authors[author]); + result.push(attributionData.people[author]); }); return result; @@ -199,6 +200,31 @@ function authorsOfFull(file) { return undefined; } +function ownersOf(file) { + if (attribution.files[file]) + return attribution.files[file].owners; + else + return undefined; +} + +function ownersOfFull(file) { + if (attribution.files[file]) { + if (attribution.files[file].owners !== undefined) { + const result = []; + attribution.files[file].owners.forEach(owner => { + result.push(attributionData.people[owner]); + }); + + return result; + } else { + return []; + } + + } + else + return undefined; +} + function sourceOf(file) { if (attribution.files[file]) return attribution.files[file].source;