11$ ( document ) . ready ( function ( ) {
2- var pathname = window . location . pathname ;
3- var cur_ver = $ ( "#version-slug" ) . text ( ) . replace ( / ^ [ \n \s ] + | [ \n \s ] + $ / g, '' )
4- var major_minor = "master" ;
2+ const pathname = window . location . pathname ;
3+ const cur_ver = $ ( "#version-slug" ) . text ( ) . replace ( / ^ [ \n \s ] + | [ \n \s ] + $ / g, '' )
4+ let major_minor = "master" ;
55 if ( cur_ver . lastIndexOf ( " (dev)" ) == - 1 ) {
66 major_minor = `${ cur_ver . split ( '.' ) [ 0 ] } .${ cur_ver . split ( '.' ) [ 1 ] } `
77 }
8- var relpath = pathname . substring ( pathname . lastIndexOf ( major_minor ) ) . replace ( / \/ $ / , '' ) ;
9- var levels = relpath . split ( "/" ) . length - 1
8+ let relpath = pathname . substring ( pathname . lastIndexOf ( major_minor ) ) . replace ( / \/ $ / , '' ) ;
9+ let levels = relpath . split ( "/" ) . length - 1
1010 if ( levels == 0 ) {
1111 levels = 1
1212 relpath += "/"
1313 }
14- var versions_file = "../" . repeat ( levels ) + "versions.json"
14+ const versions_file = "../" . repeat ( levels ) + "versions.json"
1515 relpath = "../" . repeat ( levels ) + relpath
1616 relpath = relpath . replace ( "//" , "/" )
1717 console . log ( `relpath="${ relpath } ", cur_ver="${ cur_ver } "` )
@@ -20,22 +20,22 @@ $(document).ready(function() {
2020 $ ( "#version-slug" ) . remove ( ) ; // Unnecessary if JSON was downloaded
2121
2222 $ . each ( data [ "tags" ] . reverse ( ) , function ( i , val ) {
23- var new_path = relpath . replace ( major_minor , val )
24- var item = `<li class="toctree-l2"><a class="reference internal" href="${ new_path } ">${ val } </a></li>`
23+ const new_path = relpath . replace ( major_minor , val )
24+ let item = `<li class="toctree-l2"><a class="reference internal" href="${ new_path } ">${ val } </a></li>`
2525 if ( i == 0 ) {
2626 item = `<li class="toctree-l2"><a class="reference internal" href="${ new_path } ">${ val } (Latest Release)</a></li>`
2727 }
2828 $ ( "#v-tags" ) . append ( item )
2929 } ) ;
3030 $ . each ( data [ "heads" ] . reverse ( ) , function ( i , val ) {
31- var new_path = relpath . replace ( major_minor , val )
32- var item = `<li class="toctree-l2"><a class="reference internal" href="${ new_path } ">${ val } </a></li>`
33- if ( val == "master" ) {
31+ const new_path = relpath . replace ( major_minor , val )
32+ let item = `<li class="toctree-l2"><a class="reference internal" href="${ new_path } ">${ val } </a></li>`
33+ if ( [ "master" , "main" ] . includes ( val ) ) {
3434 item = `<li class="toctree-l2"><a class="reference internal" href="${ new_path } ">${ val } (Development)</a></li>`
3535 }
3636 $ ( "#v-tags" ) . append ( item )
3737 } ) ;
3838 } ) . fail ( function ( ) {
3939 $ ( "#version-menu" ) . hide ( ) ; // JSON download failed - hide dropdown
4040 } ) ;
41- } ) ;
41+ } ) ;
0 commit comments