diff --git a/nodes/core/core/lib/debug/debug.js b/nodes/core/core/lib/debug/debug.js
index 839ddddbc..7c71621e6 100644
--- a/nodes/core/core/lib/debug/debug.js
+++ b/nodes/core/core/lib/debug/debug.js
@@ -1,4 +1,16 @@
$(function() {
+
+ $("#debug-tab-clear").click(function() {
+ $(".debug-message").remove();
+ // messageCount = 0;
+ // RED.nodes.eachNode(function(node) {
+ // node.highlighted = false;
+ // node.dirty = true;
+ // });
+ // RED.view.redraw();
+ });
+
+
function getTimestamp() {
var d = new Date();
return d.toLocaleString();
@@ -72,50 +84,71 @@ $(function() {
msg.innerHTML += ''+ payload+ '';
} else {
var el = $('').appendTo(msg);
- buildMessageElement(JSON.parse(payload)).appendTo(el);
+ buildMessageElement(JSON.parse(payload),true).appendTo(el);
}
$("#debug-content").append(msg);
$("#debug-content").scrollTop($("#debug-content")[0].scrollHeight);
},false);
- function buildMessageElement(obj) {
+ function buildMessageElement(obj,topLevel) {
var i;
var e;
var entryObj;
- var element = $('');
+ var header;
+ var element = $('').toggleClass('collapsed',topLevel);
if (Array.isArray(obj)) {
$('').html('Array['+obj.length+']').appendTo(element);
- for (i=0;i').appendTo(element);
- if (typeof obj[i] === 'object') {
- $(' ').click(function(e) {
+ header = $('').appendTo(entryObj);
+ if (typeof obj[i] === 'object' && obj[i] !== null) {
+ $(' ').appendTo(header);
+ header.addClass("debug-message-expandable");
+ header.click(function(e) {
$(this).parent().toggleClass('collapsed');
- }).appendTo(entryObj);
+ });
}
- $('').text(i).appendTo(entryObj);
+ $('').text(i).appendTo(header);
$(': ').appendTo(entryObj);
e = $('').appendTo(entryObj);
- buildMessageElement(obj[i]).appendTo(e);
+ buildMessageElement(obj[i],false).appendTo(e);
}
+ if (length < obj.length) {
+ $('...
').appendTo(element);
+ }
+ } else if (obj === null) {
+ $('null').appendTo(element);
} else if (typeof obj === 'object') {
- $('').html('Object').appendTo(element);
+
+ header = $('').html((topLevel?(JSON.stringify(obj,2).substring(0,200)):'Object')).appendTo(element);
+ if (topLevel) {
+ $(' ').prependTo(header);
+ header.addClass("debug-message-expandable");
+ header.click(function(e) {
+ $(this).parent().toggleClass('collapsed');
+ });
+ }
var keys = Object.keys(obj);
for (i=0;i').appendTo(element);
- if (typeof obj[keys[i]] === 'object') {
- $(' ').click(function(e) {
+ header = $('').appendTo(entryObj);
+ if (typeof obj[keys[i]] === 'object' && obj[keys[i]] !== null) {
+ $(' ').appendTo(header);
+ header.addClass("debug-message-expandable");
+ header.click(function(e) {
$(this).parent().toggleClass('collapsed');
- }).appendTo(entryObj);
+ });
}
- $('').text(keys[i]).appendTo(entryObj);
- $(': ').appendTo(entryObj);
+ $('').text(keys[i]).appendTo(header);
+ $(': ').appendTo(header);
e = $('').appendTo(entryObj);
- buildMessageElement(obj[keys[i]]).appendTo(e);
+ buildMessageElement(obj[keys[i]],false).appendTo(e);
}
} else if (typeof obj === 'string') {
- $('').text('"'+obj+'"').appendTo(element);
+ $('').text('"'+obj+'"').appendTo(element);
} else {
- $('').text(""+obj).appendTo(element);
+ $('').text(""+obj).appendTo(element);
}
return element;
}
diff --git a/nodes/core/core/lib/debug/style.css b/nodes/core/core/lib/debug/style.css
index 9a550afc7..76de6d870 100644
--- a/nodes/core/core/lib/debug/style.css
+++ b/nodes/core/core/lib/debug/style.css
@@ -4,7 +4,7 @@
background: #fff;
}
.debug-window .debug-message-payload {
- font-size: 12px;
+ font-size: 14px;
}
#debug-content {
position: absolute;
@@ -15,7 +15,6 @@
overflow-y: scroll;
}
.debug-message {
- cursor: pointer;
border-bottom: 1px solid #eee;
border-left: 8px solid #eee;
border-right: 8px solid #eee;
@@ -60,28 +59,47 @@
.debug-message-object-entry {
padding-left: 15px;
padding-bottom: 3px;
+ padding-top: 3px;
+}
+.debug-message-element {
+ color: #333;
}
-
.debug-message-object-key {
- color: #a66;
+ color: #792e90;
}
.debug-message-object-value {
}
.debug-message-object-handle {
- color: #999;
- font-size: 0.8em;
+ color: #666;
+ font-size: 1em;
width: 1em;
- margin-left: -1em;
text-align: center;
- transition: transform 0.2s ease-in-out;
+ transition: transform 0.1s ease-in-out;
transform: rotate(90deg);
}
-
-.debug-message-object-entry.collapsed>.debug-message-object-handle {
+.debug-message-object-entry>span>.debug-message-object-handle {
+ margin-left: -1em;
+}
+.debug-message-object-entry.collapsed>span>.debug-message-object-handle {
+ transform: rotate(0deg);
+}
+.debug-message-element.collapsed>span>.debug-message-object-handle {
transform: rotate(0deg);
}
.debug-message-object-entry.collapsed .debug-message-object-entry {
display:none;
}
+
+.debug-message-element.collapsed .debug-message-object-entry {
+ display:none;
+}
+
+.debug-message-type-other { color: #2033d6; }
+.debug-message-type-string { color: #b72828; }
+.debug-message-type-null { color: #666; font-style: italic;}
+
+.debug-message-expandable {
+ cursor: pointer;
+}