1- function assign_href ( a , url , path ) {
2- fetch ( url + "/" + path ) . then ( response => {
3- if ( response . ok ) {
1+ function assign_href ( a , url , path ) {
2+ fetch ( url + "/" + path ) . then ( response => {
3+ if ( response . ok ) {
44 a . href = url + "/" + path ;
5- }
6- else {
5+ } else {
76 a . href = url + "/index.html" ;
87 }
9- } ) . catch ( error => {
8+ } ) . catch ( error => {
109 a . href = url + "/index.html" ;
1110 } ) ;
1211}
@@ -22,17 +21,16 @@ function add_version_dropdown(json_loc, target_loc, text) {
2221 dropdown . appendChild ( content ) ;
2322 $ . getJSON ( json_loc , function ( versions ) {
2423 var currentURL = window . location . href ;
25- var path = currentURL . split ( "_site" ) [ 1 ] ;
26- path = path . split ( '/' ) ;
24+ var path = currentURL . split ( "_site" ) [ 1 ] ;
25+ path = path . split ( "/" ) ;
2726 path = path . slice ( 2 , path . length ) ;
28- path = path . join ( '/' ) ;
27+ path = path . join ( "/" ) ;
2928 for ( var key in versions ) {
3029 if ( versions . hasOwnProperty ( key ) ) {
31- console . log ( key , versions [ key ] ) ;
3230 var a = document . createElement ( "a" ) ;
3331 a . innerHTML = key ;
3432 a . title = key ;
35- assign_href ( a , target_loc + versions [ key ] , path ) ;
33+ assign_href ( a , target_loc + versions [ key ] , path ) ;
3634 content . appendChild ( a ) ;
3735 }
3836 }
0 commit comments