app/assets/javascripts/iqvoc/label_resolver.js in iqvoc-4.10.0 vs app/assets/javascripts/iqvoc/label_resolver.js in iqvoc-4.11.0
- old
+ new
@@ -7,33 +7,26 @@
};
function retrieveLabel(conceptURL, el, callback) {
var datasets = $("body").data("datasets");
var proxy = $("body").data("remote-label-path");
+ var matchedDatasets = Object.keys(datasets).filter(function(datasetURL) {
+ return conceptURL.indexOf(datasetURL, 0) === 0;
+ });
- var conceptBaseURL = getBaseURI(conceptURL);
-
- // try to get remote label if conceptBaseURL is a iqvoc instance
- if(conceptBaseURL in datasets) {
- $.get(proxy, { concept_url: conceptURL }, function(data, status, xhr) {
- el.text(data.label);
- el.removeClass("unlabeled");
- });
+ if (matchedDatasets.length === 0) {
+ return false;
}
+
+ $.get(proxy, { concept_url: conceptURL }, function(data, status, xhr) {
+ el.text(data.label);
+ el.removeClass("unlabeled");
+ });
}
function processNode(i, node) {
var el = $(node);
var uri = el.attr("href");
retrieveLabel(uri, el);
-}
-
-function getBaseURI(url) {
- var uri = new URI(url);
- var parts = {
- protocol: uri.protocol(),
- hostname: uri.host()
- };
- return URI.build(parts);
}
}(jQuery));