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

debug - format if time if correct length/range

This commit is contained in:
Dave Conway-Jones 2016-11-28 17:28:49 +00:00
parent 52fc497412
commit 671d7e2beb

View File

@ -111,14 +111,18 @@ RED.utils = (function() {
} else if (typeof obj === 'number') { } else if (typeof obj === 'number') {
e = $('<span class="debug-message-type-number"></span>').text(""+obj).appendTo(entryObj); e = $('<span class="debug-message-type-number"></span>').text(""+obj).appendTo(entryObj);
if ((obj^0)===obj) { if (Number.isInteger(obj) && (obj >= 0)) { // if it's a +ve integer
e.addClass("debug-message-type-number-toggle"); e.addClass("debug-message-type-number-toggle");
e.click(function(evt) { e.click(function(evt) {
var format = $(this).data('format'); var format = $(this).data('format') || "date";
if (format === 'hex') { if (format === 'dec') {
$(this).text(""+obj).data('format','dec'); $(this).text(""+obj).data('format','date');
} else if ((format === 'date') && (obj.toString().length===13) && (obj<=2147483647000)) {
$(this).text((new Date(obj)).toISOString()).data('format','hex');
} else if ((format === 'date') && (obj.toString().length===10) && (obj<=2147483647)) {
$(this).text((new Date(obj*1000)).toISOString()).data('format','hex');
} else { } else {
$(this).text("0x"+(obj).toString(16)).data('format','hex'); $(this).text("0x"+(obj).toString(16)).data('format','dec');
} }
evt.preventDefault(); evt.preventDefault();
}); });