Invalid Space ID: lochlcst
SnifferInfotron
History Key
- New content
Removed content
Recent Versions
Choose two versions to compare, or click the link to view it.
This blueprint can be put between any other blueprint, like a T-wiring, and just dumps all messages on its designed element,a nd passes them along. Good for debugging hard-to-grok blueprints and/or wirings.
Sample Declaration
<div id="slideshow"
impl="~010DC44F33F73148238544C3FFC7EF4ADA"
script="http://localhost/Sniffer.js">
</div>
Input Terminals
- in: (expected message type: anything)
Output Terminals
- out: (Passing forward the input message on 'in')
Properties
- none
Demos that use it
How does it work
This blueprint copies the data coming on the 'in' input terminal to the output terminal 'out' and simultaneously (OK, almost) to innerHTML of its DOM node
BLUEPRINT(
"~010DC44F33F73148238544C3FFC7EF4ADA",
[
["in", "onMessage", -1]
],
[
"out"
],
function (Class)
{
Class.prototype._onInit = function(props)
{
this._
};
Class.prototype.onMessage = function(msg)
{
var o = this._createEntry(msg);
this.dom_node.innerHTML = o.innerHTML;
this.postMessage("out", msg);
};
Class.prototype._createEntry = function(o)
{
var e = __d.createElement("DIV");
e.innerHTML = this._createStringRep(o);
return e;
};
Class.prototype._createStringRep = function(o, lvl)
{
var key, i, n, s;
var lvl = lvl || 0;
var margin = "";
if (lvl > 1) {
for (i = 0; i < lvl; i ++) {
margin += " ";
}
}
if (typeof(o) == typeof("")) {
s = "\"" + o + "\"";
} else {
try {
s = o.toString();
if (s == "[object Object]") {
s = "{<br />";
for (key in o) {
s += margin + "<b>" + key + "</b>: " + this._createStringRep(o[key], lvl + 1) + "<br />";
}
s += margin + "}";
} else if (o.sort) { // array
n = o.length;
s = "[<br />";
for (i = 0; i < n; i ++) {
s += margin + this._createStringRep(o[i], lvl + 1) + "<br />";
}
s += margin + "]";
}
} catch (ex) {
if (s === undefined ) {
s = "<em>undefined</em>";
} else if (s === null) {
s = "<em>null</em>";
} else {
// what can it be?
s = "<em>unknown</em>";
}
}
}
return s;
};
}, "New Infotron");