Skip to content
This repository has been archived by the owner on Dec 22, 2020. It is now read-only.

Updated to match changes in CrossRef results #255

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions oabutton/static/public/js/success.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,27 @@
var oabSuccess = (function($) {

function parseCrossRef(entry, doi) {
var metadata = {'doi': doi},
item = entry["pam:message"]["pam:article"];
var metadata = {'doi': doi};

if (item["dc:title"]) {
metadata["title"] = item["dc:title"];
if (entry["title"]) {
metadata["title"] = entry["title"];
}

if (item["dc:creator"]) {
if (!$.isArray(item["dc:creator"])) {
item["dc:creator"] = [item["dc:creator"]];
if (entry["author"]) {
if (!$.isArray(entry["author"])) {
entry["author"] = [entry["author"]];
}

metadata["authors"] = formatAuthorList(item["dc:creator"]);
metadata["authors"] = formatAuthorList(entry["author"]);
}

if (item["prism:publicationName"]) {
metadata["publication"] = item["prism:publicationName"];
if (entry["container-title"]) {
metadata["publication"] = entry["container-title"];
}

if (item["prism:publicationDate"]) {
if (entry["issued"]) {
// TODO: zero-pad or reformat the date, using Moment.js?
metadata["date"] = item["prism:publicationDate"];
metadata["date"] = entry["issued"]["date-parts"];
}

return metadata;
Expand All @@ -48,8 +47,8 @@ var oabSuccess = (function($) {
url: '/api/xref_proxy_simple/' + encodeURIComponent(doi),
dataType: "json",
success: function(response) {
if (response.feed.entry) {
var metadata = parseCrossRef(response.feed.entry, doi);
if (response) {
var metadata = parseCrossRef(response, doi);

addPubMedCentralLink(metadata);
addScholarDOILink(metadata);
Expand Down