Skip to content

Commit

Permalink
published if else
Browse files Browse the repository at this point in the history
  • Loading branch information
norlab committed Apr 8, 2018
1 parent ea26fe9 commit f4c6978
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Binary file added .DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ <h1>Paperbuzz Visualizations</h1>
}

var paperbuzzviz = undefined;
var doi = '10.1371/journal.pmed.0020124';
//var doi = '10.1371/journal.pmed.0020124';

// var doi = '10.1007/s00266-017-0820-4';
// var doi = '10.7287/peerj.preprints.3119v1';
var doi = '10.7287/peerj.preprints.3119v1';
d3.json('https://api.paperbuzz.org/v0/doi/' + doi, function(data) {
options.paperbuzzStatsJson = data
paperbuzzviz = new PaperbuzzViz(options);
Expand Down
15 changes: 11 additions & 4 deletions paperbuzzviz.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,17 @@ function PaperbuzzViz(options) {
console.log(data);

// TODO: Fix to work when no pub date is available. Use earliest event
var year = data.metadata["published-online"]["date-parts"][0][0];
var month = data.metadata["published-online"]["date-parts"][0][1];
var day = data.metadata["published-online"]["date-parts"][0][2];
var published_date = year+"-"+month+"-"+day;
if (data.metadata['published-online']) {
var year = data.metadata["published-online"]["date-parts"][0][0];
var month = data.metadata["published-online"]["date-parts"][0][1];
var day = data.metadata["published-online"]["date-parts"][0][2];
var published_date = year+"-"+month+"-"+day;
} else {
var year = data.metadata["issued"]["date-parts"][0][0];
var month = data.metadata["issued"]["date-parts"][0][1];
var day = data.metadata["issued"]["date-parts"][0][2];
var published_date = year+"-"+month+"-"+day;
}

// extract publication date
var pub_date = parseDate(published_date);
Expand Down

0 comments on commit f4c6978

Please sign in to comment.