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 ) {
4
4
a . href = url + "/" + path ;
5
- }
6
- else {
5
+ } else {
7
6
a . href = url + "/index.html" ;
8
7
}
9
- } ) . catch ( error => {
8
+ } ) . catch ( error => {
10
9
a . href = url + "/index.html" ;
11
10
} ) ;
12
11
}
@@ -22,17 +21,16 @@ function add_version_dropdown(json_loc, target_loc, text) {
22
21
dropdown . appendChild ( content ) ;
23
22
$ . getJSON ( json_loc , function ( versions ) {
24
23
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 ( "/" ) ;
27
26
path = path . slice ( 2 , path . length ) ;
28
- path = path . join ( '/' ) ;
27
+ path = path . join ( "/" ) ;
29
28
for ( var key in versions ) {
30
29
if ( versions . hasOwnProperty ( key ) ) {
31
- console . log ( key , versions [ key ] ) ;
32
30
var a = document . createElement ( "a" ) ;
33
31
a . innerHTML = key ;
34
32
a . title = key ;
35
- assign_href ( a , target_loc + versions [ key ] , path ) ;
33
+ assign_href ( a , target_loc + versions [ key ] , path ) ;
36
34
content . appendChild ( a ) ;
37
35
}
38
36
}
0 commit comments