Sha256: ddabf6e002f17cbe8f3a6c7e0844c754ab4e1115b04e56d8e73e73b6670a4efa

Contents?: true

Size: 800 Bytes

Versions: 1

Compression:

Stored size: 800 Bytes

Contents

// In this file, you can tune how data is displayed,
// For instance create links

// Utilities
var httpRegexp = new RegExp('^http[s]?://[^ ]+$');

function url_decorator(key, value) {
  var e = document.createElement('a');
  e.setAttribute('href', value);
  e.appendChild(document.createTextNode(value));
  return e;
}

/**
 * serviceInstanceDecorator is called to decorate an instance.
 */
function serviceInstanceDecorator(instance, element) {
    return element;
}

/**
 * serviceMetaDecorator must return a HTML node to decorate a service instance meta.
 * It should return the decorated element.
 */
function serviceMetaDecorator(instance, key, value) {
    if (httpRegexp.test(value)) {
      return url_decorator(key, value);
    } else {
      return document.createTextNode(value);
    }
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
consul-templaterb-1.21.2 samples/consul-ui/decorators.js.erb