12
12
border : solid 1px # eee ;
13
13
margin-bottom : 5px ;
14
14
}
15
- .registers {
16
- display : none;
17
- }
18
15
.bitfield td , .bitfield th {
19
16
text-align : center;
20
17
}
118
115
{{ peripheral.fields_documented }}/{{peripheral.fields_total }}
119
116
fields covered.
120
117
</ em >
121
- < a class ="toggle-registers " href ="# "> Toggle Registers</ a >
122
118
</ p >
123
119
< details class ="register-map " id ="{{ pname }}-register-map ">
124
120
< summary > Toggle register map</ summary >
152
148
{% endfor %}
153
149
</ tbody > </ table >
154
150
</ details >
155
- < div class ="container registers " id ="{{ pname }}-registers ">
151
+ < details class ="registers " id ="{{ pname }}-registers ">
152
+ < summary > Toggle registers</ summary >
156
153
{% for register in peripheral.registers %}
157
154
< div class ="row ">
158
155
< div class ="col-sm-11 register ">
242
239
</ div >
243
240
</ div >
244
241
{% endfor %}
245
- </ div >
242
+ </ details >
246
243
</ div >
247
244
</ div >
248
245
{% endfor %}
@@ -252,39 +249,34 @@ <h4>
252
249
< script src ="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js " integrity ="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa " crossorigin ="anonymous "> </ script >
253
250
254
251
< script >
255
- $ ( '.toggle-registers' ) . click ( function ( e ) {
256
- $ ( this ) . parent ( ) . siblings ( ".registers" ) . toggle ( ) ;
257
- e . preventDefault ( ) ;
258
- } ) ;
259
- $ ( '#show-all-registers' ) . click ( function ( e ) {
260
- $ ( '.registers' ) . show ( ) ;
261
- e . preventDefault ( ) ;
262
- } ) ;
263
- $ ( '#hide-all-registers' ) . click ( function ( e ) {
264
- $ ( '.registers' ) . hide ( ) ;
265
- e . preventDefault ( ) ;
266
- } ) ;
252
+ document . getElementById ( 'show-all-registers' ) . addEventListener ( 'click' , e => {
253
+ document . querySelectorAll ( '.registers' ) . forEach ( el => el . open = true )
254
+ e . preventDefault ( )
255
+ } )
256
+ document . getElementById ( 'hide-all-registers' ) . addEventListener ( 'click' , e => {
257
+ document . querySelectorAll ( '.registers' ) . forEach ( el => el . open = false )
258
+ e . preventDefault ( )
259
+ } )
267
260
$ ( '.fieldlink' ) . click ( function ( e ) {
268
261
$ ( this ) . parents ( ".container" ) . first ( ) . siblings ( ".fields" ) . show ( ) ;
269
262
} ) ;
270
263
$ ( '.toggle-fields' ) . click ( function ( e ) {
271
264
$ ( this ) . parents ( ".container" ) . first ( ) . siblings ( ".fields" ) . toggle ( ) ;
272
265
e . preventDefault ( ) ;
273
266
} ) ;
274
- if ( window . location . hash && window . location . hash . includes ( ":" ) ) {
275
- var hash = window . location . hash ;
276
- var parts = hash . substr ( 1 ) . split ( ":" ) ;
277
- var peripheral = parts [ 0 ] ;
278
- var register = parts [ 1 ] ;
279
- $ ( '#' + peripheral + '-registers' ) . show ( 0 , function ( ) {
280
- if ( parts . length == 3 ) {
281
- $ ( '#' + peripheral + '-' + register + '-fields' ) . show ( 0 , function ( ) {
282
- window . location . hash = hash ;
283
- } ) ;
284
- } else {
285
- window . location . hash = hash ;
286
- }
287
- } ) ;
267
+ if ( window . location . hash ?. includes ( ":" ) ) {
268
+ const hash = window . location . hash ;
269
+ const [ peripheral , register , field ] = hash . substr ( 1 ) . split ( ":" , 3 )
270
+ if ( document . getElementById ( `${ peripheral } -registers` ) ) {
271
+ document . getElementById ( `${ peripheral } -registers` ) . open = true
272
+ }
273
+ if ( field ) {
274
+ $ ( '#' + peripheral + '-' + register + '-fields' ) . show ( 0 , function ( ) {
275
+ window . location . hash = hash
276
+ } )
277
+ } else {
278
+ window . location . hash = hash
279
+ }
288
280
}
289
281
$ ( function ( ) {
290
282
$ ( '[data-toggle="popover"]' ) . popover ( )
0 commit comments