-
Notifications
You must be signed in to change notification settings - Fork 0
/
Credit.js
28 lines (26 loc) · 868 Bytes
/
Credit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class Credit {
formatListAsText(authors) {
if (authors.length === 1) {
return authors[0]
} else if (authors.length === 2) {
return authors[0] + " and " + authors[1]
} else {
const lastAuthor = authors.pop()
return authors.join(", ") + ", and " + lastAuthor
}
}
getAuthorText() {
if (typeof(metadata) === 'undefined' || metadata === null
|| metadata.authors === undefined || metadata.authors === null
|| metadata.authors.length === 0) {
return "unknown"
} else {
const authors = metadata.authors.slice()
return this.formatListAsText(authors)
}
}
updateHtml() {
const authorText = this.getAuthorText()
document.getElementById('authors').innerHTML = authorText
}
}