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

Better toggling between raw/string views of buffers

This commit is contained in:
Nick O'Leary 2016-11-02 16:17:56 +00:00
parent 74b6d9dff9
commit 3489fe0cf4
2 changed files with 11 additions and 6 deletions

View File

@ -288,13 +288,14 @@ 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); var arrayRows = $('<div class="debug-message-array-rows"></div>').appendTo(element);
element.addClass('debug-message-buffer-raw');
makeExpandable(header,function() { makeExpandable(header,function() {
if (!key) { if (!key) {
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') { if (type === 'buffer') {
var stringRow = $('<div class="debug-message-object-entry collapsed"></div>').hide().appendTo(element); var stringRow = $('<div class="debug-message-string-rows"></div>').appendTo(element);
var sr = $('<div class="debug-message-array-rows"></div>').appendTo(stringRow); var sr = $('<div class="debug-message-object-entry collapsed"></div>').appendTo(stringRow);
var stringEncoding = ""; var stringEncoding = "";
try { try {
stringEncoding = String.fromCharCode.apply(null, new Uint16Array(data)) stringEncoding = String.fromCharCode.apply(null, new Uint16Array(data))
@ -306,12 +307,10 @@ RED.debug = (function() {
$('<a href="#"></a>').addClass('selected').html('raw').appendTo(bufferOpts).click(function(e) { $('<a href="#"></a>').addClass('selected').html('raw').appendTo(bufferOpts).click(function(e) {
if ($(this).text() === 'raw') { if ($(this).text() === 'raw') {
$(this).text('string'); $(this).text('string');
arrayRows.hide(); element.addClass('debug-message-buffer-string').removeClass('debug-message-buffer-raw');
stringRow.show();
} else { } else {
$(this).text('raw'); $(this).text('raw');
arrayRows.show(); element.removeClass('debug-message-buffer-string').addClass('debug-message-buffer-raw');
stringRow.hide();
} }
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();

View File

@ -163,3 +163,9 @@
border: 1px solid #999; border: 1px solid #999;
background: #f3f3f3; background: #f3f3f3;
} }
.debug-message-buffer-raw > .debug-message-string-rows {
display: none;
}
.debug-message-buffer-string > .debug-message-array-rows {
display: none;
}