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

Change parseXML node to no longer have special debug options

(as can now be done in the debug node... so more consistent)
This commit is contained in:
Dave C-J 2014-04-08 16:06:46 +01:00
parent e38b321c33
commit a08789a086
2 changed files with 9 additions and 15 deletions

View File

@ -15,16 +15,16 @@
-->
<script type="text/x-red" data-template-name="xml2js">
<div class="form-row">
<!-- <div class="form-row">
<label>Use Console</label>
<input type="checkbox" id="node-input-useEyes" placeholder="Name" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-useEyes" style="width: 70%;">Debug output in console ?</label>
</div>
</div> -->
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-tips">Uses xml2js to process xml into javascript object.</div>
<!-- <div class="form-tips">Uses xml2js to process xml into javascript object.</div> -->
</script>
<script type="text/x-red" data-help-name="xml2js">
@ -37,8 +37,8 @@
category: 'advanced-function',
color:"#E6E0F8",
defaults: {
useEyes: {value:false},
name: {value:""},
//useEyes: {value:false},
name: {value:""}
},
inputs:1,
outputs:1,

View File

@ -17,17 +17,12 @@
var RED = require(process.env.NODE_RED_HOME+"/red/red");
var util = require("util");
var parseString = require('xml2js').parseString;
var gotEyes = false;
try {
var eyes = require("eyes");
gotEyes = true;
} catch(e) {
util.log("[73-parsexml.js] Note: Module 'eyes' not installed. (not needed, but useful)");
}
var useColors = true;
util.inspect.styles.boolean = "red";
function Xml2jsNode(n) {
RED.nodes.createNode(this,n);
this.useEyes = n.useEyes;
this.useEyes = n.useEyes||false;
var node = this;
this.on("input", function(msg) {
try {
@ -38,8 +33,7 @@ function Xml2jsNode(n) {
msg.payload = result;
node.send(msg);
if (node.useEyes == true) {
if (gotEyes == true) { eyes.inspect(msg); }
else { node.log(JSON.stringify(msg)); }
node.log("\n"+util.inspect(msg, {colors:useColors, depth:10}));
}
}
});