mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add RED.utils.getNodeLabel utility function
This commit is contained in:
@@ -27,19 +27,11 @@ RED.search = (function() {
|
||||
var results = [];
|
||||
|
||||
function indexNode(n) {
|
||||
var l = "";
|
||||
if (n._def && n._def.label) {
|
||||
l = n._def.label;
|
||||
try {
|
||||
l = (typeof l === "function" ? l.call(n) : l);
|
||||
if (l) {
|
||||
l = (""+l).toLowerCase();
|
||||
index[l] = index[l] || {};
|
||||
index[l][n.id] = {node:n,label:l}
|
||||
}
|
||||
} catch(err) {
|
||||
console.log("Definition error: "+n.type+".label",err);
|
||||
}
|
||||
var l = RED.utils.getNodeLabel(n);
|
||||
if (l) {
|
||||
l = (""+l).toLowerCase();
|
||||
index[l] = index[l] || {};
|
||||
index[l][n.id] = {node:n,label:l}
|
||||
}
|
||||
l = l||n.label||n.name||n.id||"";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user