diff --git a/nodes/core/core/58-debug.html b/nodes/core/core/58-debug.html index 05d6c25d2..69c59f52c 100644 --- a/nodes/core/core/58-debug.html +++ b/nodes/core/core/58-debug.html @@ -148,7 +148,7 @@ if (subWindow) { try { - subWindow.postMessage(JSON.stringify(o),"*") + subWindow.postMessage(o,"*") } catch(err) { console.log(err); } diff --git a/nodes/core/core/58-debug.js b/nodes/core/core/58-debug.js index d080c38ee..be780c7ba 100644 --- a/nodes/core/core/58-debug.js +++ b/nodes/core/core/58-debug.js @@ -160,7 +160,6 @@ module.exports = function(RED) { root: __dirname + '/lib/debug/', dotfiles: 'deny' }; - console.log("SERVING UP",req.params[0]); res.sendFile(req.params[0], options); }); }; diff --git a/nodes/core/core/lib/debug/debug.js b/nodes/core/core/lib/debug/debug.js index 3b8f419f5..4529ada7f 100644 --- a/nodes/core/core/lib/debug/debug.js +++ b/nodes/core/core/lib/debug/debug.js @@ -1,6 +1,77 @@ $(function() { + function getTimestamp() { + var d = new Date(); + return d.toLocaleString(); + } + function sanitize(m) { + return m.replace(/&/g,"&").replace(//g,">"); + } window.addEventListener('message',function(evt) { console.log(evt.data); - $('
').text(evt.data).appendTo(document.body); + var o = evt.data; + + var msg = document.createElement("div"); + + //var sourceNode = RED.nodes.node(o.id) || RED.nodes.node(o.z); + + // msg.onmouseover = function() { + // msg.style.borderRightColor = "#999"; + // var n = RED.nodes.node(o.id) || RED.nodes.node(o.z); + // if (n) { + // n.highlighted = true; + // n.dirty = true; + // } + // RED.view.redraw(); + // }; + // msg.onmouseout = function() { + // msg.style.borderRightColor = ""; + // var n = RED.nodes.node(o.id) || RED.nodes.node(o.z); + // if (n) { + // n.highlighted = false; + // n.dirty = true; + // } + // RED.view.redraw(); + // }; + // msg.onclick = function() { + // var node = RED.nodes.node(o.id) || RED.nodes.node(o.z); + // if (node) { + // RED.workspaces.show(node.z); + // } + // + // }; + //console.log(o); + var name = sanitize(((o.name?o.name:o.id)||"").toString()); + var topic = sanitize((o.topic||"").toString()); + var property = sanitize(o.property?o.property:''); + var payload = sanitize((o.msg||"").toString()); + var format = sanitize((o.format||"").toString()); + + msg.className = 'debug-message'+(o.level?(' debug-message-level-'+o.level):''); + msg.innerHTML = ''+ + getTimestamp()+''+ + (name?''+name:'')+ + ''; + // NOTE: relying on function error to have a "type" that all other msgs don't + if (o.hasOwnProperty("type") && (o.type === "function")) { + var errorLvlType = 'error'; + var errorLvl = 20; + if (o.hasOwnProperty("level") && o.level === 30) { + errorLvl = 30; + errorLvlType = 'warn'; + } + msg.className = 'debug-message debug-message-level-' + errorLvl; + msg.innerHTML += 'function : (' + errorLvlType + ')'; + } else { + msg.innerHTML += ''+ + (o.topic?topic+' : ':'')+ + (o.property?'msg.'+property:'msg')+" : "+format+ + + ''; + } + msg.innerHTML += ''+ payload+ ''; + $("#debug-content").append(msg); + + + },false) }); diff --git a/nodes/core/core/lib/debug/style.css b/nodes/core/core/lib/debug/style.css index acd8bac0f..47d62efad 100644 --- a/nodes/core/core/lib/debug/style.css +++ b/nodes/core/core/lib/debug/style.css @@ -1,3 +1,8 @@ +.debug-window { + padding:0; + margin:0; + background: #fff; +} #debug-content { position: absolute; top: 43px; diff --git a/nodes/core/core/lib/debug/view.html b/nodes/core/core/lib/debug/view.html index a18c7d584..e89ea96dc 100644 --- a/nodes/core/core/lib/debug/view.html +++ b/nodes/core/core/lib/debug/view.html @@ -1,8 +1,18 @@ + + - + + +
+