From b1b7edd9a9060ae331ab88a78b03670c75188f8a Mon Sep 17 00:00:00 2001 From: peteriman Date: Wed, 4 Mar 2020 17:04:26 +0800 Subject: [PATCH] UI Enhancements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before: `{ "array" : [ … ], "data" : { … }, "emptyArray": [ ], "emptyObject": { } }` After: `{ "array" : [ Array( 10 ) ], "data" : { Object }, "emptyArray": [ ], "emptyObject": { } }` --- libs/jsonTree/jsonTree.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/jsonTree/jsonTree.js b/libs/jsonTree/jsonTree.js index 51bbf01..7b32133 100644 --- a/libs/jsonTree/jsonTree.js +++ b/libs/jsonTree/jsonTree.js @@ -438,6 +438,8 @@ var jsonTree = (function() { throw new Error('This is abstract class'); } + var showMoreSymbol = (Array.isArray(val)) ? "Array( " + val.length + " )" : "Object"; // … + var self = this, el = document.createElement('li'), template = function(label, sym) { @@ -446,7 +448,7 @@ var jsonTree = (function() {
\
\ ' + sym[0] + '\ - \ + ' + showMoreSymbol + '\
    \ ' + sym[1] + '' + '
    ' + comma + @@ -742,7 +744,7 @@ var jsonTree = (function() { */ expand : function(filterFunc) { if (this.rootNode.isComplex) { - if (typeof filterFunc == 'function') { + if (typeof filterFunc === 'function') { this.rootNode.childNodes.forEach(function(item, i) { if (item.isComplex && filterFunc(item)) { item.expand();