1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Handle big arrays/buffers better in debug sidebar

This commit is contained in:
Nick O'Leary 2016-11-02 00:16:36 +00:00
parent d1eb82bdf6
commit 1f2c9879bd
3 changed files with 419 additions and 181 deletions

View File

@ -92,9 +92,18 @@ module.exports = function(RED) {
} catch(err) { } catch(err) {
msg.format = "Object"; msg.format = "Object";
} }
if (/error/i.test(msg.format)) {
msg.msg = JSON.stringify({
name: msg.msg.name,
message: msg.msg.message
});
} else {
var isArray = util.isArray(msg.msg); var isArray = util.isArray(msg.msg);
if (isArray) { if (isArray) {
msg.format = "array["+msg.msg.length+"]"; msg.format = "array["+msg.msg.length+"]";
if (msg.msg.length > debuglength) {
msg.msg = msg.msg.slice(0,debuglength);
}
} }
if (isArray || (msg.format === "Object")) { if (isArray || (msg.format === "Object")) {
msg.msg = JSON.stringify(msg.msg, function(key, value) { msg.msg = JSON.stringify(msg.msg, function(key, value) {
@ -104,6 +113,16 @@ module.exports = function(RED) {
if (key === '_req' || key === '_res') { if (key === '_req' || key === '_res') {
return "[internal]" return "[internal]"
} }
if (value instanceof Error) {
return value.toString()
}
if (util.isArray(value) && value.length > debuglength) {
value = {
type: "array",
data: value.slice(0,debuglength),
length: value.length
}
}
if (typeof value === 'object' && value !== null) { if (typeof value === 'object' && value !== null) {
if (seen.indexOf(value) !== -1) { return "[circular]"; } if (seen.indexOf(value) !== -1) { return "[circular]"; }
seen.push(value); seen.push(value);
@ -119,6 +138,7 @@ module.exports = function(RED) {
try { msg.msg = msg.msg.toString(); } try { msg.msg = msg.msg.toString(); }
catch(e) { msg.msg = "[Type not printable]"; } catch(e) { msg.msg = "[Type not printable]"; }
} }
}
seen = null; seen = null;
} else if (typeof msg.msg === "boolean") { } else if (typeof msg.msg === "boolean") {
msg.format = "boolean"; msg.format = "boolean";
@ -138,7 +158,6 @@ module.exports = function(RED) {
msg.msg = msg.msg.substring(0,debuglength)+"..."; msg.msg = msg.msg.substring(0,debuglength)+"...";
} }
} }
// if (msg.msg.length > debuglength) { // if (msg.msg.length > debuglength) {
// msg.msg = msg.msg.substr(0,debuglength) +" ...."; // msg.msg = msg.msg.substr(0,debuglength) +" ....";
// } // }

View File

@ -132,7 +132,6 @@ RED.debug = (function() {
activeWorkspace = _activeWorkspace; activeWorkspace = _activeWorkspace;
} }
$(".debug-message").each(function() { $(".debug-message").each(function() {
console.log()
$(this).toggleClass('hide',filter&&!$(this).hasClass('debug-message-flow-'+activeWorkspace)); $(this).toggleClass('hide',filter&&!$(this).hasClass('debug-message-flow-'+activeWorkspace));
}); });
} }
@ -170,182 +169,398 @@ RED.debug = (function() {
return str.replace(/\n/g,"↵").replace(/\t/g,"→"); return str.replace(/\n/g,"↵").replace(/\t/g,"→");
} }
function buildMessageSummaryValue(value) {
var result;
if (Array.isArray(value)) {
result = $('<span class="debug-message-object-value debug-message-type-meta"></span>').html('array['+value.length+']');
} else if (value === null) {
result = $('<span class="debug-message-object-value debug-message-type-null">null</span>');
} else if (typeof value === 'object') {
if (value.hasOwnProperty('type') && value.type === 'Buffer' && value.hasOwnProperty('data')) {
result = $('<span class="debug-message-object-value debug-message-type-meta"></span>').html('buffer['+value.data.length+']');
} else if (value.hasOwnProperty('type') && value.type === 'array' && value.hasOwnProperty('data')) {
result = $('<span class="debug-message-object-value debug-message-type-meta"></span>').html('array['+value.length+']');
} else {
result = $('<span class="debug-message-object-value debug-message-type-meta">object</span>');
}
} else if (typeof value === 'string') {
subvalue = value;
if (subvalue.length > 50) {
subvalue = subvalue.substring(0,50)+"&hellip;";
}
result = $('<span class="debug-message-object-value debug-message-type-string"></span>').html('"'+formatString(subvalue)+'"');
} else {
result = $('<span class="debug-message-object-value debug-message-type-other"></span>').text(""+value);
}
return result;
}
function makeExpandable(el,onexpand) {
el.addClass("debug-message-expandable");
el.click(function(e) {
var parent = $(this).parent();
if (parent.hasClass('collapsed')) {
if (onexpand && !parent.hasClass('built')) {
onexpand();
parent.addClass('built');
}
parent.removeClass('collapsed');
} else {
parent.addClass('collapsed');
}
e.preventDefault();
});
}
function buildMessageElement(obj,topLevel,typeHint) { function buildMessageElement(obj,key,typeHint,hideKey) {
var i; var i;
var e; var e;
var entryObj; var entryObj;
var header; var header;
var headerHead; var headerHead;
var value,subvalue; var value,subvalue;
var element = $('<span class="debug-message-element"></span>').toggleClass('collapsed',topLevel); var element = $('<span class="debug-message-element"></span>');
if (Array.isArray(obj)) { if (!key) {
var length = Math.min(obj.length,10); element.addClass("debug-message-top-level");
if (!topLevel) { }
header = $('<span class="debug-message-type-meta"></span>').html(typeHint||('array['+obj.length+']')).appendTo(element);
header = $('<span></span>').appendTo(element);
if (key && !hideKey) {
$('<span class="debug-message-object-key"></span>').text(key).appendTo(header);
$('<span>: </span>').appendTo(header);
}
entryObj = $('<span class="debug-message-object-value"></span>').appendTo(header);
var isArray = Array.isArray(obj);
var isArrayObject = false;
if (obj && typeof obj === 'object' && obj.hasOwnProperty('type') && obj.hasOwnProperty('data')) {
isArray = true;
isArrayObject = true;
}
if (obj === null || obj === undefined) {
$('<span class="debug-message-type-null">'+obj+'</span>').appendTo(entryObj);
} else if (typeof obj === 'string') {
$('<span class="debug-message-type-string"></span>').html('"'+formatString(obj)+'"').appendTo(entryObj);
} else if (typeof obj === 'number') {
e = $('<span class="debug-message-type-number"></span>').text(""+obj).appendTo(entryObj);
e.click(function(evt) {
var format = $(this).data('format');
if (format === 'hex') {
$(this).text(""+obj).data('format','dec');
} else { } else {
header = $('<span>').appendTo(element); $(this).text("0x"+(obj).toString(16)).data('format','hex');
if (length > 0) { }
evt.preventDefault();
});
} else if (isArray) {
element.addClass('collapsed');
var originalLength = obj.length;
if (typeHint) {
var m = /\[(\d+)\]/.exec(typeHint);
if (m) {
originalLength = parseInt(m[1]);
}
}
var data = obj;
var type = 'array';
if (isArrayObject) {
data = obj.data;
if (originalLength === undefined) {
originalLength = data.length;
}
type = obj.type.toLowerCase();
}
var fullLength = data.length;
if (originalLength > 0) {
$('<i class="fa fa-caret-right debug-message-object-handle"></i> ').prependTo(header); $('<i class="fa fa-caret-right debug-message-object-handle"></i> ').prependTo(header);
header.addClass("debug-message-expandable"); makeExpandable(header,function() {
header.click(function(e) { if (!key) {
$(this).parent().toggleClass('collapsed'); $('<span class="debug-message-type-meta debug-message-object-type-header"></span>').html(typeHint||(type+'['+originalLength+']')).appendTo(header);
//e.stopPropagation(); }
e.preventDefault(); var row;
if (fullLength <= 10) {
for (i=0;i<fullLength;i++) {
row = $('<div class="debug-message-object-entry collapsed"></div>').appendTo(element);
buildMessageElement(data[i],""+i,false).appendTo(row);
}
} else {
for (i=0;i<fullLength;i+=10) {
var minRange = i;
row = $('<div class="debug-message-object-entry collapsed"></div>').appendTo(element);
header = $('<span></span>').appendTo(row);
$('<i class="fa fa-caret-right debug-message-object-handle"></i> ').appendTo(header);
makeExpandable(header, (function() {
var min = minRange;
var max = Math.min(fullLength-1,(minRange+9));
var parent = row;
return function() {
for (var i=min;i<=max;i++) {
var row = $('<div class="debug-message-object-entry collapsed"></div>').appendTo(parent);
buildMessageElement(data[i],""+i,false).appendTo(row);
}
}
})());
$('<span class="debug-message-object-key"></span>').html("["+minRange+" &hellip; "+Math.min(fullLength-1,(minRange+9))+"]").appendTo(header);
}
}
}); });
} }
$('<span class="debug-message-type-meta debug-message-object-type-header"></span>').html(typeHint||('array['+obj.length+']')).appendTo(header); if (key) {
headerHead = $('<span class="debug-message-object-header"></span>').appendTo(header); $('<span class="debug-message-type-meta"></span>').html(typeHint||(type+'['+originalLength+']')).appendTo(entryObj);
} else {
headerHead = $('<span class="debug-message-object-header"></span>').appendTo(entryObj);
$('<span>[ </span>').appendTo(headerHead); $('<span>[ </span>').appendTo(headerHead);
} var arrayLength = Math.min(originalLength,10);
for (i=0;i<length;i++) { for (i=0;i<arrayLength;i++) {
if (topLevel) { buildMessageSummaryValue(data[i]).appendTo(headerHead);
value = obj[i]; if (i < arrayLength-1) {
if (Array.isArray(value)) {
$('<span class="debug-message-object-value debug-message-type-meta"></span>').html('array['+value.length+']').appendTo(headerHead);
} else if (value === null) {
$('<span class="debug-message-object-value debug-message-type-null">null</span>').appendTo(headerHead);
} else if (typeof value === 'object') {
if (value.hasOwnProperty('type') && value.type === 'Buffer' && value.hasOwnProperty('data')) {
$('<span class="debug-message-object-value debug-message-type-meta"></span>').html('buffer['+value.data.length+']').appendTo(headerHead);
} else {
$('<span class="debug-message-object-value debug-message-type-meta">object</span>').appendTo(headerHead);
}
} else if (typeof value === 'string') {
subvalue = value;
if (subvalue.length > 50) {
subvalue = subvalue.substring(0,50)+"...";
}
$('<span class="debug-message-object-value debug-message-type-string"></span>').html('"'+formatString(subvalue)+'"').appendTo(headerHead);
} else {
$('<span class="debug-message-object-value debug-message-type-other"></span>').text(""+value).appendTo(headerHead);
}
if (i < length -1) {
$('<span>, </span>').appendTo(headerHead); $('<span>, </span>').appendTo(headerHead);
} }
} }
entryObj = $('<div class="debug-message-object-entry collapsed"></div>').appendTo(element); if (originalLength > arrayLength) {
header = $('<span></span>').appendTo(entryObj); $('<span> &hellip;</span>').appendTo(headerHead);
if (typeof obj[i] === 'object' && obj[i] !== null) {
$('<i class="fa fa-caret-right debug-message-object-handle"></i> ').appendTo(header);
header.addClass("debug-message-expandable");
header.click(function(e) {
$(this).parent().toggleClass('collapsed');
//e.stopPropagation();
e.preventDefault();
});
} }
$('<span class="debug-message-object-key"></span>').text(i).appendTo(header); if (arrayLength === 0) {
$('<span>: </span>').appendTo(entryObj);
e = $('<span class="debug-message-object-value"></span>').appendTo(entryObj);
buildMessageElement(obj[i],false).appendTo(e);
}
if (length < obj.length) {
if (topLevel) {
$('<span> ...</span>').appendTo(headerHead);
}
$('<div class="debug-message-object-entry"><span class="debug-message-object-key">...</span></div>').appendTo(element);
}
if (topLevel) {
if (length === 0) {
$('<span class="debug-message-type-meta">empty</span>').appendTo(headerHead); $('<span class="debug-message-type-meta">empty</span>').appendTo(headerHead);
} }
$('<span> ]</span>').appendTo(headerHead); $('<span> ]</span>').appendTo(headerHead);
} }
} else if (obj === null || obj === undefined) {
$('<span class="debug-message-object-value debug-message-type-null">'+obj+'</span>').appendTo(element);
} else if (typeof obj === 'object') {
if (obj.hasOwnProperty('type') && obj.type === 'Buffer' && obj.hasOwnProperty('data')) {
buildMessageElement(obj.data,false,'buffer['+obj.data.length+']').appendTo(element);
} else { } else if (typeof obj === 'object') {
element.addClass('collapsed');
var keys = Object.keys(obj); var keys = Object.keys(obj);
if (topLevel) {
header = $('<span>').appendTo(element);
if (keys.length > 0) { if (keys.length > 0) {
$('<i class="fa fa-caret-right debug-message-object-handle"></i> ').prependTo(header); $('<i class="fa fa-caret-right debug-message-object-handle"></i> ').prependTo(header);
header.addClass("debug-message-expandable"); makeExpandable(header, function() {
header.click(function(e) { if (!key) {
$(this).parent().toggleClass('collapsed');
//e.stopPropagation();
e.preventDefault();
});
}
} else {
header = $('<span class="debug-message-type-meta"></span>').html('object').appendTo(element);
}
if (topLevel) {
$('<span class="debug-message-type-meta debug-message-object-type-header"></span>').html('object').appendTo(header); $('<span class="debug-message-type-meta debug-message-object-type-header"></span>').html('object').appendTo(header);
headerHead = $('<span class="debug-message-object-header"></span>').appendTo(header);
$('<span>{ </span>').appendTo(headerHead);
} }
for (i=0;i<keys.length;i++) { for (i=0;i<keys.length;i++) {
if (topLevel) { var row = $('<div class="debug-message-object-entry collapsed"></div>').appendTo(element);
if (i < 5) { buildMessageElement(obj[keys[i]],keys[i],false).appendTo(row);
$('<span class="debug-message-object-key"></span>').text(keys[i]).appendTo(headerHead); }
$('<span>: </span>').appendTo(headerHead); });
value = obj[keys[i]]; }
if (Array.isArray(value)) { if (key) {
$('<span class="debug-message-object-value debug-message-type-meta"></span>').html('array['+value.length+']').appendTo(headerHead); $('<span class="debug-message-type-meta"></span>').html('object').appendTo(entryObj);
} else if (value === null) {
$('<span class="debug-message-object-value debug-message-type-null">null</span>').appendTo(headerHead);
} else if (typeof value === 'object') {
if (value.hasOwnProperty('type') && value.type === 'Buffer' && value.hasOwnProperty('data')) {
$('<span class="debug-message-object-value debug-message-type-meta"></span>').html('buffer['+value.data.length+']').appendTo(headerHead);
} else { } else {
$('<span class="debug-message-object-value debug-message-type-meta">object</span>').appendTo(headerHead); headerHead = $('<span class="debug-message-object-header"></span>').appendTo(entryObj);
} $('<span>{ </span>').appendTo(headerHead);
} else if (typeof value === 'string') { var keysLength = Math.min(keys.length,5);
subvalue = value; for (i=0;i<keysLength;i++) {
if (subvalue.length > 50) { buildMessageSummaryValue(obj[keys[i]]).appendTo(headerHead);
subvalue = subvalue.substring(0,50)+"..."; if (i < keysLength-1) {
}
$('<span class="debug-message-object-value debug-message-type-string"></span>').html('"'+formatString(subvalue)+'"').appendTo(headerHead);
} else {
$('<span class="debug-message-object-value debug-message-type-other"></span>').text(""+value).appendTo(headerHead);
}
if (i < keys.length -1) {
$('<span>, </span>').appendTo(headerHead); $('<span>, </span>').appendTo(headerHead);
} }
} }
if (i === 5) { if (keys.length > keysLength) {
$('<span> ...</span>').appendTo(headerHead); $('<span> &hellip;</span>').appendTo(headerHead);
} }
if (keysLength === 0) {
$('<span class="debug-message-type-meta">empty</span>').appendTo(headerHead);
} }
entryObj = $('<div class="debug-message-object-entry collapsed"></div>').appendTo(element); $('<span> }</span>').appendTo(headerHead);
var entryHeader = $('<span></span>').appendTo(entryObj);
if (typeof obj[keys[i]] === 'object' && obj[keys[i]] !== null) {
$('<i class="fa fa-caret-right debug-message-object-handle"></i> ').appendTo(entryHeader); // $('<span class="debug-message-type-meta debug-message-object-type-header"></span>').html('object').appendTo(header);
entryHeader.addClass("debug-message-expandable"); // headerHead = $('<span class="debug-message-object-header"></span>').appendTo(header);
entryHeader.click(function(e) { // $('<span>{ </span>').appendTo(headerHead);
$(this).parent().toggleClass('collapsed'); // for (i=0;i<keys.length;i++) {
//e.stopPropagation(); // if (!key) {
e.preventDefault(); // if (i < 5) {
}); // $('<span class="debug-message-object-key"></span>').text(keys[i]).appendTo(headerHead);
} // $('<span>: </span>').appendTo(headerHead);
$('<span class="debug-message-object-key"></span>').text(keys[i]).appendTo(entryHeader); // buildMessageSummaryValue(obj[keys[i]]).appendTo(headerHead);
$('<span>: </span>').appendTo(entryHeader); // if (i < keys.length -1) {
e = $('<span class="debug-message-object-value"></span>').appendTo(entryObj); // $('<span>, </span>').appendTo(headerHead);
buildMessageElement(obj[keys[i]],false).appendTo(e); // }
// }
// if (i === 5) {
// $('<span> &hellip;</span>').appendTo(headerHead);
// }
// }
// entryObj = $('<div class="debug-message-object-entry collapsed"></div>').appendTo(element);
// var entryHeader = $('<span></span>').appendTo(entryObj);
// $('<span class="debug-message-object-key"></span>').text(keys[i]).appendTo(entryHeader);
// $('<span>: </span>').appendTo(entryHeader);
// e = $('<span class="debug-message-object-value"></span>').appendTo(entryObj);
// buildMessageElement(obj[keys[i]],keys[i]).appendTo(e);
// }
// $('<div class="debug-message-object-entry"><span class="debug-message-object-key">&hellip;</span></div>').appendTo(element);
} }
if (keys.length === 0) { if (keys.length === 0) {
$('<div class="debug-message-object-entry debug-message-type-meta collapsed"></div>').text("empty").appendTo(element); $('<div class="debug-message-object-entry debug-message-type-meta collapsed"></div>').text("empty").appendTo(element);
} }
if (topLevel) {
if (keys.length === 0) {
$('<span class="debug-message-type-meta">empty</span>').appendTo(headerHead);
}
$('<span> }</span>').appendTo(headerHead);
}
}
} else if (typeof obj === 'string') {
$('<span class="debug-message-object-value debug-message-type-string"></span>').html('"'+formatString(obj)+'"').appendTo(element);
} else { } else {
$('<span class="debug-message-object-value debug-message-type-other"></span>').text(""+obj).appendTo(element); $('<span class="debug-message-type-other"></span>').text(""+obj).appendTo(entryObj);
} }
return element; return element;
} }
// function buildMessageElement(obj,topLevel,typeHint) {
// var i;
// var e;
// var entryObj;
// var header;
// var headerHead;
// var value,subvalue;
// var element = $('<span class="debug-message-element"></span>').toggleClass('collapsed',topLevel);
// if (Array.isArray(obj)) {
// var originalLength = obj.length;
// if (typeHint) {
// var m = /\[(\d+)\]/.exec(typeHint);
// if (m) {
// originalLength = parseInt(m[1]);
// }
// }
// var fullLength = obj.length;
// var length = Math.min(obj.length,10);
// if (!topLevel) {
// header = $('<span class="debug-message-type-meta"></span>').html(typeHint||('array['+obj.length+']')).appendTo(element);
// } else {
// header = $('<span>').appendTo(element);
// if (length > 0) {
// $('<i class="fa fa-caret-right debug-message-object-handle"></i> ').prependTo(header);
// makeExpandable(header);
// }
// $('<span class="debug-message-type-meta debug-message-object-type-header"></span>').html(typeHint||('array['+obj.length+']')).appendTo(header);
// headerHead = $('<span class="debug-message-object-header"></span>').appendTo(header);
// $('<span>[ </span>').appendTo(headerHead);
// }
// var row;
// for (i=0;i<fullLength;i++) {
// if (topLevel) {
// if (i<length) {
// buildMessageSummaryValue(obj[i]).appendTo(headerHead);
// if (i < length -1) {
// $('<span>, </span>').appendTo(headerHead);
// }
// }
// }
// if (fullLength < 10) {
// row = element;
// } else if (fullLength > 10 && (i%10) === 0) {
// var minRange = 10*Math.floor(i/10);
// row = $('<div class="debug-message-object-entry collapsed"></div>').appendTo(element);
// header = $('<span></span>').appendTo(row);
// $('<i class="fa fa-caret-right debug-message-object-handle"></i> ').appendTo(header);
// makeExpandable(header);
// $('<span class="debug-message-object-key"></span>').html("["+minRange+" &hellip; "+Math.min(fullLength-1,(minRange+9))+"]").appendTo(header);
// }
// entryObj = $('<div class="debug-message-object-entry collapsed"></div>').appendTo(row);
//
// header = $('<span></span>').appendTo(entryObj);
// if (typeof obj[i] === 'object' && obj[i] !== null) {
// $('<i class="fa fa-caret-right debug-message-object-handle"></i> ').appendTo(header);
// makeExpandable(header);
// }
// $('<span class="debug-message-object-key"></span>').text(i).appendTo(header);
//
// $('<span>: </span>').appendTo(entryObj);
// e = $('<span class="debug-message-object-value"></span>').appendTo(entryObj);
// buildMessageElement(obj[i],false).appendTo(e);
// }
// if (length < obj.length) {
// if (topLevel) {
// $('<span> &hellip;</span>').appendTo(headerHead);
// }
// //$('<div class="debug-message-object-entry"><span class="debug-message-object-key">&hellip;</span></div>').appendTo(element);
// }
// if (fullLength < originalLength) {
// row = $('<div class="debug-message-object-entry collapsed"></div>').appendTo(element);
// $('<span> &hellip;</span>').appendTo(row);
// }
// if (topLevel) {
// if (length === 0) {
// $('<span class="debug-message-type-meta">empty</span>').appendTo(headerHead);
// }
// $('<span> ]</span>').appendTo(headerHead);
// }
// } else if (obj === null || obj === undefined) {
// $('<span class="debug-message-object-value debug-message-type-null">'+obj+'</span>').appendTo(element);
// } else if (typeof obj === 'object') {
// if (obj.hasOwnProperty('type') && obj.type === 'Buffer' && obj.hasOwnProperty('data')) {
// buildMessageElement(obj.data,false,'buffer['+obj.data.length+']').appendTo(element);
//
// } else {
// var keys = Object.keys(obj);
// if (topLevel) {
// header = $('<span>').appendTo(element);
// if (keys.length > 0) {
// $('<i class="fa fa-caret-right debug-message-object-handle"></i> ').prependTo(header);
// makeExpandable(header);
// }
// } else {
// header = $('<span class="debug-message-type-meta"></span>').html('object').appendTo(element);
// }
// if (topLevel) {
// $('<span class="debug-message-type-meta debug-message-object-type-header"></span>').html('object').appendTo(header);
// headerHead = $('<span class="debug-message-object-header"></span>').appendTo(header);
// $('<span>{ </span>').appendTo(headerHead);
// }
// for (i=0;i<keys.length;i++) {
// if (topLevel) {
// if (i < 5) {
// $('<span class="debug-message-object-key"></span>').text(keys[i]).appendTo(headerHead);
// $('<span>: </span>').appendTo(headerHead);
// buildMessageSummaryValue(obj[keys[i]]).appendTo(headerHead);
// if (i < keys.length -1) {
// $('<span>, </span>').appendTo(headerHead);
// }
// }
// if (i === 5) {
// $('<span> &hellip;</span>').appendTo(headerHead);
// }
// }
// entryObj = $('<div class="debug-message-object-entry collapsed"></div>').appendTo(element);
// var entryHeader = $('<span></span>').appendTo(entryObj);
// $('<span class="debug-message-object-key"></span>').text(keys[i]).appendTo(entryHeader);
// $('<span>: </span>').appendTo(entryHeader);
// e = $('<span class="debug-message-object-value"></span>').appendTo(entryObj);
// if (typeof obj[keys[i]] === 'object' && obj[keys[i]] !== null) {
// $('<i class="fa fa-caret-right debug-message-object-handle"></i> ').prependTo(entryHeader);
// makeExpandable(entryHeader);
// }
// buildMessageElement(obj[keys[i]],false).appendTo(e);
// }
// if (keys.length === 0) {
// $('<div class="debug-message-object-entry debug-message-type-meta collapsed"></div>').text("empty").appendTo(element);
// }
// if (topLevel) {
// if (keys.length === 0) {
// $('<span class="debug-message-type-meta">empty</span>').appendTo(headerHead);
// }
// $('<span> }</span>').appendTo(headerHead);
// }
// }
// } else if (typeof obj === 'string') {
// $('<span class="debug-message-object-value debug-message-type-string"></span>').html('"'+formatString(obj)+'"').appendTo(element);
// } else if (typeof obj === 'number') {
// e = $('<span class="debug-message-object-value debug-message-type-number"></span>').text(""+obj).appendTo(element);
// e.click(function(evt) {
// var format = $(this).data('format');
// if (format === 'hex') {
// $(this).text(""+obj).data('format','dec');
// } else {
// $(this).text("0x"+(obj).toString(16)).data('format','hex');
// }
// evt.preventDefault();
// });
// } else {
// $('<span class="debug-message-object-value debug-message-type-other"></span>').text(""+obj).appendTo(element);
// }
// return element;
// }
function buildMessageBody(obj,el) {
}
function handleDebugMessage(o) { function handleDebugMessage(o) {
var msg = document.createElement("div"); var msg = document.createElement("div");
@ -397,7 +612,7 @@ RED.debug = (function() {
(o.property?'msg.'+property:'msg')+" : "+format+ (o.property?'msg.'+property:'msg')+" : "+format+
'</span>').appendTo(msg); '</span>').appendTo(msg);
} }
if (format === 'Object' || /^array/.test(format) || format === 'boolean' || format === 'number' ) { if (format === 'Object' || /^array/.test(format) || format === 'boolean' || format === 'number'||/error/i.test(format) ) {
payload = JSON.parse(payload); payload = JSON.parse(payload);
} else if (format === 'null') { } else if (format === 'null') {
payload = null; payload = null;
@ -411,7 +626,7 @@ RED.debug = (function() {
} }
} }
var el = $('<span class="debug-message-payload"></span>').appendTo(msg); var el = $('<span class="debug-message-payload"></span>').appendTo(msg);
buildMessageElement(payload,true,format).appendTo(el); buildMessageElement(payload,/*true*/null,format).appendTo(el);
var atBottom = (sbc.scrollHeight-messageList.height()-sbc.scrollTop) < 5; var atBottom = (sbc.scrollHeight-messageList.height()-sbc.scrollTop) < 5;
var m = { var m = {
el: msg el: msg
@ -435,7 +650,7 @@ RED.debug = (function() {
} }
if (messages.length === 100) { if (messages.length === 100) {
var m = messages.shift(); m = messages.shift();
if (view === "list") { if (view === "list") {
m.el.remove(); m.el.remove();
} }

View File

@ -96,7 +96,10 @@
transition: transform 0.1s ease-in-out; transition: transform 0.1s ease-in-out;
transform: rotate(90deg); transform: rotate(90deg);
} }
.debug-message-object-entry>span>.debug-message-object-handle { .debug-message-element:not(.debug-message-top-level)>.debug-message-expandable>.debug-message-object-handle {
margin-left: -1em;
}
.debug-message-object-entry>.debug-message-expandable>.debug-message-object-handle {
margin-left: -1em; margin-left: -1em;
} }
.debug-message-object-entry.collapsed>span>.debug-message-object-handle { .debug-message-object-entry.collapsed>span>.debug-message-object-handle {
@ -106,7 +109,7 @@
transform: rotate(0deg); transform: rotate(0deg);
} }
.debug-message-object-entry.collapsed .debug-message-object-entry { .debug-message-object-entry.collapsed > .debug-message-object-entry {
display:none; display:none;
} }
@ -126,6 +129,7 @@
.debug-message-type-string { color: #b72828; } .debug-message-type-string { color: #b72828; }
.debug-message-type-null { color: #666; font-style: italic;} .debug-message-type-null { color: #666; font-style: italic;}
.debug-message-type-meta { color: #666; font-style: italic;} .debug-message-type-meta { color: #666; font-style: italic;}
.debug-message-type-number { color: #2033d6;cursor: pointer;}
.debug-message-expandable { .debug-message-expandable {
cursor: pointer; cursor: pointer;