mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
A whole bunch of whitespace linting - no functional changes
This commit is contained in:
parent
8e2352b08a
commit
e20cf97fce
@ -21,7 +21,7 @@ module.exports = function(RED) {
|
|||||||
this.on("input",function(msg) {
|
this.on("input",function(msg) {
|
||||||
if (msg.hasOwnProperty("reset")) {
|
if (msg.hasOwnProperty("reset")) {
|
||||||
if (msg.hasOwnProperty("topic") && (typeof msg.topic === "string") && (msg.topic !== "")) {
|
if (msg.hasOwnProperty("topic") && (typeof msg.topic === "string") && (msg.topic !== "")) {
|
||||||
delete node.previous[msg.topic];
|
delete node.previous[msg.topic];
|
||||||
}
|
}
|
||||||
else { node.previous = {}; }
|
else { node.previous = {}; }
|
||||||
}
|
}
|
||||||
|
@ -179,8 +179,8 @@ module.exports = function(RED) {
|
|||||||
node.board.sysexCommand(msg.payload);
|
node.board.sysexCommand(msg.payload);
|
||||||
}
|
}
|
||||||
if (node.state === "STRING") {
|
if (node.state === "STRING") {
|
||||||
node.board.sendString(msg.payload.toString());
|
node.board.sendString(msg.payload.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
node.board.once('disconnect', function() {
|
node.board.once('disconnect', function() {
|
||||||
|
@ -92,7 +92,7 @@ module.exports = function(RED) {
|
|||||||
var val;
|
var val;
|
||||||
if (node.intype == "up") { val = 1; }
|
if (node.intype == "up") { val = 1; }
|
||||||
if (node.intype == "down") { val = 0; }
|
if (node.intype == "down") { val = 0; }
|
||||||
setTimeout(function(){
|
setTimeout(function() {
|
||||||
node.send({ topic:"pi/"+node.pin, payload:val });
|
node.send({ topic:"pi/"+node.pin, payload:val });
|
||||||
node.status({fill:"grey",shape:"dot",text:RED._("rpi-gpio.status.na",{value:val})});
|
node.status({fill:"grey",shape:"dot",text:RED._("rpi-gpio.status.na",{value:val})});
|
||||||
},250);
|
},250);
|
||||||
@ -194,7 +194,7 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
node.status({fill:"grey",shape:"dot",text:"node-red:rpi-gpio.status.not-available"});
|
node.status({fill:"grey",shape:"dot",text:"node-red:rpi-gpio.status.not-available"});
|
||||||
node.on("input", function(msg){
|
node.on("input", function(msg) {
|
||||||
node.status({fill:"grey",shape:"dot",text:RED._("rpi-gpio.status.na",{value:msg.payload.toString()})});
|
node.status({fill:"grey",shape:"dot",text:RED._("rpi-gpio.status.na",{value:msg.payload.toString()})});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -303,14 +303,14 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
node.on("close", function(done) {
|
node.on("close", function(done) {
|
||||||
node.status({});
|
node.status({});
|
||||||
if (node.child != null) {
|
if (node.child != null) {
|
||||||
node.finished = done;
|
node.finished = done;
|
||||||
node.child.kill('SIGINT');
|
node.child.kill('SIGINT');
|
||||||
node.child = null;
|
node.child = null;
|
||||||
}
|
}
|
||||||
else { done(); }
|
else { done(); }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
node.status({fill:"grey",shape:"dot",text:"node-red:rpi-gpio.status.not-available"});
|
node.status({fill:"grey",shape:"dot",text:"node-red:rpi-gpio.status.not-available"});
|
||||||
|
@ -90,7 +90,7 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
node.status({fill:"grey",shape:"dot",text:"node-red:rpi-gpio.status.not-available"});
|
node.status({fill:"grey",shape:"dot",text:"node-red:rpi-gpio.status.not-available"});
|
||||||
node.on("input", function(msg){
|
node.on("input", function(msg) {
|
||||||
node.status({fill:"grey",shape:"dot",text:RED._("node-red:rpi-gpio.status.na",{value:msg.payload.toString()})});
|
node.status({fill:"grey",shape:"dot",text:RED._("node-red:rpi-gpio.status.na",{value:msg.payload.toString()})});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -145,43 +145,6 @@ module.exports = function(RED) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//case "holiday" : {
|
|
||||||
//if (DEBUG) {
|
|
||||||
//hminnode.log("Hit the holiday case");
|
|
||||||
//}
|
|
||||||
//if (!('enabled' in message.payload[key]) && !('time' in message.payload[key])) {
|
|
||||||
//hminnode.log("Warning: Unsupported 'holiday' value passed!");
|
|
||||||
//eturn;
|
|
||||||
//}
|
|
||||||
//var time = message.payload[key].time;
|
|
||||||
//// Ensure hminnode time is a date
|
|
||||||
//if (typeof(time) == "string") {
|
|
||||||
//hminnode.log("Typeof time was " +typeof(message.payload[key].time));
|
|
||||||
//// message.payload[key].time = new Date(message.payload[key].time);
|
|
||||||
//message.payload[key].time = new Date(2014, 02, 15, 12, 0, 0);
|
|
||||||
//hminnode.log("Typeof time is now " +typeof(message.payload[key].time));
|
|
||||||
//}
|
|
||||||
//// Also add in away mode (for hot water) if we're on hols
|
|
||||||
//if (message.payload[key].time) {
|
|
||||||
//message.payload.away_mode = 1;
|
|
||||||
//}
|
|
||||||
//else {
|
|
||||||
//message.payload.away_mode = 0;
|
|
||||||
//}
|
|
||||||
//break;
|
|
||||||
// }
|
|
||||||
|
|
||||||
//case "hotwater" : {
|
|
||||||
//if (DEBUG) {
|
|
||||||
//hminnode.log("Hit the hotwater case");
|
|
||||||
//}
|
|
||||||
//if (message.payload[key] !== "on" && message.payload[key] !== "boost" && message.payload[key] !== "off") {
|
|
||||||
//hminnode.log("Warning: Unsupported 'hotwater' value passed!");
|
|
||||||
//return;
|
|
||||||
//}
|
|
||||||
//break;
|
|
||||||
// }
|
|
||||||
|
|
||||||
case "heating" : {
|
case "heating" : {
|
||||||
// Ensure heating stays last! It's got a multi write scenario
|
// Ensure heating stays last! It's got a multi write scenario
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
module.exports = function(RED) {
|
module.exports = function(RED) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
//import noble
|
//import noble
|
||||||
|
@ -44,10 +44,13 @@ module.exports = function(RED) {
|
|||||||
sensorTag.enableIrTemperature(function() {});
|
sensorTag.enableIrTemperature(function() {});
|
||||||
sensorTag.on('irTemperatureChange',
|
sensorTag.on('irTemperatureChange',
|
||||||
function(objectTemperature, ambientTemperature) {
|
function(objectTemperature, ambientTemperature) {
|
||||||
var msg = {'topic': node.topic + '/temperature'};
|
var msg = {
|
||||||
msg.payload = {'object': +objectTemperature.toFixed(1),
|
'topic': node.topic + '/temperature',
|
||||||
'ambient': +ambientTemperature.toFixed(1)
|
'payload': {
|
||||||
};
|
'object': +objectTemperature.toFixed(1),
|
||||||
|
'ambient': +ambientTemperature.toFixed(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
node.send(msg);
|
node.send(msg);
|
||||||
});
|
});
|
||||||
sensorTag.enableBarometricPressure(function() {});
|
sensorTag.enableBarometricPressure(function() {});
|
||||||
@ -59,8 +62,9 @@ module.exports = function(RED) {
|
|||||||
sensorTag.enableHumidity(function() {});
|
sensorTag.enableHumidity(function() {});
|
||||||
sensorTag.on('humidityChange', function(temp, humidity) {
|
sensorTag.on('humidityChange', function(temp, humidity) {
|
||||||
var msg = {'topic': node.topic + '/humidity'};
|
var msg = {'topic': node.topic + '/humidity'};
|
||||||
msg.payload = {'temperature': +temp.toFixed(1),
|
msg.payload = {
|
||||||
'humidity': +humidity.toFixed(1)
|
'temperature': +temp.toFixed(1),
|
||||||
|
'humidity': +humidity.toFixed(1)
|
||||||
};
|
};
|
||||||
if ((temp !== -40) || (humidity !== 100)) {
|
if ((temp !== -40) || (humidity !== 100)) {
|
||||||
node.send(msg);
|
node.send(msg);
|
||||||
|
@ -30,7 +30,7 @@ module.exports = function(RED) {
|
|||||||
this.on("input", function(msg) {
|
this.on("input", function(msg) {
|
||||||
|
|
||||||
// setup the data for the URI
|
// setup the data for the URI
|
||||||
if (this.datatype == "legacy"){
|
if (this.datatype == "legacy") {
|
||||||
this.url = this.baseurl + '/input/post.json?';
|
this.url = this.baseurl + '/input/post.json?';
|
||||||
if (typeof(msg.payload) !== "string") {
|
if (typeof(msg.payload) !== "string") {
|
||||||
this.url += 'json=' + JSON.stringify(msg.payload);
|
this.url += 'json=' + JSON.stringify(msg.payload);
|
||||||
@ -44,15 +44,15 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (this.datatype == "fulljson"){
|
else if (this.datatype == "fulljson") {
|
||||||
this.url = this.baseurl + '/input/post?';
|
this.url = this.baseurl + '/input/post?';
|
||||||
this.url += 'fulljson=' + encodeURIComponent(JSON.stringify(msg.payload));
|
this.url += 'fulljson=' + encodeURIComponent(JSON.stringify(msg.payload));
|
||||||
}
|
}
|
||||||
else if (this.datatype == "json"){
|
else if (this.datatype == "json") {
|
||||||
this.url = this.baseurl + '/input/post?';
|
this.url = this.baseurl + '/input/post?';
|
||||||
this.url += 'json={' + encodeURIComponent(msg.payload) + '}';
|
this.url += 'json={' + encodeURIComponent(msg.payload) + '}';
|
||||||
}
|
}
|
||||||
else if (this.datatype == "CSV"){
|
else if (this.datatype == "CSV") {
|
||||||
this.url = this.baseurl + '/input/post?';
|
this.url = this.baseurl + '/input/post?';
|
||||||
this.url += 'csv=' + msg.payload;
|
this.url += 'csv=' + msg.payload;
|
||||||
}
|
}
|
||||||
|
@ -174,16 +174,16 @@ module.exports = function(RED) {
|
|||||||
return {
|
return {
|
||||||
get:function(serialConfig) {
|
get:function(serialConfig) {
|
||||||
// make local copy of configuration -- perhaps not needed?
|
// make local copy of configuration -- perhaps not needed?
|
||||||
var port = serialConfig.serialport,
|
var port = serialConfig.serialport,
|
||||||
baud = serialConfig.serialbaud,
|
baud = serialConfig.serialbaud,
|
||||||
databits = serialConfig.databits,
|
databits = serialConfig.databits,
|
||||||
parity = serialConfig.parity,
|
parity = serialConfig.parity,
|
||||||
stopbits = serialConfig.stopbits,
|
stopbits = serialConfig.stopbits,
|
||||||
newline = serialConfig.newline,
|
newline = serialConfig.newline,
|
||||||
spliton = serialConfig.out,
|
spliton = serialConfig.out,
|
||||||
waitfor = serialConfig.waitfor,
|
waitfor = serialConfig.waitfor,
|
||||||
binoutput = serialConfig.bin,
|
binoutput = serialConfig.bin,
|
||||||
addchar = serialConfig.addchar,
|
addchar = serialConfig.addchar,
|
||||||
responsetimeout = serialConfig.responsetimeout;
|
responsetimeout = serialConfig.responsetimeout;
|
||||||
var id = port;
|
var id = port;
|
||||||
// just return the connection object if already have one
|
// just return the connection object if already have one
|
||||||
@ -320,6 +320,7 @@ module.exports = function(RED) {
|
|||||||
obj.serial.on('error', function(err) {
|
obj.serial.on('error', function(err) {
|
||||||
RED.log.error(RED._("serial.errors.error",{port:port,error:err.toString()}));
|
RED.log.error(RED._("serial.errors.error",{port:port,error:err.toString()}));
|
||||||
obj._emitter.emit('closed');
|
obj._emitter.emit('closed');
|
||||||
|
if (obj.tout) { clearTimeout(obj.tout); }
|
||||||
obj.tout = setTimeout(function() {
|
obj.tout = setTimeout(function() {
|
||||||
setupSerial();
|
setupSerial();
|
||||||
}, settings.serialReconnectTime);
|
}, settings.serialReconnectTime);
|
||||||
@ -328,6 +329,7 @@ module.exports = function(RED) {
|
|||||||
if (!obj._closing) {
|
if (!obj._closing) {
|
||||||
RED.log.error(RED._("serial.errors.unexpected-close",{port:port}));
|
RED.log.error(RED._("serial.errors.unexpected-close",{port:port}));
|
||||||
obj._emitter.emit('closed');
|
obj._emitter.emit('closed');
|
||||||
|
if (obj.tout) { clearTimeout(obj.tout); }
|
||||||
obj.tout = setTimeout(function() {
|
obj.tout = setTimeout(function() {
|
||||||
setupSerial();
|
setupSerial();
|
||||||
}, settings.serialReconnectTime);
|
}, settings.serialReconnectTime);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-serialport",
|
"name" : "node-red-node-serialport",
|
||||||
"version" : "0.8.3",
|
"version" : "0.8.4",
|
||||||
"description" : "Node-RED nodes to talk to serial ports",
|
"description" : "Node-RED nodes to talk to serial ports",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
"serialport" : "^7.1.5"
|
"serialport" : "^7.1.5"
|
||||||
|
@ -67,7 +67,6 @@ module.exports = function(RED) {
|
|||||||
node.log('subscribing to: '+node.topic);
|
node.log('subscribing to: '+node.topic);
|
||||||
node.client.subscribe(node.topic, function(body, headers) {
|
node.client.subscribe(node.topic, function(body, headers) {
|
||||||
var newmsg={"headers":headers,"topic":node.topic}
|
var newmsg={"headers":headers,"topic":node.topic}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
newmsg.payload = JSON.parse(body);
|
newmsg.payload = JSON.parse(body);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ module.exports = function(RED) {
|
|||||||
var value = RED.util.getMessageProperty(msg,node.property);
|
var value = RED.util.getMessageProperty(msg,node.property);
|
||||||
if (value !== undefined) {
|
if (value !== undefined) {
|
||||||
if (typeof value === "string") {
|
if (typeof value === "string") {
|
||||||
// try to decode it...
|
// try to decode it...
|
||||||
var regexp = new RegExp('^[a-z0-9]{1,9}$'); // can only contain a-z or 0-9 and length 1-9
|
var regexp = new RegExp('^[a-z0-9]{1,9}$'); // can only contain a-z or 0-9 and length 1-9
|
||||||
if (regexp.test(value)) {
|
if (regexp.test(value)) {
|
||||||
var po = geohash.decode(value);
|
var po = geohash.decode(value);
|
||||||
|
@ -4,14 +4,19 @@
|
|||||||
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
// Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
// Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
// * Neither the name of Smaz nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
// Neither the name of Smaz nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||||
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
// Our compression codebook
|
// Our compression codebook
|
||||||
var rc = [
|
var rc = [
|
||||||
" ", "the", "e", "t", "a", "of", "o", "and", "i", "n", "s", "e ", "r", " th", " t", "in", "he", "th", "h", "he ", "to", "\r\n", "l", "s ", "d", " a", "an","er", "c", " o", "d ", "on", " of", "re", "of ", "t ", ", ", "is", "u", "at", " ", "n ", "or", "which", "f", "m", "as", "it", "that", "\n", "was", "en", " ", " w", "es", " an", " i", "\r", "f ", "g", "p", "nd", " s", "nd ", "ed ", "w", "ed", "http://", "for", "te", "ing", "y ", "The", " c", "ti", "r ", "his", "st", " in", "ar", "nt", ",", " to", "y", "ng", " h", "with", "le", "al", "to ", "b", "ou", "be", "were", " b", "se", "o ", "ent", "ha", "ng ", "their", "\"", "hi", "from", " f", "in ", "de", "ion", "me", "v", ".", "ve", "all", "re ", "ri", "ro", "is ", "co", "f t", "are", "ea", ". ", "her", " m", "er ", " p", "es ", "by", "they", "di", "ra", "ic", "not", "s, ", "d t", "at ", "ce", "la", "h ", "ne", "as ", "tio", "on ", "n t", "io", "we", " a ", "om", ", a", "s o", "ur", "li", "ll", "ch", "had", "this", "e t", "g ", "e\r\n", " wh", "ere", " co", "e o", "a ", "us", " d", "ss", "\n\r\n", "\r\n\r", "=\"", " be", " e", "s a", "ma", "one", "t t", "or ", "but", "el", "so", "l ", "e s", "s,", "no", "ter", " wa", "iv", "ho", "e a", " r", "hat", "s t", "ns", "ch ", "wh", "tr", "ut", "/", "have", "ly ", "ta", " ha", " on", "tha", "-", " l", "ati", "en ", "pe", " re", "there", "ass", "si", " fo", "wa", "ec", "our", "who", "its", "z", "fo", "rs", ">", "ot", "un", "<", "im", "th ", "nc", "ate", "><", "ver", "ad", " we", "ly", "ee", " n", "id", " cl", "ac", "il", "</", "rt", " wi", "div", "e, ", " it", "whi", " ma", "ge", "x", "�", "\'>", "=\'"];
|
" ", "the", "e", "t", "a", "of", "o", "and", "i", "n", "s", "e ", "r", " th", " t", "in", "he", "th", "h", "he ", "to", "\r\n", "l", "s ", "d", " a", "an","er", "c", " o", "d ", "on", " of", "re", "of ", "t ", ", ", "is", "u", "at", " ", "n ", "or", "which", "f", "m", "as", "it", "that", "\n", "was", "en", " ", " w", "es", " an", " i", "\r", "f ", "g", "p", "nd", " s", "nd ", "ed ", "w", "ed", "http://", "for", "te", "ing", "y ", "The", " c", "ti", "r ", "his", "st", " in", "ar", "nt", ",", " to", "y", "ng", " h", "with", "le", "al", "to ", "b", "ou", "be", "were", " b", "se", "o ", "ent", "ha", "ng ", "their", "\"", "hi", "from", " f", "in ", "de", "ion", "me", "v", ".", "ve", "all", "re ", "ri", "ro", "is ", "co", "f t", "are", "ea", ". ", "her", " m", "er ", " p", "es ", "by", "they", "di", "ra", "ic", "not", "s, ", "d t", "at ", "ce", "la", "h ", "ne", "as ", "tio", "on ", "n t", "io", "we", " a ", "om", ", a", "s o", "ur", "li", "ll", "ch", "had", "this", "e t", "g ", "e\r\n", " wh", "ere", " co", "e o", "a ", "us", " d", "ss", "\n\r\n", "\r\n\r", "=\"", " be", " e", "s a", "ma", "one", "t t", "or ", "but", "el", "so", "l ", "e s", "s,", "no", "ter", " wa", "iv", "ho", "e a", " r", "hat", "s t", "ns", "ch ", "wh", "tr", "ut", "/", "have", "ly ", "ta", " ha", " on", "tha", "-", " l", "ati", "en ", "pe", " re", "there", "ass", "si", " fo", "wa", "ec", "our", "who", "its", "z", "fo", "rs", ">", "ot", "un", "<", "im", "th ", "nc", "ate", "><", "ver", "ad", " we", "ly", "ee", " n", "id", " cl", "ac", "il", "</", "rt", " wi", "div", "e, ", " it", "whi", " ma", "ge", "x", "�", "\'>", "=\'"];
|
||||||
|
|
||||||
var cb = rc.reduce(function(result, item, index, array) {
|
var cb = rc.reduce(function(result, item, index, array) {
|
||||||
@ -20,103 +25,100 @@ var cb = rc.reduce(function(result, item, index, array) {
|
|||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
var smaz = module.exports = {
|
var smaz = module.exports = {
|
||||||
codebook: cb,
|
codebook: cb,
|
||||||
reverse_codebook: rc,
|
reverse_codebook: rc,
|
||||||
flush_verbatim: function(verbatim) {
|
flush_verbatim: function(verbatim) {
|
||||||
var output = [];
|
var output = [];
|
||||||
if (verbatim.length > 1) {
|
if (verbatim.length > 1) {
|
||||||
output.push(255);
|
output.push(255);
|
||||||
output.push(verbatim.length-1);
|
output.push(verbatim.length-1);
|
||||||
} else {
|
} else {
|
||||||
output.push(254);
|
output.push(254);
|
||||||
}
|
}
|
||||||
var k = 0;
|
var k = 0;
|
||||||
for (; k < verbatim.length; k++) {
|
for (; k < verbatim.length; k++) {
|
||||||
output.push(verbatim.charCodeAt(k));
|
output.push(verbatim.charCodeAt(k));
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
},
|
},
|
||||||
|
|
||||||
compress: function(input) {
|
compress: function(input) {
|
||||||
var verbatim = "";
|
var verbatim = "";
|
||||||
var output = [];
|
var output = [];
|
||||||
var input_index = 0;
|
var input_index = 0;
|
||||||
|
|
||||||
while (input_index < input.length) {
|
while (input_index < input.length) {
|
||||||
// Try to lookup substrings into the hash table, starting from the
|
// Try to lookup substrings into the hash table, starting from the
|
||||||
// longer to the shorter substrings
|
// longer to the shorter substrings
|
||||||
var encoded = false;
|
var encoded = false;
|
||||||
var j = 7;
|
var j = 7;
|
||||||
|
|
||||||
if (input.length-input_index < 7) {
|
if (input.length-input_index < 7) {
|
||||||
j = input.length-input_index;
|
j = input.length-input_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; j > 0; j--) {
|
for (; j > 0; j--) {
|
||||||
var code = smaz.codebook[input.substr(input_index,j)];
|
var code = smaz.codebook[input.substr(input_index,j)];
|
||||||
if (code != undefined) {
|
if (code != undefined) {
|
||||||
// Match found in the hash table,
|
// Match found in the hash table,
|
||||||
// Flush verbatim bytes if needed
|
// Flush verbatim bytes if needed
|
||||||
if (verbatim) {
|
if (verbatim) {
|
||||||
|
output = output.concat(smaz.flush_verbatim(verbatim));
|
||||||
|
verbatim = "";
|
||||||
|
}
|
||||||
|
// Emit the byte
|
||||||
|
output.push(code);
|
||||||
|
input_index += j;
|
||||||
|
encoded = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!encoded) {
|
||||||
|
// Match not found - add the byte to the verbatim buffer
|
||||||
|
verbatim += input[input_index];
|
||||||
|
input_index++;
|
||||||
|
// Flush if we reached the verbatim bytes length limit
|
||||||
|
if (verbatim.length == 256) {
|
||||||
|
output = output.concat(smaz.flush_verbatim(verbatim));
|
||||||
|
verbatim = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Flush verbatim bytes if needed
|
||||||
|
if (verbatim) {
|
||||||
output = output.concat(smaz.flush_verbatim(verbatim));
|
output = output.concat(smaz.flush_verbatim(verbatim));
|
||||||
verbatim = "";
|
verbatim = "";
|
||||||
}
|
|
||||||
// Emit the byte
|
|
||||||
output.push(code);
|
|
||||||
|
|
||||||
input_index += j;
|
|
||||||
|
|
||||||
encoded = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
return new Uint8Array(output);
|
||||||
if (!encoded) {
|
},
|
||||||
// Match not found - add the byte to the verbatim buffer
|
|
||||||
verbatim += input[input_index];
|
|
||||||
input_index++;
|
|
||||||
|
|
||||||
// Flush if we reached the verbatim bytes length limit
|
decompress: function(input) {
|
||||||
if (verbatim.length == 256) {
|
var output = "";
|
||||||
output = output.concat(smaz.flush_verbatim(verbatim));
|
var i = 0;
|
||||||
verbatim = "";
|
while (i < input.length) {
|
||||||
|
if (input[i] === 254) {
|
||||||
|
// Verbatim byte
|
||||||
|
if (i+1 >= input.length) {
|
||||||
|
throw "Malformed smaz.";
|
||||||
|
}
|
||||||
|
output += String.fromCharCode(input[i+1]);
|
||||||
|
i += 2;
|
||||||
|
} else if (input[i] === 255) {
|
||||||
|
// Verbatim string
|
||||||
|
var j;
|
||||||
|
if (i+input[i+1]+2 >= input.length) {
|
||||||
|
throw "Malformed smaz.";
|
||||||
|
}
|
||||||
|
for (j = 0; j < input[i+1]+1; j++) {
|
||||||
|
output += String.fromCharCode(input[i+2+j]);
|
||||||
|
}
|
||||||
|
i += 3+input[i+1];
|
||||||
|
} else {
|
||||||
|
// Codebook entry
|
||||||
|
output += smaz.reverse_codebook[input[i]];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
return output;
|
||||||
}
|
}
|
||||||
// Flush verbatim bytes if needed
|
|
||||||
if (verbatim) {
|
|
||||||
output = output.concat(smaz.flush_verbatim(verbatim));
|
|
||||||
verbatim = "";
|
|
||||||
}
|
|
||||||
return new Uint8Array(output);
|
|
||||||
},
|
|
||||||
|
|
||||||
decompress: function(input) {
|
|
||||||
var output = "";
|
|
||||||
var i = 0;
|
|
||||||
while (i < input.length) {
|
|
||||||
if (input[i] === 254) {
|
|
||||||
// Verbatim byte
|
|
||||||
if (i+1 >= input.length) {
|
|
||||||
throw "Malformed smaz.";
|
|
||||||
}
|
|
||||||
output += String.fromCharCode(input[i+1]);
|
|
||||||
i += 2;
|
|
||||||
} else if(input[i] === 255) {
|
|
||||||
// Verbatim string
|
|
||||||
var j;
|
|
||||||
if (i+input[i+1]+2 >= input.length) {
|
|
||||||
throw "Malformed smaz.";
|
|
||||||
}
|
|
||||||
for (j = 0; j < input[i+1]+1; j++) {
|
|
||||||
output += String.fromCharCode(input[i+2+j]);
|
|
||||||
}
|
|
||||||
i += 3+input[i+1];
|
|
||||||
} else {
|
|
||||||
// Codebook entry
|
|
||||||
output += smaz.reverse_codebook[input[i]];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
@ -55,7 +55,7 @@ module.exports = function(RED) {
|
|||||||
if (flag) {
|
if (flag) {
|
||||||
RED.nodes.addCredentials(n.id,{userid:this.userid, password:this.password, global:true});
|
RED.nodes.addCredentials(n.id,{userid:this.userid, password:this.password, global:true});
|
||||||
}
|
}
|
||||||
if (n.tls === false){
|
if (n.tls === false) {
|
||||||
this.tls = false;
|
this.tls = false;
|
||||||
}
|
}
|
||||||
var node = this;
|
var node = this;
|
||||||
@ -289,7 +289,7 @@ module.exports = function(RED) {
|
|||||||
// and pass in the email message. The parser will signal when it has parsed the message.
|
// and pass in the email message. The parser will signal when it has parsed the message.
|
||||||
SimpleParser(data, {}, function(err, parsed) {
|
SimpleParser(data, {}, function(err, parsed) {
|
||||||
//node.log(util.format("SimpleParser: on(end): %j", mailObject));
|
//node.log(util.format("SimpleParser: on(end): %j", mailObject));
|
||||||
if (err){
|
if (err) {
|
||||||
node.status({fill:"red", shape:"ring", text:"email.status.parseerror"});
|
node.status({fill:"red", shape:"ring", text:"email.status.parseerror"});
|
||||||
node.error(RED._("email.errors.parsefail", {folder:node.box}), err);
|
node.error(RED._("email.errors.parsefail", {folder:node.box}), err);
|
||||||
}
|
}
|
||||||
@ -391,7 +391,7 @@ module.exports = function(RED) {
|
|||||||
imapMessage.on('body', function(stream, info) {
|
imapMessage.on('body', function(stream, info) {
|
||||||
//console.log("> message - body - stream=?, info=%j", info);
|
//console.log("> message - body - stream=?, info=%j", info);
|
||||||
SimpleParser(stream, {}, function(err, parsed) {
|
SimpleParser(stream, {}, function(err, parsed) {
|
||||||
if (err){
|
if (err) {
|
||||||
node.status({fill:"red", shape:"ring", text:"email.status.parseerror"});
|
node.status({fill:"red", shape:"ring", text:"email.status.parseerror"});
|
||||||
node.error(RED._("email.errors.parsefail", {folder:node.box}),err);
|
node.error(RED._("email.errors.parsefail", {folder:node.box}),err);
|
||||||
}
|
}
|
||||||
|
@ -519,10 +519,10 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function filterdActiveDevices(devices){
|
function filterdActiveDevices(devices) {
|
||||||
var activeDevices = [];
|
var activeDevices = [];
|
||||||
for(var i=0;i<devices.length;i++){
|
for (var i=0; i<devices.length; i++) {
|
||||||
if(devices[i].active){
|
if (devices[i].active) {
|
||||||
activeDevices.push(devices[i]);
|
activeDevices.push(devices[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ module.exports = function(RED) {
|
|||||||
// Is it base64 encoded or binary?
|
// Is it base64 encoded or binary?
|
||||||
var attachmentString = attachment.toString();
|
var attachmentString = attachment.toString();
|
||||||
var attachmentBuffer = Buffer.from(attachmentString,'base64');
|
var attachmentBuffer = Buffer.from(attachmentString,'base64');
|
||||||
if(attachmentString === attachmentBuffer.toString('base64')) {
|
if (attachmentString === attachmentBuffer.toString('base64')) {
|
||||||
// If converts back to same, then it was base64 so set to binary
|
// If converts back to same, then it was base64 so set to binary
|
||||||
// https://stackoverflow.com/a/48770228
|
// https://stackoverflow.com/a/48770228
|
||||||
attachment = attachmentBuffer;
|
attachment = attachmentBuffer;
|
||||||
|
@ -505,7 +505,7 @@ module.exports = function(RED) {
|
|||||||
var missingUsernames = Object.keys(missingUsers).join(",");
|
var missingUsernames = Object.keys(missingUsers).join(",");
|
||||||
return node.twitterConfig.getUsers(missingUsernames).then(function() {
|
return node.twitterConfig.getUsers(missingUsernames).then(function() {
|
||||||
var len = tweets.length;
|
var len = tweets.length;
|
||||||
for (var i = 0;i < len; i++) {
|
for (var i = 0; i < len; i++) {
|
||||||
var tweet = messages[i];
|
var tweet = messages[i];
|
||||||
var output = tweets[i];
|
var output = tweets[i];
|
||||||
output.sender = userObjectCache[tweet.message_create.sender_id];
|
output.sender = userObjectCache[tweet.message_create.sender_id];
|
||||||
|
@ -49,7 +49,7 @@ module.exports = function(RED) {
|
|||||||
var bind = [];
|
var bind = [];
|
||||||
|
|
||||||
var doQuery = function(msg) {
|
var doQuery = function(msg) {
|
||||||
if (node.sqlquery == "msg.topic"){
|
if (node.sqlquery == "msg.topic") {
|
||||||
if (typeof msg.topic === 'string') {
|
if (typeof msg.topic === 'string') {
|
||||||
if (msg.topic.length > 0) {
|
if (msg.topic.length > 0) {
|
||||||
bind = Array.isArray(msg.payload) ? msg.payload : [];
|
bind = Array.isArray(msg.payload) ? msg.payload : [];
|
||||||
@ -84,7 +84,7 @@ module.exports = function(RED) {
|
|||||||
node.status({fill:"red", shape:"dot",text:"msg.topic error"});
|
node.status({fill:"red", shape:"dot",text:"msg.topic error"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (node.sqlquery == "fixed"){
|
if (node.sqlquery == "fixed") {
|
||||||
if (typeof node.sql === 'string') {
|
if (typeof node.sql === 'string') {
|
||||||
if (node.sql.length > 0) {
|
if (node.sql.length > 0) {
|
||||||
node.mydbConfig.db.all(node.sql, bind, function(err, row) {
|
node.mydbConfig.db.all(node.sql, bind, function(err, row) {
|
||||||
@ -96,14 +96,14 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
if (node.sql === null || node.sql == "") {
|
if (node.sql === null || node.sql == "") {
|
||||||
node.error("SQL statement config not set up",msg);
|
node.error("SQL statement config not set up",msg);
|
||||||
node.status({fill:"red",shape:"dot",text:"SQL config not set up"});
|
node.status({fill:"red",shape:"dot",text:"SQL config not set up"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (node.sqlquery == "prepared"){
|
if (node.sqlquery == "prepared") {
|
||||||
if (typeof node.sql === 'string' && typeof msg.params !== "undefined" && typeof msg.params === "object") {
|
if (typeof node.sql === 'string' && typeof msg.params !== "undefined" && typeof msg.params === "object") {
|
||||||
if (node.sql.length > 0) {
|
if (node.sql.length > 0) {
|
||||||
node.mydbConfig.db.all(node.sql, msg.params, function(err, row) {
|
node.mydbConfig.db.all(node.sql, msg.params, function(err, row) {
|
||||||
|
@ -75,7 +75,7 @@ module.exports = function(RED) {
|
|||||||
else {
|
else {
|
||||||
if (exifData) {
|
if (exifData) {
|
||||||
msg.exif = exifData;
|
msg.exif = exifData;
|
||||||
if((exifData.hasOwnProperty("gps")) && (Object.keys(exifData.gps).length !== 0)) {
|
if ((exifData.hasOwnProperty("gps")) && (Object.keys(exifData.gps).length !== 0)) {
|
||||||
addMsgLocationDataFromExifGPSData(msg);
|
addMsgLocationDataFromExifGPSData(msg);
|
||||||
}
|
}
|
||||||
//else { node.log("The incoming image did not contain Exif GPS data."); }
|
//else { node.log("The incoming image did not contain Exif GPS data."); }
|
||||||
|
Loading…
Reference in New Issue
Block a user