mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Provide string view of buffers in debug messages
This commit is contained in:
parent
06ee9aa05c
commit
74b6d9dff9
@ -287,39 +287,46 @@ RED.debug = (function() {
|
|||||||
|
|
||||||
if (originalLength > 0) {
|
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);
|
||||||
|
var arrayRows = $('<div class="debug-message-array-rows"></div>').appendTo(element);
|
||||||
makeExpandable(header,function() {
|
makeExpandable(header,function() {
|
||||||
if (!key) {
|
if (!key) {
|
||||||
var headerHead = $('<span class="debug-message-type-meta debug-message-object-type-header"></span>').html(typeHint||(type+'['+originalLength+']')).appendTo(header);
|
headerHead = $('<span class="debug-message-type-meta debug-message-object-type-header"></span>').html(typeHint||(type+'['+originalLength+']')).appendTo(header);
|
||||||
if (type === 'buffer') {
|
|
||||||
// var bufferOpts = $('<span class="debug-message-buffer-opts"></span>').appendTo(headerHead);
|
|
||||||
// //dec hex string
|
|
||||||
// $('<a href="#"></a>').addClass('selected').html('dec').appendTo(bufferOpts).click(function(e) {
|
|
||||||
// $(this).addClass('selected').siblings().removeClass('selected');
|
|
||||||
// e.preventDefault();
|
|
||||||
// e.stopPropagation();
|
|
||||||
// })
|
|
||||||
// $('<a href="#"></a>').html('hex').appendTo(bufferOpts).click(function(e) {
|
|
||||||
// $(this).addClass('selected').siblings().removeClass('selected');
|
|
||||||
// e.preventDefault();
|
|
||||||
// e.stopPropagation();
|
|
||||||
// })
|
|
||||||
// $('<a href="#"></a>').html('string').appendTo(bufferOpts).click(function(e) {
|
|
||||||
// $(this).addClass('selected').siblings().removeClass('selected');
|
|
||||||
// e.preventDefault();
|
|
||||||
// e.stopPropagation();
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
|
if (type === 'buffer') {
|
||||||
|
var stringRow = $('<div class="debug-message-object-entry collapsed"></div>').hide().appendTo(element);
|
||||||
|
var sr = $('<div class="debug-message-array-rows"></div>').appendTo(stringRow);
|
||||||
|
var stringEncoding = "";
|
||||||
|
try {
|
||||||
|
stringEncoding = String.fromCharCode.apply(null, new Uint16Array(data))
|
||||||
|
} catch(err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
$('<pre class="debug-message-type-string"></pre>').html(stringEncoding).appendTo(sr);
|
||||||
|
var bufferOpts = $('<span class="debug-message-buffer-opts"></span>').appendTo(headerHead);
|
||||||
|
$('<a href="#"></a>').addClass('selected').html('raw').appendTo(bufferOpts).click(function(e) {
|
||||||
|
if ($(this).text() === 'raw') {
|
||||||
|
$(this).text('string');
|
||||||
|
arrayRows.hide();
|
||||||
|
stringRow.show();
|
||||||
|
} else {
|
||||||
|
$(this).text('raw');
|
||||||
|
arrayRows.show();
|
||||||
|
stringRow.hide();
|
||||||
|
}
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
var row;
|
var row;
|
||||||
if (fullLength <= 10) {
|
if (fullLength <= 10) {
|
||||||
for (i=0;i<fullLength;i++) {
|
for (i=0;i<fullLength;i++) {
|
||||||
row = $('<div class="debug-message-object-entry collapsed"></div>').appendTo(element);
|
row = $('<div class="debug-message-object-entry collapsed"></div>').appendTo(arrayRows);
|
||||||
buildMessageElement(data[i],""+i,false).appendTo(row);
|
buildMessageElement(data[i],""+i,false).appendTo(row);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i=0;i<fullLength;i+=10) {
|
for (i=0;i<fullLength;i+=10) {
|
||||||
var minRange = i;
|
var minRange = i;
|
||||||
row = $('<div class="debug-message-object-entry collapsed"></div>').appendTo(element);
|
row = $('<div class="debug-message-object-entry collapsed"></div>').appendTo(arrayRows);
|
||||||
header = $('<span></span>').appendTo(row);
|
header = $('<span></span>').appendTo(row);
|
||||||
$('<i class="fa fa-caret-right debug-message-object-handle"></i> ').appendTo(header);
|
$('<i class="fa fa-caret-right debug-message-object-handle"></i> ').appendTo(header);
|
||||||
makeExpandable(header, (function() {
|
makeExpandable(header, (function() {
|
||||||
@ -336,13 +343,13 @@ RED.debug = (function() {
|
|||||||
$('<span class="debug-message-object-key"></span>').html("["+minRange+" … "+Math.min(fullLength-1,(minRange+9))+"]").appendTo(header);
|
$('<span class="debug-message-object-key"></span>').html("["+minRange+" … "+Math.min(fullLength-1,(minRange+9))+"]").appendTo(header);
|
||||||
}
|
}
|
||||||
if (fullLength < originalLength) {
|
if (fullLength < originalLength) {
|
||||||
$('<div class="debug-message-object-entry collapsed"><span class="debug-message-object-key">['+fullLength+' … '+originalLength+']</span></div>').appendTo(element);
|
$('<div class="debug-message-object-entry collapsed"><span class="debug-message-object-key">['+fullLength+' … '+originalLength+']</span></div>').appendTo(arrayRows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (key) {
|
if (key) {
|
||||||
$('<span class="debug-message-type-meta"></span>').html(typeHint||(type+'['+originalLength+']')).appendTo(entryObj);
|
headerHead = $('<span class="debug-message-type-meta f"></span>').html(typeHint||(type+'['+originalLength+']')).appendTo(entryObj);
|
||||||
} else {
|
} else {
|
||||||
headerHead = $('<span class="debug-message-object-header"></span>').appendTo(entryObj);
|
headerHead = $('<span class="debug-message-object-header"></span>').appendTo(entryObj);
|
||||||
$('<span>[ </span>').appendTo(headerHead);
|
$('<span>[ </span>').appendTo(headerHead);
|
||||||
|
@ -119,6 +119,9 @@
|
|||||||
.debug-message-element:not(.collapsed)>.debug-message-expandable>.debug-message-object-value>.debug-message-object-header {
|
.debug-message-element:not(.collapsed)>.debug-message-expandable>.debug-message-object-value>.debug-message-object-header {
|
||||||
display:none;
|
display:none;
|
||||||
}
|
}
|
||||||
|
.debug-message-element.collapsed .debug-message-buffer-opts {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.debug-message-element.collapsed .debug-message-object-type-header {
|
.debug-message-element.collapsed .debug-message-object-type-header {
|
||||||
display:none;
|
display:none;
|
||||||
@ -154,11 +157,6 @@
|
|||||||
padding: 2px 5px;
|
padding: 2px 5px;
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
}
|
}
|
||||||
.debug-message-buffer-opts a.selected {
|
|
||||||
background: #eee;
|
|
||||||
color: #999;
|
|
||||||
border: 1px solid #999;
|
|
||||||
}
|
|
||||||
.debug-message-buffer-opts a:hover {
|
.debug-message-buffer-opts a:hover {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: #999;
|
color: #999;
|
||||||
|
Loading…
Reference in New Issue
Block a user