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

View File

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