1- function add_version_dropdown ( json_loc , target_loc , text ) {
1+ function assign_href ( a ) {
2+ var http = new XMLHttpRequest ( ) ;
3+ http . open ( 'GET' , url + "/" + path ) ;
4+ http . onreadystatechange = function ( ) {
5+ console . log ( '%%%%' , this ) ;
6+ if ( this . readyState == this . DONE ) {
7+ if ( this . status != 404 ) {
8+ a . href = url + "/" + path ;
9+ }
10+ else {
11+ a . href = url ;
12+ }
13+ }
14+ } ;
15+ http . send ( ) ;
16+ }
217
18+ function add_version_dropdown ( json_loc , target_loc , text ) {
319 var dropdown = document . createElement ( "div" ) ;
420 dropdown . className = "md-flex__cell md-flex__cell--shrink dropdown" ;
521 var button = document . createElement ( "button" ) ;
@@ -21,21 +37,7 @@ function add_version_dropdown(json_loc, target_loc, text) {
2137 var a = document . createElement ( "a" ) ;
2238 a . innerHTML = key ;
2339 a . title = key ;
24- var url = target_loc + versions [ key ] ;
25- var http = new XMLHttpRequest ( ) ;
26- http . open ( 'GET' , url + "/" + path ) ;
27- http . onreadystatechange = function ( ) {
28- console . log ( '%%%%' , this ) ;
29- if ( this . readyState == this . DONE ) {
30- if ( this . status != 404 ) {
31- a . href = url + "/" + path ;
32- }
33- else {
34- a . href = url ;
35- }
36- }
37- } ;
38- http . send ( ) ;
40+ assign_href ( a ) ;
3941 content . appendChild ( a ) ;
4042 }
4143 }
0 commit comments