Skip to content
Permalink
Browse files

Allows inject to be triggered from the console.

 * Debug purposes
  • Loading branch information...
Saevon committed Aug 4, 2015
1 parent 47afa7e commit 0f8bf91a75718a58517186c49a04732967554e6d
Showing with 24 additions and 0 deletions.
  1. +24 −0 nodes/core/core/20-inject.js
@@ -18,7 +18,26 @@ module.exports = function(RED) {
"use strict";
var cron = require("cron");

// DEBUG CODE:
var injects = {};
if (window === undefined) {
var window = {};
}
window.nodeRedInject = function(name) {
if (!name) {
return injects;
}

var node = injects[name];
if (!node) {
return;
}

node.emit("input", {});
};

function InjectNode(n) {

RED.nodes.createNode(this,n);
this.topic = n.topic;
this.payload = n.payload;
@@ -49,6 +68,11 @@ module.exports = function(RED) {
setTimeout( function(){ node.emit("input",{}); }, 100);
}

// DEBUG CODE:
if (n.name) {
injects[n.name] = this;
}

this.on("input",function(msg) {
var msg = {topic:this.topic};
if ( (this.payloadType == null && this.payload === "") || this.payloadType === "date") {

0 comments on commit 0f8bf91

Please sign in to comment.
You can’t perform that action at this time.