Skip to content

Commit

Permalink
Merge pull request #28 from gwendoux/main
Browse files Browse the repository at this point in the history
fix for issue :  Funder registry URI does not transform to Funder Name #27
  • Loading branch information
qqmyers authored Dec 17, 2024
2 parents dedda78 + f827efb commit b235428
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions examples/config/demos/grantNumberAgencyFundreg.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"protocol": "fundreg",
"retrieval-uri": "https://data.crossref.org/fundingdata/funder/{0}",
"allow-free-text": true,
"prefix": "http://dx.doi.org/10.13039/",
"prefix": "https://doi.org/10.13039/",
"managed-fields": {},
"languages":"",
"vocabs": {
"funders": {
"uriSpace": "http://dx.doi.org/10.13039/"
"uriSpace": "https://doi.org/10.13039/"
}
},
"retrieval-filtering": {
Expand Down
19 changes: 11 additions & 8 deletions scripts/fundreg.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ console.log("fundreg.js..");
var fundregSelector = "span[data-cvoc-protocol='fundreg']";
var fundregInputSelector = "input[data-cvoc-protocol='fundreg']";
var fundregRetrievalUrl = "https://api.crossref.org/funders";
var fundregIdStem = "https://doi.org/10.13039";
var fundregPrefix = "fundreg";
//Max chars that displays well for a child field
var fundregMaxLength = 30;
Expand All @@ -21,11 +22,11 @@ function expandFunders() {
// Mark it as processed
$(funderElement).addClass('expanded');
var id = funderElement.textContent;
if (!id.startsWith("http://dx.doi.org/10.13039/")) {
if (!id.startsWith(fundregIdStem)) {
$(funderElement).html(getFunderDisplayHtml(id, ['No Crossref Entry'], false));
} else {
//Remove the URL prefix - "http://dx.doi.org/10.13039/".length = 27
id = id.substring(27);
//Remove the URL prefix - "http://doi.org/10.13039/".length = 24
id = id.substring(24);
//Check for cached entry
let value = getValue(fundregPrefix, id);
if(value.name !=null) {
Expand Down Expand Up @@ -70,10 +71,12 @@ function expandFunders() {
function getFunderDisplayHtml(name, altNames, truncate=true) {
if (typeof(altNames) == 'undefined') {
altNames = [];
}
}
if (truncate && (name.length >= fundregMaxLength)) {
// show the first characters of a long name
altNames.unshift(name);
if(altNames!=false){
altNames.unshift(name);
}
name=name.substring(0,fundregMaxLength) + "…";
}
return $('<span></span>').append(name).attr("title", altNames);
Expand Down Expand Up @@ -181,8 +184,8 @@ function updateFunderInputs() {
// If the input has a value already, format it the same way as if it
// were a new selection
var id = $(funderInput).val();
if (id.startsWith("http://dx.doi.org/10.13039/")) {
id = id.substring(27);
if (id.startsWith(fundregIdStem)) {
id = id.substring(24);
//Check for cached entry
let value = getValue(fundregPrefix, id);
if(value.name !=null) {
Expand Down Expand Up @@ -247,4 +250,4 @@ function updateFunderInputs() {
});
}
});
}
}

0 comments on commit b235428

Please sign in to comment.