Commit 63c4aae7 authored by Maxime Chaillet's avatar Maxime Chaillet
Browse files

separate object containing data retrieved from datacite from the object used in the template.

parent 7875b6a9
This diff is collapsed.
(function(dust){dust.register("badges_tpl",body_0);function body_0(chk,ctx){return chk.w("<div class=\"col-12\"><div><span class=\"badge badge-success\" style=\"font-size:14px;\"> open Access </span></div></div>");}body_0.__dustBody=!0;return body_0}(dust));
(function(dust){dust.register("doinotfound_tpl",body_0);function body_0(chk,ctx){return chk.w("<div class=\"container-fluid \" style=\"color:black;\"><div class=\"row\"><div class=\"col-3\"> </div><div class=\"col-6 lightRedBackground text-center rounded\"> <p> ").f(ctx.get(["message"], false),ctx,"h",["s"]).w(" </p> </div></div><div class=\"col-3\"> </div></div> ");}body_0.__dustBody=!0;return body_0}(dust));
(function(dust){dust.register("doinotfound2_tpl",body_0);function body_0(chk,ctx){return chk.f(ctx.get(["message"], false),ctx,"h",["s"]);}body_0.__dustBody=!0;return body_0}(dust));
(function(dust){dust.register("experimentalreport_tpl",body_0);function body_0(chk,ctx){return chk.w("<div class=\"card-header text-center\"><label>Experimental report </label></div><div class=\"card-body padding10\">").x(ctx.get(["data"], false),ctx,{"else":body_1,"block":body_2},{});}body_0.__dustBody=!0;function body_1(chk,ctx){return chk.w("<p> There is currently no experimental report. </p></div>");}body_1.__dustBody=!0;function body_2(chk,ctx){return chk.h("eq",ctx,{"block":body_3},{"key":ctx.getPath(false, ["data","length"]),"value":1},"h").h("gt",ctx,{"block":body_4},{"key":ctx.getPath(false, ["data","length"]),"value":1},"h").w(" </div>");}body_2.__dustBody=!0;function body_3(chk,ctx){return chk.w("<p> <b> One </b> report has been found for this proposal. </p></div><div class=\"card-footer\"> <button type=\"button\" class=\"btn btn-primary btn-lg btn-block\" onclick=\"javascript:(function(){ var expRep = new ExperimentalReportController(); expRep.openFileInNewTab('").f(ctx.getPath(false, ["data","0"]),ctx,"h").w("'); })()\" > <span class=\"fa fa-download whiteFont\"></span> ").f(ctx.getPath(false, ["data","0"]),ctx,"h").w(" </button></div>");}body_3.__dustBody=!0;function body_4(chk,ctx){return chk.w("<p> In total, <b> ").f(ctx.getPath(false, ["data","length"]),ctx,"h").w(" </b> reports have been found for this proposal: </p><div class=\"scroll-box\">").s(ctx.get(["data"], false),ctx,{"block":body_5},{}).w("</div>");}body_4.__dustBody=!0;function body_5(chk,ctx){return chk.w(" <div class=\"row\"> <div class=\"col-1\"> </div><div class=\"col-10 padding-bottom-10\"><button type=\"button\" class=\"btn btn-primary btn-lg btn-block\" onclick=\"javascript:(function(){ var expRep = new ExperimentalReportController(); expRep.openFileInNewTab('").f(ctx.getPath(true, []),ctx,"h").w("'); })()\" > <span class=\"fa fa-download whiteFont\"></span> <span class=\"whitefont\"> ").f(ctx.getPath(true, []),ctx,"h").w("</span> </button></div><div class=\"col-1\"> </div></div>");}body_5.__dustBody=!0;return body_0}(dust));
(function(dust){dust.register("landingpage_tpl",body_0);function body_0(chk,ctx){return chk.w("<div class=\"container-fluid\"><br /><div class=\"row padding-top-15\"><div class=\"col-8\"><div class=\"row\"><div class=\"col-12 fontSize-20 text-center text-uppercase font-weight-bold\">").f(ctx.getPath(false, ["data","title"]),ctx,"h").w("</div></div><hr><div class=\"row\"><div class=\"col-4\"><div class=\"myBorder-left\"><label> Proposal </label>").x(ctx.getPath(false, ["data","proposalNumber"]),ctx,{"else":body_1,"block":body_2},{}).w("</div></div><div class=\"col-4\"><div class=\"myBorder-left\"><label> Publication year </label>").x(ctx.getPath(false, ["data","mintingYear"]),ctx,{"else":body_3,"block":body_4},{}).w("</div></div> <div class=\"col-4\"><div class=\"myBorder-left\"><label> Beamline </label> ").x(ctx.getPath(false, ["data","beamline"]),ctx,{"else":body_5,"block":body_6},{}).w("</div></div></div><div class=\"padding-top-15\"></div><div class=\"row\"><div class=\"col-4\"><div class=\"myBorder-left\"><label> Session date </label>").x(ctx.getPath(false, ["data","sessionDate"]),ctx,{"else":body_9,"block":body_10},{}).w("</div></div> <div class=\"col-4\"><div class=\"myBorder-left\"><label>Category </label>").x(ctx.getPath(false, ["data","proposalType"]),ctx,{"else":body_11,"block":body_12},{}).w("</div></div> <div class=\"col-4\"> <div class=\"myBorder-left\"><label>Publisher </label> <div class=\"padding-left-15\"><a href=\"http://www.esrf.fr\"> ").f(ctx.getPath(false, ["data","publisher"]),ctx,"h").w(" </a> </div></div></div> </div><hr><div class=\"row\"><div class=\"col-12\"><div class=\"myBorder-left\"><label> Abstract </label><div class=\"padding-left-15\">There is no abstract for this session.</div></div> </div></div><hr><div class=\"row\"><div class=\"col-12\"><div class=\"card-deck\"><div class=\"card\" id=\"expReport\"><div class=\"card-header text-center\"><label>Experimental report </label></div></div><div class=\"card\"><div class=\"card-header text-center\"><label>Experimental data </label></div><div class=\"card-body padding10\"><p class=\"card-text\" >").f(ctx.getPath(false, ["data","accessMessage"]),ctx,"h",["s"]).w("</p></div><div class=\"card-footer\"><form action=\"https://icat.esrf.fr/#/browse/facility/ESRF/proposal/").f(ctx.getPath(false, ["data","proposalNumber"]),ctx,"h").w("/investigation/").f(ctx.getPath(false, ["data","investigationId"]),ctx,"h").w("/dataset\" target=\"_blank\"><button type=\"submit\" class=\"btn btn-primary btn-lg btn-block\"> Access data </button></form></div></div></div></div></div><hr><div class=\"row\"><div class=\"col-12\"><div class=\"myBorder-left\"><label> Citation </label><div class=\"padding-left-15\"><p> Below is the recommended format for citing this work in a research publication.</p><div class=\"padding-left-15\"><cite> ").f(ctx.getPath(false, ["data","citation"]),ctx,"h",["s"]).w(" </cite></div></div></div> </div></div> </div><div class=\"col-4\"><div class=\"row\"><div class=\"col-12\"><div class=\"card\"><div class=\"card-header text-center\"><label>Authors </label></div><div class=\"card-body text-center\">").s(ctx.getPath(false, ["data","creator"]),ctx,{"block":body_13},{}).w("</div></div></div></div></div></div> </div>");}body_0.__dustBody=!0;function body_1(chk,ctx){return chk.w("<div class=\"padding-left-15\"> Not available</div>");}body_1.__dustBody=!0;function body_2(chk,ctx){return chk.w("<div class=\"padding-left-15\">").f(ctx.getPath(false, ["data","proposalNumber"]),ctx,"h").w("</div>");}body_2.__dustBody=!0;function body_3(chk,ctx){return chk.w("<div class=\"padding-left-15\"> Not available</div>");}body_3.__dustBody=!0;function body_4(chk,ctx){return chk.w("<div class=\"padding-left-15\">").f(ctx.getPath(false, ["data","mintingYear"]),ctx,"h").w("</div>");}body_4.__dustBody=!0;function body_5(chk,ctx){return chk.w("<div class=\"padding-left-15\">Not available</div>");}body_5.__dustBody=!0;function body_6(chk,ctx){return chk.h("eq",ctx,{"else":body_7,"block":body_8},{"key":ctx.getPath(false, ["data","beamlineUrl"]),"value":"noLink"},"h");}body_6.__dustBody=!0;function body_7(chk,ctx){return chk.w("<div class=\"padding-left-15\"><a href=\"").f(ctx.getPath(false, ["data","beamlineUrl"]),ctx,"h").w("\" target=\"_blank\"> ").f(ctx.getPath(false, ["data","beamline"]),ctx,"h").w(" </a></div>");}body_7.__dustBody=!0;function body_8(chk,ctx){return chk.w("<div class=\"padding-left-15\">").f(ctx.getPath(false, ["data","beamline"]),ctx,"h").w("</div>");}body_8.__dustBody=!0;function body_9(chk,ctx){return chk.w("<div class=\"padding-left-15\"> Not available</div>");}body_9.__dustBody=!0;function body_10(chk,ctx){return chk.w("<div class=\"padding-left-15\">").f(ctx.getPath(false, ["data","sessionDate"]),ctx,"h").w("</div>");}body_10.__dustBody=!0;function body_11(chk,ctx){return chk.w("<div class=\"padding-left-15\"> Not available</div>");}body_11.__dustBody=!0;function body_12(chk,ctx){return chk.w("<div class=\"padding-left-15\">").f(ctx.getPath(false, ["data","proposalType"]),ctx,"h").w("</div>");}body_12.__dustBody=!0;function body_13(chk,ctx){return chk.w(" ").x(ctx.getPath(true, ["givenName"]),ctx,{"else":body_14,"block":body_15},{}).w(" ");}body_13.__dustBody=!0;function body_14(chk,ctx){return chk.w(" ").f(ctx.getPath(true, ["name"]),ctx,"h").w(" </br> ");}body_14.__dustBody=!0;function body_15(chk,ctx){return chk.w(" ").f(ctx.getPath(true, ["givenName"]),ctx,"h").w(" ").f(ctx.getPath(true, ["familyName"]),ctx,"h").w(" </br> ");}body_15.__dustBody=!0;return body_0}(dust));
(function(dust){dust.register("landingpage_tpl",body_0);function body_0(chk,ctx){return chk.w("<div class=\"container-fluid\"><br /><div class=\"row padding-top-15\"><div class=\"col-8\"><div class=\"row\"><div class=\"col-12 fontSize-20 text-center text-uppercase font-weight-bold\">").f(ctx.getPath(false, ["data","title"]),ctx,"h").w("</div></div><hr><div class=\"row\"><div class=\"col-4\"><div class=\"myBorder-left\"><label> Proposal </label>").x(ctx.getPath(false, ["data","proposalNumber"]),ctx,{"else":body_1,"block":body_2},{}).w("</div></div><div class=\"col-4\"><div class=\"myBorder-left\"><label> Publication year </label>").x(ctx.getPath(false, ["data","mintingYear"]),ctx,{"else":body_3,"block":body_4},{}).w("</div></div> <div class=\"col-4\"><div class=\"myBorder-left\"><label> Beamline </label> ").x(ctx.getPath(false, ["data","beamline"]),ctx,{"else":body_5,"block":body_6},{}).w("</div></div></div><div class=\"padding-top-15\"></div><div class=\"row\"><div class=\"col-4\"><div class=\"myBorder-left\"><label> Session date </label>").x(ctx.getPath(false, ["data","sessionDate"]),ctx,{"else":body_9,"block":body_10},{}).w("</div></div> <div class=\"col-4\"><div class=\"myBorder-left\"><label>Category </label>").x(ctx.getPath(false, ["data","proposalType"]),ctx,{"else":body_11,"block":body_12},{}).w("</div></div> <div class=\"col-4\"> <div class=\"myBorder-left\"><label>Publisher </label> <div class=\"padding-left-15\"><a href=\"http://www.esrf.fr\"> ").f(ctx.getPath(false, ["data","publisher"]),ctx,"h").w(" </a> </div></div></div> </div><hr><div class=\"row\"><div class=\"col-12\"><div class=\"myBorder-left\"><label> Abstract </label><div class=\"padding-left-15\">There is no abstract for this session.</div></div> </div></div><hr><div class=\"row\"><div class=\"col-12\"><div class=\"card-deck\"><div class=\"card\" id=\"expReport\"><div class=\"card-header text-center\"><label>Experimental report </label></div></div><div class=\"card\"><div class=\"card-header text-center\"><label>Experimental data </label></div><div class=\"card-body padding10\"><p class=\"card-text\" >").f(ctx.getPath(false, ["data","accessMessage"]),ctx,"h",["s"]).w("</p></div><div class=\"card-footer\"><form action=\"https://icat.esrf.fr/#/browse/facility/ESRF/proposal/").f(ctx.getPath(false, ["data","proposalNumber"]),ctx,"h").w("/investigation/").f(ctx.getPath(false, ["data","investigationId"]),ctx,"h").w("/dataset\" target=\"_blank\"><button type=\"submit\" class=\"btn btn-primary btn-lg btn-block\"> Access data </button></form></div></div></div></div></div><hr><div class=\"row\"><div class=\"col-12\"><div class=\"myBorder-left\"><label> Citation </label><div class=\"padding-left-15\"><p> Below is the recommended format for citing this work in a research publication.</p><div class=\"padding-left-15\"><cite> ").f(ctx.getPath(false, ["data","citation"]),ctx,"h",["s"]).w(" </cite></div></div></div> </div></div> </div><div class=\"col-4\"><div id=\"badge\" class=\"row\"> </div> <br><div class=\"row\"><div class=\"col-12\"><div class=\"card\"><div class=\"card-header text-center\"><label>Authors </label></div><div class=\"card-body text-center\">").s(ctx.getPath(false, ["data","creator"]),ctx,{"block":body_13},{}).w("</div></div></div></div></div></div> </div>");}body_0.__dustBody=!0;function body_1(chk,ctx){return chk.w("<div class=\"padding-left-15\"> Not available</div>");}body_1.__dustBody=!0;function body_2(chk,ctx){return chk.w("<div class=\"padding-left-15\">").f(ctx.getPath(false, ["data","proposalNumber"]),ctx,"h").w("</div>");}body_2.__dustBody=!0;function body_3(chk,ctx){return chk.w("<div class=\"padding-left-15\"> Not available</div>");}body_3.__dustBody=!0;function body_4(chk,ctx){return chk.w("<div class=\"padding-left-15\">").f(ctx.getPath(false, ["data","mintingYear"]),ctx,"h").w("</div>");}body_4.__dustBody=!0;function body_5(chk,ctx){return chk.w("<div class=\"padding-left-15\">Not available</div>");}body_5.__dustBody=!0;function body_6(chk,ctx){return chk.h("eq",ctx,{"else":body_7,"block":body_8},{"key":ctx.getPath(false, ["data","beamlineUrl"]),"value":"noLink"},"h");}body_6.__dustBody=!0;function body_7(chk,ctx){return chk.w("<div class=\"padding-left-15\"><a href=\"").f(ctx.getPath(false, ["data","beamlineUrl"]),ctx,"h").w("\" target=\"_blank\"> ").f(ctx.getPath(false, ["data","beamline"]),ctx,"h").w(" </a></div>");}body_7.__dustBody=!0;function body_8(chk,ctx){return chk.w("<div class=\"padding-left-15\">").f(ctx.getPath(false, ["data","beamline"]),ctx,"h").w("</div>");}body_8.__dustBody=!0;function body_9(chk,ctx){return chk.w("<div class=\"padding-left-15\"> Not available</div>");}body_9.__dustBody=!0;function body_10(chk,ctx){return chk.w("<div class=\"padding-left-15\">").f(ctx.getPath(false, ["data","sessionDate"]),ctx,"h").w("</div>");}body_10.__dustBody=!0;function body_11(chk,ctx){return chk.w("<div class=\"padding-left-15\"> Not available</div>");}body_11.__dustBody=!0;function body_12(chk,ctx){return chk.w("<div class=\"padding-left-15\">").f(ctx.getPath(false, ["data","proposalType"]),ctx,"h").w("</div>");}body_12.__dustBody=!0;function body_13(chk,ctx){return chk.w(" ").x(ctx.getPath(true, ["givenName"]),ctx,{"else":body_14,"block":body_15},{}).w(" ");}body_13.__dustBody=!0;function body_14(chk,ctx){return chk.w(" ").f(ctx.getPath(true, ["name"]),ctx,"h").w(" </br> ");}body_14.__dustBody=!0;function body_15(chk,ctx){return chk.w(" ").f(ctx.getPath(true, ["givenName"]),ctx,"h").w(" ").f(ctx.getPath(true, ["familyName"]),ctx,"h").w(" </br> ");}body_15.__dustBody=!0;return body_0}(dust));
(function(dust){dust.register("welcome_tpl",body_0);function body_0(chk,ctx){return chk.w(" <div class=\"container-fluid\"><div class=\"row\"><div class=\"col-12 flexCentered whiteFont\" style=\"color:#132577; font-size: 4rem; height: 200px; margin-top: 10px; margin-bottom: 10px;\">ESRF Data Portal</div></div></div><div class=\"container-fluid\"><div class=\"row\"><div class=\"col-12 col-md-4\"><div class=\"padding10\"><div class=\"card-header text-center\"><h2>About the portal</h2></div><div class=\"card-body padding10\">This page centralizes the services offered by the ESRF to access data stored at the facility as part of its data policy.<ul><li>DOI search engine</li><li>Data catalogue <a href=\"https://icat.esrf.fr\" target=\"_blank\"> icat.esrf.fr</a></li></ul></div></div></div><div class=\"col-12 col-md-4\"><div class=\"padding10\"><div class=\"card-header text-center \"><h2>DOI resolver</h2></div><div class=\"card-body padding10\"><p>The search engine below only finds DOI which have been minted at ESRF. </br> Use <a href=\"https://doi.org\">doi.org </a> search engine for any other DOI.</p><div class=\"row\"><div class=\"col-xl-9 padding-right-0\"><p> <input id=\"doiSearchBox\" class=\"form-control\" placeholder=\"10.15151/ESRF-ES-90632078\" type=\"text\" required/> </p><div class=\"text-danger\" id=\"error\"> </div> </div><div class=\"col padding-left-0\"> <input class=\"btn btn-primary\" type=\"submit\" value=\"Search\" onclick=\"searchDOI()\" /> </div></div><div class=\"row\"><div class=\"col\"><p> <a href=\"https://search.datacite.org/works?query=10.15151\"> Advanced search </a> </p></div></div></div> </div></div><div class=\"col-12 col-md-4\"><div class=\"padding10\"><div class=\"card-header text-center\"><h2>About DOI</h2></div><div class=\"card-body padding10\">The Digital Object Identifier (<a href=\"https://www.doi.org/\">DOI</a>) is a code composed of digits and characters. It identifies data in aunique and perennial way thus referencing this data worldwide. The DOI has two parts namely the DOI prefixand the DOI suffix separated by a slash (\"/\") as depicted below :</p><pre>prefix/suffix </pre></div></div></div></div></div>");}body_0.__dustBody=!0;return body_0}(dust));
\ No newline at end of file
......@@ -57,32 +57,35 @@ DOIController.prototype.getData = function(doi) {
}
})
.done(function(doiData) {
if (doiData) {
.done(function(data) {
if (data) {
// Test abnormal length of the json object
if (!_this.isValidDOIData(doiData)) {
if (!_this.isValidDOIData(data)) {
_this.view.renderError("Not Found", _this.origin);
} else {
var doiData = {};
doiData.title = data.title;
doiData.publisher = data.publisher;
doiData.creator = data.creator;
var jsonExtractor = new JsonExtractor();
doiData.mintingYear = jsonExtractor.getMintingYear(doiData);
doiData.sessionDate = jsonExtractor.getSessionDate(doiData);
doiData.mintingYear = jsonExtractor.getMintingYear(data);
doiData.sessionDate = jsonExtractor.getSessionDate(data);
doiData.proposalType = jsonExtractor.getFieldFromSubject(doiData.subject, "Proposal Type Description");
doiData.proposalNumber = jsonExtractor.getFieldFromSubject(doiData.subject, "Proposal");
doiData.proposalType = jsonExtractor.getFieldFromSubject(data.subject, "Proposal Type Description");
doiData.proposalNumber = jsonExtractor.getFieldFromSubject(data.subject, "Proposal");
_this.experimentalReportController.requestFilenameList(doiData.proposalNumber);
doiData.beamline = jsonExtractor.getFieldFromSubject(doiData.subject, "instrument");
doiData.beamline = jsonExtractor.getFieldFromSubject(data.subject, "instrument");
jsonExtractor.extractInvestigationId(doiData);
_this.view.setDataAccessMessage(doiData);
_this.createCitation(doiData);
doiData.investigationId = jsonExtractor.extractInvestigationId(data);
doiData.accessMessage = _this.view.setDataAccessMessage(data);
doiData.citation = _this.createCitation(data);
// Set the URL corresponding to the beamline name.
if (doiData.date_collected) {
var experimentalDate = moment(doiData.date_collected);
if (data.date_collected) {
var experimentalDate = moment(data.date_collected);
doiData.beamlineUrl = _this.getBeamlineUrl(doiData.beamline, experimentalDate);
} else {
doiData.beamlineUrl = "noLink";
......@@ -170,6 +173,8 @@ DOIController.prototype.getBeamlineUrl = function(beamline, date) {
*
* @param {string}
* data: the data object, it is a reference
* @return {string}
* citation : the citation to be displayed
*/
DOIController.prototype.createCitation = function(data) {
// Authors sent in json can be in several format. The following call find
......@@ -177,16 +182,13 @@ DOIController.prototype.createCitation = function(data) {
var citation = new Citation(data);
if (!citation.isBuildable) {
data.citation = "The citation could not be generated.";
return "The citation could not be generated.";
} else {
var authorInCitation = citation.getAuthorsForCitation(data.creator);
var doiRegistrationYear = moment(data.date_registered).year();
var fullCitation = authorInCitation + ' (' + doiRegistrationYear + '). ' + data.title + '. ' + data.publisher + ' (ESRF). ' +
" <a href='https://doi.esrf.fr/" + data.doi + "'> doi:" + data.doi.toUpperCase() + "</a>";
data.citation = fullCitation;
return fullCitation;
}
};
......@@ -32,7 +32,7 @@ DOIView.prototype.setDOI = function( doiCode ) {
};
/**
* Set the doi http link in the doi landing page. It is the http adress at datacite server which will redirect to the DOI landing page.
* Set the doi http link in the doi landing page. It is the http address at datacite server which will redirect to the DOI landing page.
*
*/
DOIView.prototype.setDOILink = function( doiLink ) {
......@@ -40,7 +40,7 @@ DOIView.prototype.setDOILink = function( doiLink ) {
};
/**
* Render experimental Report data *
* Render experimental Report data
*
* @param {array}
* data The filename list to be displayed
......@@ -70,9 +70,10 @@ DOIView.prototype.renderDOIData = function( doiData, target ) {
}, function( err, out ) {
$( '#' + _this.mainPanelId ).html( out );
_this.isDOIAlreadyRendered = true;
/**
* If there are experimental reports already retrieved then reder them after
* the rendering of the DOI *
* If there are experimental reports already retrieved then render them after
* the rendering of the DOI
*/
if ( _this.failedRecievingExpReport ) {
_this.renderErrorForExperimentalReport();
......@@ -135,19 +136,21 @@ DOIView.prototype.renderErrorForExperimentalReport = function() {
};
/**
* Set the message which is displayed just above the "Access data button"
* Set the message which is displayed just above the "Access data button" in experimental data box.
*
* @param {object}
* data The json object reference.
* @return {string}
* the message to display
*/
DOIView.prototype.setDataAccessMessage = function( data ) {
var publicationDate = moment( data.publication_year, "YYYY" );
var now = moment();
if ( now > publicationDate ) {
data.accessMessage = "The data can be accessed by clicking on the link below";
return "The data can be accessed by clicking on the link below";
} else {
data.accessMessage = "The data is under embargo until <b>" + data.publication_year + "</b> but could be released earlier. </p> " +
return "The data is under embargo until <b>" + data.publication_year + "</b> but could be released earlier. </p> " +
" <p> Currently, it is only accessible to proposal team members. </p>";
}
......
function JsonExtractor(json) {
function JsonExtractor( json ) {
}
/**
* Extract investigationId from the data.doi field as received from the json
* response. Add the corresponding fields in the data object
* response.
*
* @param {string}
* data The data object reference which is sent to the dustjs
* template
* @return {string}
* investigationId The investigationID requested for accessing data in ICAT.
*/
JsonExtractor.prototype.extractInvestigationId = function(data) {
var regExp = RegExp(/\/\w*-*[Ee][Ss][Rr][Ff]-[Ee][Ss]-(\d+)$/);
data.investigationId = regExp.exec(data.doi)[1];
JsonExtractor.prototype.extractInvestigationId = function( data ) {
var regExp = RegExp( /\/\w*-*[Ee][Ss][Rr][Ff]-[Ee][Ss]-(\d+)$/ );
return regExp.exec( data.doi )[1];
};
/**
* Extract field value (beamline, proposal number and proposal type) from the
* data json object. Returns nullif the field is not found.
* data json object. Returns null if the field is not found.
*
* @param {array}
* subject The array containing objects of interest template
* @param {string}
* field The text field which is searched
*/
JsonExtractor.prototype.getFieldFromSubject = function(subject, field) {
if (subject) {
if (subject[0]) {
for (var i = 0; i < subject[0].length; i++) {
if (subject[0][i].subject_scheme === field) {
return subject[0][i].text;
JsonExtractor.prototype.getFieldFromSubject = function( subject, field ) {
if ( subject ) {
if ( subject[0] ) {
for ( var i = 0; i < subject[0].length; i++ ) {
if ( subject[0][i].subject_scheme === field ) {
return subject[0][i].text;
}
}
}
}
}
}
return null;
return null;
};
/**
......@@ -44,13 +46,13 @@ JsonExtractor.prototype.getFieldFromSubject = function(subject, field) {
* template
* @return {string} The minting year. Null if it does not exist.
*/
JsonExtractor.prototype.getMintingYear = function(data) {
if (data) {
if (data.date_registered && data.date_registered != null) {
return moment(data.date_registered).year();
JsonExtractor.prototype.getMintingYear = function( data ) {
if ( data ) {
if ( data.date_registered && data.date_registered != null ) {
return moment( data.date_registered ).year();
}
}
}
return null;
return null;
};
/**
......@@ -62,11 +64,11 @@ JsonExtractor.prototype.getMintingYear = function(data) {
* @return {string} The formatted (YYY-M-D) session date. Null if it does not
* exist.
*/
JsonExtractor.prototype.getSessionDate = function(data) {
if (data) {
if (data.date_collected && data.date_collected != null) {
return moment(data.date_collected).format('YYYY-M-D');
JsonExtractor.prototype.getSessionDate = function( data ) {
if ( data ) {
if ( data.date_collected && data.date_collected != null ) {
return moment( data.date_collected ).format( 'YYYY-M-D' );
}
}
}
return null;
return null;
};
<div class="col-12">
<div>
<span class="badge badge-success" style="font-size:14px;"> open Access </span>
</div>
</div>
\ No newline at end of file
......@@ -135,6 +135,10 @@
</div>
<div class="col-4">
<div id="badge" class="row"> </div>
<br>
<div class="row">
<div class="col-12">
<div class="card">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment