Sha256: c02045f48f83609577323c2592cd646e7c9c76f465cc3243798434dcc0a87473

Contents?: true

Size: 916 Bytes

Versions: 4

Compression:

Stored size: 916 Bytes

Contents

(function($) {

  "use strict";

  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;
    });

    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() {
    $("a.unlabeled").each(processNode);

    // initialise new dynamically added links
    $(document.body).on("concept-label", function(ev, container) {
      $("a.unlabeled", container).each(processNode);
    });
  });

}(jQuery));

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
iqvoc-4.14.5 app/assets/javascripts/iqvoc/label_resolver.js
iqvoc-4.14.4 app/assets/javascripts/iqvoc/label_resolver.js
iqvoc-4.13.2 app/assets/javascripts/iqvoc/label_resolver.js
iqvoc-4.13.0 app/assets/javascripts/iqvoc/label_resolver.js