SnifferInfotron

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 = "{
"; for (key in o) { s += margin + "" + key + ": " + this._createStringRep(o[key], lvl + 1) + "
"; } s += margin + "}"; } else if (o.sort) { // array n = o.length; s = "[
"; for (i = 0; i < n; i ++) { s += margin + this._createStringRep(o[i], lvl + 1) + "
"; } s += margin + "]"; } } catch (ex) { if (s === undefined ) { s = "undefined"; } else if (s === null) { s = "null"; } else { // what can it be? s = "unknown"; } } } return s; }; }, "New Infotron");


Copyright © 2006–2008 by Assembla, LLC / Phone 1.781.328.2241 / E-mail: info@assembla.com