Skip to content

Commit 7a4c0a4

Browse files
committed
split function
1 parent a6157d0 commit 7a4c0a4

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

spec/_static/javascripts/version_dropdown.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
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

Comments
 (0)