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

Tidy up jsHinst errors in parser nodes

This commit is contained in:
Dave C-J 2014-06-30 20:44:01 +01:00
parent 790ad8eb68
commit 52779ac518
2 changed files with 14 additions and 13 deletions

View File

@ -27,20 +27,20 @@ module.exports = function(RED) {
if (msg.hasOwnProperty("payload")) {
if (typeof msg.payload == "object") { // convert to csv
try {
var o = "";
for (var i in node.template) {
if (msg.payload.hasOwnProperty(node.template[i])) {
if (msg.payload[node.template[i]].indexOf(node.sep) != -1) {
o += node.quo + msg.payload[node.template[i]] + node.quo + node.sep;
var ou = "";
for (var t in node.template) {
if (msg.payload.hasOwnProperty(node.template[t])) {
if (msg.payload[node.template[t]].indexOf(node.sep) != -1) {
ou += node.quo + msg.payload[node.template[t]] + node.quo + node.sep;
}
else if (msg.payload[node.template[i]].indexOf(node.quo) != -1) {
msg.payload[node.template[i]] = msg.payload[node.template[i]].replace(/"/g, '""');
o += node.quo + msg.payload[node.template[i]] + node.quo + node.sep;
else if (msg.payload[node.template[t]].indexOf(node.quo) != -1) {
msg.payload[node.template[t]] = msg.payload[node.template[t]].replace(/"/g, '""');
ou += node.quo + msg.payload[node.template[t]] + node.quo + node.sep;
}
else { o += msg.payload[node.template[i]] + node.sep; }
else { ou += msg.payload[node.template[t]] + node.sep; }
}
}
msg.payload = o.slice(0,-1);
msg.payload = ou.slice(0,-1);
node.send(msg);
}
catch(e) { node.log(e); }
@ -57,7 +57,7 @@ module.exports = function(RED) {
if (msg.payload[i-1] === node.quo) { k[j] += '\"'; }
}
else if ((msg.payload[i] === node.sep) && f) {
if ( node.template[j] && (node.template[j] != "") ) { o[node.template[j]] = k[j]; }
if ( node.template[j] && (node.template[j] !== "") ) { o[node.template[j]] = k[j]; }
j += 1;
k[j] = "";
}
@ -65,7 +65,7 @@ module.exports = function(RED) {
k[j] += msg.payload[i];
}
}
if ( node.template[j] && (node.template[j] != "") ) { o[node.template[j]] = k[j]; }
if ( node.template[j] && (node.template[j] !== "") ) { o[node.template[j]] = k[j]; }
msg.payload = o;
node.send(msg);
}

View File

@ -15,6 +15,7 @@
**/
module.exports = function(RED) {
"use strict";
var cheerio = require('cheerio');
function CheerioNode(n) {
@ -46,7 +47,7 @@ module.exports = function(RED) {
//if (node.ret === "val") { pay.push( $(this).val() ); }
}
});
if ((node.as === "single") && (pay.length != 0)) {
if ((node.as === "single") && (pay.length !== 0)) {
msg.payload = pay;
node.send(msg);
}