mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
update initialize & finalize processing of function node
This commit is contained in:
@@ -50,18 +50,6 @@ RED.library = (function() {
|
||||
'</form>'+
|
||||
'</div>'
|
||||
|
||||
function toSingleLine(text) {
|
||||
var result = text.replace(/\\/g, "\\\\").replace(/\n/g, "\\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
function fromSingleLine(text) {
|
||||
var result = text.replace(/\\[\\n]/g, function(s) {
|
||||
return ((s === "\\\\") ? "\\" : "\n");
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
function saveToLibrary() {
|
||||
var elementPrefix = activeLibrary.elementPrefix || "node-input-";
|
||||
var name = $("#"+elementPrefix+"name").val().trim();
|
||||
@@ -80,10 +68,8 @@ RED.library = (function() {
|
||||
var field = activeLibrary.fields[i];
|
||||
if (field == "name") {
|
||||
data.name = name;
|
||||
} else if(field == "initialize") {
|
||||
data.initialize = toSingleLine(activeLibrary.initEditor.getValue());
|
||||
} else if(field == "finalize") {
|
||||
data.finalize = toSingleLine(activeLibrary.finalizeEditor.getValue());
|
||||
} else if (typeof(field) === 'object') {
|
||||
data[field.name] = field.get();
|
||||
} else {
|
||||
data[field] = $("#"+elementPrefix+field).val();
|
||||
}
|
||||
@@ -539,13 +525,9 @@ RED.library = (function() {
|
||||
var elementPrefix = activeLibrary.elementPrefix || "node-input-";
|
||||
for (var i=0; i<activeLibrary.fields.length; i++) {
|
||||
var field = activeLibrary.fields[i];
|
||||
if (field === "initialize") {
|
||||
var text = fromSingleLine(selectedLibraryItem.initialize);
|
||||
activeLibrary.initEditor.setValue(text, -1);
|
||||
}
|
||||
else if (field === "finalize") {
|
||||
var text = fromSingleLine(selectedLibraryItem.finalize);
|
||||
activeLibrary.finalizeEditor.setValue(text, -1);
|
||||
if (typeof(field) === 'object') {
|
||||
var val = selectedLibraryItem[field.name];
|
||||
field.set(val);
|
||||
}
|
||||
else {
|
||||
$("#"+elementPrefix+field).val(selectedLibraryItem[field]);
|
||||
|
Reference in New Issue
Block a user