@@ -49,7 +49,7 @@ class DOM {
49
49
async createHeaderContent ( h ) {
50
50
// this.log.debug(`createHeaderContent (${h.self.id.join()})`, e, elem, h)
51
51
let empty = true
52
- let elem = this . indexElems . get ( h . self . id )
52
+ let elem = this . indexElems . get ( h . self )
53
53
54
54
if ( h . classes && h . classes . length ) {
55
55
empty = false
@@ -92,19 +92,19 @@ class DOM {
92
92
if ( empty ) {
93
93
elem . addClass ( 'empty' )
94
94
}
95
- this . lazyLoaders . set ( h . self . id , async ( ) => await this . getHeader ( h ) )
95
+ this . lazyLoaders . set ( h . self , async ( ) => await this . getHeader ( h ) )
96
96
}
97
97
98
98
async getHeader ( h ) {
99
99
// this.log.debug(`getHeader (${h.self.id.join()})`, h)
100
- return true // this.lazyLoaders.get(h.self.id )
100
+ return true // this.lazyLoaders.get(h.self)
101
101
}
102
102
103
- async doExpand ( id ) {
103
+ async doExpand ( idx ) {
104
104
// this.log.debug(`doExpand '${id.join()}'`, id)
105
105
106
- await this . lazyLoaders . get ( id ) ( )
107
- let elem = this . indexElems . get ( id )
106
+ await this . lazyLoaders . get ( idx ) ( )
107
+ let elem = this . indexElems . get ( idx )
108
108
// let content_wrapper = elem.closest('.content-wrapper')
109
109
// let content = content_wrapper.children('.content')
110
110
@@ -141,10 +141,10 @@ class DOM {
141
141
}
142
142
}
143
143
144
- async scrollAt ( id ) {
145
- this . log . info ( `scrollAt '${ id . join ( ) } '` , id )
144
+ async scrollAt ( idx ) {
145
+ this . log . info ( `scrollAt '${ idx . id . join ( ) } '` , idx . id )
146
146
147
- const e = this . indexElems . get ( id )
147
+ const e = this . indexElems . get ( idx )
148
148
const broot = e . closest ( '.kunai-branch' )
149
149
const croot = broot . closest ( '.content' )
150
150
let wrapper = croot . closest ( '.content-wrapper' )
@@ -190,7 +190,7 @@ class DOM {
190
190
let li = $ ( '<li>' , { class : 'article' } ) . append (
191
191
$ ( '<a>' , { href : idx . url ( ) } ) . text ( idx . id . join ( ) )
192
192
)
193
- this . indexElems . set ( idx . id , li )
193
+ this . indexElems . set ( idx , li )
194
194
return li
195
195
}
196
196
@@ -200,7 +200,7 @@ class DOM {
200
200
$ ( '<a>' , { href : m . url ( ) } )
201
201
. html ( await m . join_html ( DOM . crOptions ) )
202
202
)
203
- this . indexElems . set ( m . id , li )
203
+ this . indexElems . set ( m , li )
204
204
205
205
if ( this . kc . getPriorityForIndex ( m ) . index !== this . kc . prioSpecials . get ( '__functions__' ) . index ) {
206
206
li . addClass ( 'special' )
@@ -210,7 +210,7 @@ class DOM {
210
210
211
211
async makeClass ( c ) {
212
212
let li = $ ( '<li>' , { class : 'class classy' } )
213
- this . indexElems . set ( c . self . id , li )
213
+ this . indexElems . set ( c . self , li )
214
214
215
215
$ ( '<a>' , { class : 'self' } ) . attr ( 'href' , c . self . url ( ) ) . html (
216
216
await c . self . join_html ( DOM . crClassOptions )
@@ -233,7 +233,7 @@ class DOM {
233
233
234
234
async makeOther ( o ) {
235
235
let li = $ ( '<li>' , { class : `other ${ o . id . type } ` } )
236
- this . indexElems . set ( o . id , li )
236
+ this . indexElems . set ( o , li )
237
237
238
238
if ( IndexID . isClassy ( o . id . type ) ) {
239
239
li . addClass ( 'classy' )
@@ -261,17 +261,17 @@ class DOM {
261
261
262
262
async makeExpandable ( elem , obj ) {
263
263
// this.log.debug(`makeExpandable '${obj.self.id.join()}'`, elem, obj)
264
- this . indexElems . set ( obj . self . id , elem )
264
+ this . indexElems . set ( obj . self , elem )
265
265
this . lazyLoaders . set (
266
- obj . self . id ,
266
+ obj . self ,
267
267
async ( ) => { await this . createContent ( obj ) }
268
268
)
269
269
270
270
let bar = $ ( '<div>' , { class : 'expandbar' } ) . appendTo ( elem )
271
271
272
272
bar . append (
273
273
$ ( '<div>' , { class : 'expander' } ) . on ( 'click' , async ( ) => {
274
- await this . doExpand ( obj . self . id )
274
+ await this . doExpand ( obj . self )
275
275
} )
276
276
)
277
277
@@ -329,27 +329,21 @@ class Treeview {
329
329
const h = this . page_idx . in_header
330
330
this . log . info ( `expanding current page header '${ h . id . join ( ) } '` , h , this . page_idx )
331
331
332
- await this . dom . doExpand ( h . id )
332
+ await this . dom . doExpand ( h )
333
333
} else {
334
334
if ( IType . isHeader ( this . page_idx . id . type ) ) {
335
- await this . dom . doExpand ( this . page_idx . id )
335
+ await this . dom . doExpand ( this . page_idx )
336
336
} else {
337
337
this . log . info ( `current page '${ this . page_idx . id . join ( ) } ' is not classy. nothing left to expand` )
338
338
}
339
339
}
340
340
341
341
if ( ids . length > 1 ) {
342
- if ( this . page_idx . id . type === 'article' && this . page_idx . id . indexes . length > 1 ) {
343
- const selector = `[data-lang-id="C++${ this . page_idx . cpp_version } "] li.article`
344
- const article = [ ...$ ( selector ) ] . find ( li => li . innerText === this . page_idx . name )
345
- this . dom . indexElems . set ( this . page_idx . id , $ ( article ) )
346
- }
347
-
348
342
// highlight self
349
- this . dom . indexElems . get ( this . page_idx . id ) . addClass ( 'current-page' )
343
+ this . dom . indexElems . get ( this . page_idx ) . addClass ( 'current-page' )
350
344
351
345
// finally, always scroll to self
352
- await this . dom . scrollAt ( this . page_idx . id )
346
+ await this . dom . scrollAt ( this . page_idx )
353
347
}
354
348
} catch ( e ) {
355
349
this . log . error ( `Failed to determine current page for id '${ ids . join ( '/' ) } '. Sidebar will NOT work properly! (${ e } )` , ids )
0 commit comments