Skip to content

Commit

Permalink
date parts changes
Browse files Browse the repository at this point in the history
  • Loading branch information
norlab committed Jul 10, 2018
1 parent 841d480 commit b72a049
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
10 changes: 6 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ <h1>Paperbuzz Visualizations</h1>
}

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

// var doi = '10.1007/s00266-017-0820-4';
var doi = '10.1038/nature.2017.22163';
//var doi = '10.1080/23800127.2017.1283122';
//var doi = '10.15252/embj.201695429';
//var doi = '10.1016/j.quaint.2011.07.044';
var doi = '10.4236/sn.2017.62007';
//var doi = '10.2190/EC.43.3.f'
//var doi = '10.1038/nature.2017.22163';
d3.json('https://api.paperbuzz.org/v0/doi/' + doi, function(data) {
options.paperbuzzStatsJson = data
paperbuzzviz = new PaperbuzzViz(options);
Expand Down
31 changes: 27 additions & 4 deletions paperbuzzviz.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,36 @@ function PaperbuzzViz(options) {
// TODO: Fix to work when no pub date is available. Use earliest event
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];
if (data.metadata["published-online"]["date-parts"][0][1]) {
var month = data.metadata["published-online"]["date-parts"][0][1];
} else {var month = 01
}
if (data.metadata["published-online"]["date-parts"][0][2]) {
var day = data.metadata["published-online"]["date-parts"][0][2];
} else {var day = 01
}
var published_date = year+"-"+month+"-"+day;
} else if (data.metadata['published-print']) {
var year = data.metadata["published-print"]["date-parts"][0][0];
if (data.metadata["published-print"]["date-parts"][0][1]) {
var month = data.metadata["published-print"]["date-parts"][0][1];
} else {var month = 01
}
if (data.metadata["published-print"]["date-parts"][0][2]) {
var day = data.metadata["published-print"]["date-parts"][0][2];
} else {var day = 01
}
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];
if (data.metadata["issued"]["date-parts"][0][1]) {
var month = data.metadata["issued"]["date-parts"][0][1];
} else {var month = 01
}
if (data.metadata["issued"]["date-parts"][0][2]) {
var day = data.metadata["issued"]["date-parts"][0][2];
} else {var day = 01
}
var published_date = year+"-"+month+"-"+day;
}

Expand Down

0 comments on commit b72a049

Please sign in to comment.