I need to modify the constructor of the nodes. Unfortunately, I found 4 different definitions for registerType (which registers the node constructors). I was wondering if somebody can clarify the functionality of each of them? Thanks
For example, for email node, I found the following 4 codes:
1) In email.js:
RED.nodes.registerType("e-mail",EmailNode,{
credentials: {
userid: {type:"text"},
password: {type: "password"},
global: { type:"boolean"}
}
});
2) In email.html
RED.nodes.registerType('e-mail in',{
category: 'social-input',
color:"#c7e9c0",
defaults: {
repeat: {value:"300",required:true},
server: {value:"
imap.gmail.com",required:true},
port: {value:"993",required:true},
name: {value:""}
},
credentials: {
userid: {type:"text"},
password: {type: "password"},
global: { type:"boolean"}
},
inputs:0,
outputs:1,
icon: "envelope.png",
label: function() {
return
this.name||"email";
},
labelStyle: function() {
return (
this.name||!this.topic)?"node_label_italic":"";
},
oneditprepare: function() {
if (this.credentials.global) {
$('#node-tip').show();
} else {
$('#node-tip').hide();
};
}
});
3) In register.js:
registerType: registry.registerNodeConstructor,
registerNodeConstructor: function(type,constructor) {
if (nodeConstructors[type]) {
throw new Error(type+" already registered");
}
//TODO: Ensure type is known - but doing so will break some tests
// that don't have a way to register a node template ahead
// of registering the constructor
util.inherits(constructor,Node);
nodeConstructors[type] = constructor;
events.emit("type-registered",type);
}
4) In index.js
// Node type registry
registerType: registerType,
function registerType(type,constructor,opts) {
if (opts && opts.credentials) {
credentials.register(type,opts.credentials);
}
registry.registerType(type,constructor);
}