File: operation-icons.js

package info (click to toggle)
openrefine 3.9.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 44,440 kB
  • sloc: javascript: 106,758; java: 91,946; xml: 6,634; sh: 614; makefile: 78; python: 71; sql: 59
file content (20 lines) | stat: -rw-r--r-- 531 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

var OperationIconRegistry = {
  map: new Map()
};

OperationIconRegistry.setIcon = function(operationId, iconPath) {
  if (!iconPath.endsWith(".svg")) {
    throw new Error('Operation icon must be a path to a SVG file.');
  }
  // this will cause the image to load so that once it is added to the DOM it will already be in the browser cache
  var image = new Image();
  image.src = iconPath;

  this.map.set(operationId, iconPath);
}

OperationIconRegistry.getIcon = function(operationId) {
  return this.map.get(operationId);
}