diff --git a/nodes/core/core/lib/debug/debug.js b/nodes/core/core/lib/debug/debug.js
index 4529ada7f..839ddddbc 100644
--- a/nodes/core/core/lib/debug/debug.js
+++ b/nodes/core/core/lib/debug/debug.js
@@ -68,10 +68,55 @@ $(function() {
'';
}
- msg.innerHTML += ''+ payload+ '';
+ if (format !== 'Object') {
+ msg.innerHTML += ''+ payload+ '';
+ } else {
+ var el = $('').appendTo(msg);
+ buildMessageElement(JSON.parse(payload)).appendTo(el);
+ }
$("#debug-content").append(msg);
+ $("#debug-content").scrollTop($("#debug-content")[0].scrollHeight);
+ },false);
-
-
- },false)
+ function buildMessageElement(obj) {
+ var i;
+ var e;
+ var entryObj;
+ var element = $('');
+ if (Array.isArray(obj)) {
+ $('').html('Array['+obj.length+']').appendTo(element);
+ for (i=0;i').appendTo(element);
+ if (typeof obj[i] === 'object') {
+ $(' ').click(function(e) {
+ $(this).parent().toggleClass('collapsed');
+ }).appendTo(entryObj);
+ }
+ $('').text(i).appendTo(entryObj);
+ $(': ').appendTo(entryObj);
+ e = $('').appendTo(entryObj);
+ buildMessageElement(obj[i]).appendTo(e);
+ }
+ } else if (typeof obj === 'object') {
+ $('').html('Object').appendTo(element);
+ var keys = Object.keys(obj);
+ for (i=0;i').appendTo(element);
+ if (typeof obj[keys[i]] === 'object') {
+ $(' ').click(function(e) {
+ $(this).parent().toggleClass('collapsed');
+ }).appendTo(entryObj);
+ }
+ $('').text(keys[i]).appendTo(entryObj);
+ $(': ').appendTo(entryObj);
+ e = $('').appendTo(entryObj);
+ buildMessageElement(obj[keys[i]]).appendTo(e);
+ }
+ } else if (typeof obj === 'string') {
+ $('').text('"'+obj+'"').appendTo(element);
+ } else {
+ $('').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 47d62efad..9a550afc7 100644
--- a/nodes/core/core/lib/debug/style.css
+++ b/nodes/core/core/lib/debug/style.css
@@ -3,6 +3,9 @@
margin:0;
background: #fff;
}
+.debug-window .debug-message-payload {
+ font-size: 12px;
+}
#debug-content {
position: absolute;
top: 43px;
@@ -54,3 +57,31 @@
border-left-color: #f99;
border-right-color: #f99;
}
+.debug-message-object-entry {
+ padding-left: 15px;
+ padding-bottom: 3px;
+}
+
+.debug-message-object-key {
+ color: #a66;
+}
+.debug-message-object-value {
+
+}
+.debug-message-object-handle {
+ color: #999;
+ font-size: 0.8em;
+ width: 1em;
+ margin-left: -1em;
+ text-align: center;
+ transition: transform 0.2s ease-in-out;
+ transform: rotate(90deg);
+}
+
+.debug-message-object-entry.collapsed>.debug-message-object-handle {
+ transform: rotate(0deg);
+}
+
+.debug-message-object-entry.collapsed .debug-message-object-entry {
+ display:none;
+}
diff --git a/nodes/core/core/lib/debug/view.html b/nodes/core/core/lib/debug/view.html
index e89ea96dc..bfbffac9c 100644
--- a/nodes/core/core/lib/debug/view.html
+++ b/nodes/core/core/lib/debug/view.html
@@ -3,6 +3,7 @@
+ Node-RED Debug Tools