1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

refactor node.libs to a function getLibsList

- preparation for monaco integration
This commit is contained in:
Steve-Mcl 2021-04-29 16:56:16 +01:00
parent 1f7884dc70
commit 5bba50f01f

View File

@ -313,6 +313,30 @@
} }
function getLibsList() {
var _libs = [];
if (RED.settings.functionExternalModules === true) {
var libs = $("#node-input-libs-container").editableList("items");
libs.each(function(i) {
var item = $(this);
var v = item.find(".node-input-libs-var").val();
var n = item.find(".node-input-libs-val").typedInput("type");
if (n === "_custom_") {
n = item.find(".node-input-libs-val").val();
}
if ((!v || (v === "")) ||
(!n || (n === ""))) {
return;
}
_libs.push({
var: v,
module: n
});
});
}
return _libs;
}
RED.nodes.registerType('function',{ RED.nodes.registerType('function',{
color:"#fdd0a2", color:"#fdd0a2",
category: 'function', category: 'function',
@ -523,28 +547,7 @@
$("#node-input-noerr").val(noerr); $("#node-input-noerr").val(noerr);
this.noerr = noerr; this.noerr = noerr;
if (RED.settings.functionExternalModules === true) { node.libs = getLibsList();
var libs = $("#node-input-libs-container").editableList("items");
node.libs = [];
libs.each(function(i) {
var item = $(this);
var v = item.find(".node-input-libs-var").val();
var n = item.find(".node-input-libs-val").typedInput("type");
if (n === "_custom_") {
n = item.find(".node-input-libs-val").val();
}
if ((!v || (v === "")) ||
(!n || (n === ""))) {
return;
}
node.libs.push({
var: v,
module: n
});
});
} else {
node.libs = [];
}
}, },
oneditcancel: function() { oneditcancel: function() {
var node = this; var node = this;