瀏覽代碼

Display owner information for characters when available

tags/v0.1.0
Fen Dweller 5 年之前
父節點
當前提交
3ed3e750db
共有 2 個檔案被更改,包括 50 行新增2 行删除
  1. +22
    -0
      macrovision.js
  2. +28
    -2
      media/attribution.js

+ 22
- 0
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) {


+ 28
- 2
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;


Loading…
取消
儲存