@@ -104,20 +104,21 @@ async function drawList(dom, lst, opt) {
104104 return null ;
105105
106106 const handle = {
107- dom, lst, opt,
108- indx : - 1 , painter : null ,
109- draw_next ( ) {
110- while ( ++ this . indx < this . lst . arr . length ) {
111- const item = this . lst . arr [ this . indx ] ,
112- opt = ( this . lst . opt && this . lst . opt [ this . indx ] ) ? this . lst . opt [ this . indx ] : this . opt ;
113- if ( ! item ) continue ;
114- return draw ( this . dom , item , opt ) . then ( p => {
115- if ( p && ! this . painter ) this . painter = p ;
116- return this . draw_next ( ) ; // reenter loop
117- } ) ;
118- }
119- return this . painter ;
120- }
107+ dom, lst, opt,
108+ indx : - 1 , painter : null ,
109+ draw_next ( ) {
110+ while ( ++ this . indx < this . lst . arr . length ) {
111+ const item = this . lst . arr [ this . indx ] ,
112+ opt2 = ( this . lst . opt && this . lst . opt [ this . indx ] ) ? this . lst . opt [ this . indx ] : this . opt ;
113+ if ( ! item )
114+ continue ;
115+ return draw ( this . dom , item , opt2 ) . then ( p => {
116+ if ( p && ! this . painter ) this . painter = p ;
117+ return this . draw_next ( ) ; // reenter loop
118+ } ) ;
119+ }
120+ return this . painter ;
121+ }
121122 } ;
122123
123124 return handle . draw_next ( ) ;
@@ -799,52 +800,55 @@ class HierarchyPainter extends BasePainter {
799800 folder . _had_direct_read = false ;
800801 // this is central get method, item or itemname can be used, returns promise
801802 folder . _get = function ( item , itemname ) {
802- if ( item ?. _readobj )
803- return Promise . resolve ( item . _readobj ) ;
804-
805- if ( item ) itemname = painter . itemFullName ( item , this ) ;
806-
807- const readFileObject = file => {
808- if ( ! this . _file ) this . _file = file ;
809-
810- if ( ! file ) return Promise . resolve ( null ) ;
811-
812- return file . readObject ( itemname ) . then ( obj => {
813- // if object was read even when item did not exist try to reconstruct new hierarchy
814- if ( ! item && obj ) {
815- // first try to found last read directory
816- const d = painter . findItem ( { name : itemname , top : this , last_exists : true , check_keys : true } ) ;
817- if ( ( d ?. last !== undefined ) && ( d . last !== this ) ) {
818- // reconstruct only sub-directory hierarchy
819- const dir = file . getDir ( painter . itemFullName ( d . last , this ) ) ;
820- if ( dir ) {
821- d . last . _name = d . last . _keyname ;
822- const dirname = painter . itemFullName ( d . last , this ) ;
823- keysHierarchy ( d . last , dir . fKeys , file , dirname + '/' ) ;
824- }
825- } else {
826- // reconstruct full file hierarchy
827- keysHierarchy ( this , file . fKeys , file , '' ) ;
803+ if ( item ?. _readobj )
804+ return Promise . resolve ( item . _readobj ) ;
805+
806+ if ( item )
807+ itemname = painter . itemFullName ( item , this ) ;
808+
809+ const readFileObject = file2 => {
810+ if ( ! this . _file )
811+ this . _file = file2 ;
812+
813+ if ( ! file2 )
814+ return Promise . resolve ( null ) ;
815+
816+ return file2 . readObject ( itemname ) . then ( obj => {
817+ // if object was read even when item did not exist try to reconstruct new hierarchy
818+ if ( ! item && obj ) {
819+ // first try to found last read directory
820+ const d = painter . findItem ( { name : itemname , top : this , last_exists : true , check_keys : true } ) ;
821+ if ( ( d ?. last !== undefined ) && ( d . last !== this ) ) {
822+ // reconstruct only sub-directory hierarchy
823+ const dir = file2 . getDir ( painter . itemFullName ( d . last , this ) ) ;
824+ if ( dir ) {
825+ d . last . _name = d . last . _keyname ;
826+ const dirname = painter . itemFullName ( d . last , this ) ;
827+ keysHierarchy ( d . last , dir . fKeys , file2 , dirname + '/' ) ;
828828 }
829- item = painter . findItem ( { name : itemname , top : this } ) ;
830- }
831-
832- if ( item ) {
833- item . _readobj = obj ;
834- // remove cycle number for objects supporting expand
835- if ( '_expand' in item ) item . _name = item . _keyname ;
829+ } else {
830+ // reconstruct full file hierarchy
831+ keysHierarchy ( this , file2 . fKeys , file2 , '' ) ;
836832 }
833+ item = painter . findItem ( { name : itemname , top : this } ) ;
834+ }
837835
838- return obj ;
839- } ) ;
840- } ;
836+ if ( item ) {
837+ item . _readobj = obj ;
838+ // remove cycle number for objects supporting expand
839+ if ( '_expand' in item ) item . _name = item . _keyname ;
840+ }
841841
842- if ( this . _file ) return readFileObject ( this . _file ) ;
843- if ( this . _localfile ) return openFile ( this . _localfile ) . then ( f => readFileObject ( f ) ) ;
844- if ( this . _fullurl ) return openFile ( this . _fullurl ) . then ( f => readFileObject ( f ) ) ;
845- return Promise . resolve ( null ) ;
842+ return obj ;
843+ } ) ;
846844 } ;
847845
846+ if ( this . _file ) return readFileObject ( this . _file ) ;
847+ if ( this . _localfile ) return openFile ( this . _localfile ) . then ( f => readFileObject ( f ) ) ;
848+ if ( this . _fullurl ) return openFile ( this . _fullurl ) . then ( f => readFileObject ( f ) ) ;
849+ return Promise . resolve ( null ) ;
850+ } ;
851+
848852 keysHierarchy ( folder , file . fKeys , file , '' ) ;
849853
850854 return folder ;
@@ -2473,7 +2477,7 @@ class HierarchyPainter extends BasePainter {
24732477 if ( items [ cnt ] === null ) continue ; // ignore completed item
24742478 if ( items_wait [ cnt ] && items . indexOf ( items [ cnt ] ) === cnt ) {
24752479 items_wait [ cnt ] = false ;
2476- return h . display ( items [ cnt ] , options [ cnt ] , doms [ cnt ] ) . then ( painter => dropNextItem ( cnt , painter ) ) ;
2480+ return h . display ( items [ cnt ] , options [ cnt ] , doms [ cnt ] ) . then ( drop_painter => dropNextItem ( cnt , drop_painter ) ) ;
24772481 }
24782482 }
24792483 }
@@ -2682,17 +2686,20 @@ class HierarchyPainter extends BasePainter {
26822686 return ;
26832687 }
26842688
2685- if ( hitem . _obj ) promise = doExpandItem ( hitem , hitem . _obj ) ;
2689+ if ( hitem . _obj )
2690+ promise = doExpandItem ( hitem , hitem . _obj ) ;
26862691 }
26872692
26882693 return promise . then ( res => {
2689- if ( res !== - 1 ) return res ; // done
2694+ if ( res !== - 1 )
2695+ return res ; // done
26902696
26912697 showProgress ( 'Loading ' + itemname ) ;
26922698
2693- return this . getObject ( itemname , silent ? 'hierarchy_expand' : 'hierarchy_expand_verbose' ) . then ( res => {
2699+ return this . getObject ( itemname , silent ? 'hierarchy_expand' : 'hierarchy_expand_verbose' ) . then ( res2 => {
26942700 showProgress ( ) ;
2695- if ( res . obj ) return doExpandItem ( res . item , res . obj ) . then ( res => { return ( res !== - 1 ) ? res : undefined ; } ) ;
2701+ if ( res2 . obj )
2702+ return doExpandItem ( res2 . item , res2 . obj ) . then ( res3 => { return res3 !== - 1 ? res3 : undefined ; } ) ;
26962703 } ) ;
26972704 } ) ;
26982705 }
@@ -2737,17 +2744,17 @@ class HierarchyPainter extends BasePainter {
27372744 this . forEachJsonFile ( item => { if ( item . _jsonfile === filepath ) isfileopened = true ; } ) ;
27382745 if ( isfileopened ) return ;
27392746
2740- return httpRequest ( filepath , 'object' ) . then ( res => {
2741- if ( ! res ) return ;
2742- const h1 = { _jsonfile : filepath , _kind : prROOT + res . _typename , _jsontmp : res , _name : filepath . split ( '/' ) . pop ( ) } ;
2743- if ( res . fTitle ) h1 . _title = res . fTitle ;
2747+ return httpRequest ( filepath , 'object' ) . then ( res2 => {
2748+ if ( ! res2 ) return ;
2749+ const h1 = { _jsonfile : filepath , _kind : prROOT + res2 . _typename , _jsontmp : res2 , _name : filepath . split ( '/' ) . pop ( ) } ;
2750+ if ( res2 . fTitle ) h1 . _title = res2 . fTitle ;
27442751 h1 . _get = function ( item /* ,itemname */ ) {
27452752 if ( item . _jsontmp )
27462753 return Promise . resolve ( item . _jsontmp ) ;
27472754 return httpRequest ( item . _jsonfile , 'object' )
2748- . then ( res => {
2749- item . _jsontmp = res ;
2750- return res ;
2755+ . then ( res3 => {
2756+ item . _jsontmp = res3 ;
2757+ return res3 ;
27512758 } ) ;
27522759 } ;
27532760 if ( ! this . h )
@@ -2868,13 +2875,13 @@ class HierarchyPainter extends BasePainter {
28682875 h . _childs . push ( {
28692876 _name : fname , _title : dirname + fname , _jsonfile : dirname + fname , _can_draw : true ,
28702877 _get : item => {
2871- return httpRequest ( item . _jsonfile , 'object' ) . then ( res => {
2872- if ( res ) {
2873- item . _kind = prROOT + res . _typename ;
2874- item . _jsontmp = res ;
2878+ return httpRequest ( item . _jsonfile , 'object' ) . then ( res2 => {
2879+ if ( res2 ) {
2880+ item . _kind = prROOT + res2 . _typename ;
2881+ item . _jsontmp = res2 ;
28752882 this . updateTreeNode ( item ) ;
28762883 }
2877- return res ;
2884+ return res2 ;
28782885 } ) ;
28792886 }
28802887 } ) ;
@@ -4009,16 +4016,16 @@ async function drawInspector(dom, obj, opt) {
40094016 if ( sett . opts ) {
40104017 menu . addDrawMenu ( 'nosub:Draw' , sett . opts , arg => {
40114018 if ( ! hitem ?. _obj ) return ;
4012- const obj = hitem . _obj ;
4019+ const obj2 = hitem . _obj ;
40134020 let ddom = this . selectDom ( ) . node ( ) ;
40144021 if ( isFunc ( this . removeInspector ) ) {
40154022 ddom = ddom . parentNode ;
40164023 this . removeInspector ( ) ;
40174024 if ( arg . indexOf ( kInspect ) === 0 )
4018- return this . showInspector ( arg , obj ) ;
4025+ return this . showInspector ( arg , obj2 ) ;
40194026 }
40204027 cleanup ( ddom ) ;
4021- draw ( ddom , obj , arg ) ;
4028+ draw ( ddom , obj2 , arg ) ;
40224029 } ) ;
40234030 }
40244031 } ;
0 commit comments