mirror of
https://github.com/LCPQ/QUESTDB_website.git
synced 2024-11-04 13:13:55 +01:00
Put creation of publication UI in createPubliUI
This commit is contained in:
parent
1e6f71f58f
commit
9ee1565bde
@ -13,6 +13,7 @@ draft: false
|
||||
<script src="/js/getSets.js"></script>
|
||||
<script src="/js/websiteFile.js"></script>
|
||||
<script src="/js/numberUtils.js"></script>
|
||||
<script src="/js/createPubliUI.js"></script>
|
||||
{{< getDataFilesName >}}
|
||||
<script>
|
||||
window.onload = async function () {
|
||||
@ -21,75 +22,9 @@ draft: false
|
||||
const dois = uniq(Object.values(await loadAllData()).flat().map(d => d.DOI.string))
|
||||
const publiscite = await Cite.async(dois)
|
||||
const sets = await getSets()
|
||||
console.log(sets)
|
||||
const publis = publiscite.format('data', { format: 'object' })
|
||||
for (const publi of publis) {
|
||||
const art = $("<article/>").addClass("publi")
|
||||
art.className = "publi"
|
||||
console.log(sets.get(publi.DOI))
|
||||
$("<h1/>").text(sets.get(publi.DOI)).appendTo(art)
|
||||
$("<a/>", {
|
||||
href: publi.URL,
|
||||
target: "_blank"
|
||||
}).html($("<h2/>").text(publi.title)).appendTo(art)
|
||||
const authors = publi.author
|
||||
const ulauthors = $("<ul/>").addClass("authors-list").appendTo(art)
|
||||
for (const author of authors) {
|
||||
const liauth = $("<li/>").addClass("author-item")
|
||||
const spanAuth = $("<span/>").text(String.raw`${author.given} ${author.family}`).appendTo(liauth)
|
||||
if (author.sequence === "first") {
|
||||
$(spanAuth).after($("<strong/>").text("*"))
|
||||
}
|
||||
var notifycontent = $("<div/>").addClass("author-info")
|
||||
$("<h1/>").text(String.raw`${author.given} ${author.family}`).appendTo(notifycontent)
|
||||
ulaff = $("<ul/>").addClass("affiliation-list").appendTo(notifycontent)
|
||||
for (const a of author.affiliation) {
|
||||
$("<li/>").text(a.name).appendTo(ulaff)
|
||||
}
|
||||
if (author["authenticated-orcid"]) {
|
||||
const html = String.raw`<div class="orcid-id"><a href="https://orcid.org" target="_blank"><img alt="ORCID logo" src="https://orcid.org/sites/default/files/images/orcid_16x16.png" width="16" height="16"/></a> <a href="${author.ORCID}" target="_blank">${author.ORCID} </a></div>`
|
||||
notifycontent.append(html)
|
||||
}
|
||||
tippy(spanAuth[0], {
|
||||
content: notifycontent[0],
|
||||
theme: 'light',
|
||||
interactive: true,
|
||||
});
|
||||
ulauthors.append(liauth)
|
||||
}
|
||||
journaldiv = $("<div/>").appendTo(art)
|
||||
if ("container-title-short" in publi) {
|
||||
var title_short = $("<span/>").text(publi["container-title-short"])
|
||||
journaldiv.append(title_short)
|
||||
tippy(title_short[0], {
|
||||
content: publi["container-title"],
|
||||
theme: 'light',
|
||||
});
|
||||
}
|
||||
else {
|
||||
$("<span/>").text(publi["container-title"]).appendTo(journaldiv)
|
||||
}
|
||||
var datArr = publi.issued["date-parts"][0]
|
||||
var date = new Date(datArr[0], datArr[1] - 1, datArr[2])
|
||||
$("<span/>").text(date.getFullYear().toString()).appendTo(journaldiv)
|
||||
journaldiv.append(" ")
|
||||
$("<span/>").text(publi.volume).appendTo(journaldiv)
|
||||
if (publi.issue) {
|
||||
$("<span/>").addClass("issue").text(publi.issue).appendTo(journaldiv)
|
||||
journaldiv.append(", ")
|
||||
$("<span/>").text(publi.page).appendTo(journaldiv)
|
||||
}
|
||||
$("<a/>", {
|
||||
href: publi.URL,
|
||||
target: "_blank"
|
||||
}).text(String.raw`DOI: ${publi.DOI}`).appendTo(art)
|
||||
$("<p/>").append("Published on ").append($("<time/>", {
|
||||
datetime: JSON.stringify(date)
|
||||
}).text(date.toLocaleDateString("en-us", {
|
||||
day: "numeric",
|
||||
month: "short",
|
||||
year: "numeric"
|
||||
}))).appendTo(art)
|
||||
art=createPubliUI(publi,sets,true)
|
||||
$(art).appendTo("<li/>").appendTo("#publis_ul")
|
||||
}
|
||||
}
|
||||
|
75
static/js/createPubliUI.js
Normal file
75
static/js/createPubliUI.js
Normal file
@ -0,0 +1,75 @@
|
||||
function createPubliUI(publi,sets=new Map(),toolTips=false) {
|
||||
const art = $("<article/>").addClass("publi")
|
||||
art.className = "publi"
|
||||
if (sets.has(publi.DOI)) {
|
||||
$("<h1/>").text(sets.get(publi.DOI)).appendTo(art)
|
||||
}
|
||||
$("<a/>", {
|
||||
href: publi.URL,
|
||||
target: "_blank"
|
||||
}).html($("<h2/>").text(publi.title)).appendTo(art)
|
||||
const authors = publi.author
|
||||
const ulauthors = $("<ul/>").addClass("authors-list").appendTo(art)
|
||||
for (const author of authors) {
|
||||
const liauth = $("<li/>").addClass("author-item")
|
||||
const spanAuth = $("<span/>").text(String.raw`${author.given} ${author.family}`).appendTo(liauth)
|
||||
if (author.sequence === "first") {
|
||||
$(spanAuth).after($("<strong/>").text("*"))
|
||||
}
|
||||
var notifycontent = $("<div/>").addClass("author-info")
|
||||
$("<h1/>").text(String.raw`${author.given} ${author.family}`).appendTo(notifycontent)
|
||||
ulaff = $("<ul/>").addClass("affiliation-list").appendTo(notifycontent)
|
||||
for (const a of author.affiliation) {
|
||||
$("<li/>").text(a.name).appendTo(ulaff)
|
||||
}
|
||||
if (author["authenticated-orcid"]) {
|
||||
const html = String.raw`<div class="orcid-id"><a href="https://orcid.org" target="_blank"><img alt="ORCID logo" src="https://orcid.org/sites/default/files/images/orcid_16x16.png" width="16" height="16"/></a> <a href="${author.ORCID}" target="_blank">${author.ORCID} </a></div>`
|
||||
notifycontent.append(html)
|
||||
}
|
||||
if (toolTips) {
|
||||
tippy(spanAuth[0], {
|
||||
content: notifycontent[0],
|
||||
theme: 'light',
|
||||
interactive: true,
|
||||
});
|
||||
}
|
||||
|
||||
ulauthors.append(liauth)
|
||||
}
|
||||
journaldiv = $("<div/>").appendTo(art)
|
||||
if ("container-title-short" in publi) {
|
||||
var title_short = $("<span/>").text(publi["container-title-short"])
|
||||
journaldiv.append(title_short)
|
||||
if (toolTips) {
|
||||
tippy(title_short[0], {
|
||||
content: publi["container-title"],
|
||||
theme: 'light',
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
$("<span/>").text(publi["container-title"]).appendTo(journaldiv)
|
||||
}
|
||||
var datArr = publi.issued["date-parts"][0]
|
||||
var date = new Date(datArr[0], datArr[1] - 1, datArr[2])
|
||||
$("<span/>").text(date.getFullYear().toString()).appendTo(journaldiv)
|
||||
journaldiv.append(" ")
|
||||
$("<span/>").text(publi.volume).appendTo(journaldiv)
|
||||
if (publi.issue) {
|
||||
$("<span/>").addClass("issue").text(publi.issue).appendTo(journaldiv)
|
||||
journaldiv.append(", ")
|
||||
$("<span/>").text(publi.page).appendTo(journaldiv)
|
||||
}
|
||||
$("<a/>", {
|
||||
href: publi.URL,
|
||||
target: "_blank"
|
||||
}).text(String.raw`DOI: ${publi.DOI}`).appendTo(art)
|
||||
$("<p/>").append("Published on ").append($("<time/>", {
|
||||
datetime: JSON.stringify(date)
|
||||
}).text(date.toLocaleDateString("en-us", {
|
||||
day: "numeric",
|
||||
month: "short",
|
||||
year: "numeric"
|
||||
}))).appendTo(art)
|
||||
return art
|
||||
}
|
Loading…
Reference in New Issue
Block a user