Skip to content

Commit

Permalink
Deploy: 8c5ba34
Browse files Browse the repository at this point in the history
  • Loading branch information
array-api-bot committed Jul 8, 2023
1 parent 512ab7c commit 62b1f3a
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 12 deletions.
21 changes: 18 additions & 3 deletions 2021.12/_static/javascripts/version_dropdown.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
function add_version_dropdown(json_loc, target_loc, text) {
function assign_href(a, url, path) {
fetch(url + "/" + path).then(response => {
if (response.ok) {
a.href = url + "/" + path;
} else {
a.href = url + "/index.html";
}
}).catch(error => {
a.href = url + "/index.html";
});
}

function add_version_dropdown(json_loc, target_loc, text) {
var dropdown = document.createElement("div");
dropdown.className = "md-flex__cell md-flex__cell--shrink dropdown";
var button = document.createElement("button");
Expand All @@ -9,13 +20,17 @@ function add_version_dropdown(json_loc, target_loc, text) {
dropdown.appendChild(button);
dropdown.appendChild(content);
$.getJSON(json_loc, function(versions) {
var currentURL = window.location.href;
var path = currentURL.split("_site")[1];
path = path.split("/");
path = path.slice(2, path.length);
path = path.join("/");
for (var key in versions) {
if (versions.hasOwnProperty(key)) {
console.log(key, versions[key]);
var a = document.createElement("a");
a.innerHTML = key;
a.title = key;
a.href = target_loc + versions[key];
assign_href(a, target_loc + versions[key], path);
content.appendChild(a);
}
}
Expand Down
21 changes: 18 additions & 3 deletions 2022.12/_static/javascripts/version_dropdown.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
function add_version_dropdown(json_loc, target_loc, text) {
function assign_href(a, url, path) {
fetch(url + "/" + path).then(response => {
if (response.ok) {
a.href = url + "/" + path;
} else {
a.href = url + "/index.html";
}
}).catch(error => {
a.href = url + "/index.html";
});
}

function add_version_dropdown(json_loc, target_loc, text) {
var dropdown = document.createElement("div");
dropdown.className = "md-flex__cell md-flex__cell--shrink dropdown";
var button = document.createElement("button");
Expand All @@ -9,13 +20,17 @@ function add_version_dropdown(json_loc, target_loc, text) {
dropdown.appendChild(button);
dropdown.appendChild(content);
$.getJSON(json_loc, function(versions) {
var currentURL = window.location.href;
var path = currentURL.split("_site")[1];
path = path.split("/");
path = path.slice(2, path.length);
path = path.join("/");
for (var key in versions) {
if (versions.hasOwnProperty(key)) {
console.log(key, versions[key]);
var a = document.createElement("a");
a.innerHTML = key;
a.title = key;
a.href = target_loc + versions[key];
assign_href(a, target_loc + versions[key], path);
content.appendChild(a);
}
}
Expand Down
21 changes: 18 additions & 3 deletions draft/_static/javascripts/version_dropdown.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
function add_version_dropdown(json_loc, target_loc, text) {
function assign_href(a, url, path) {
fetch(url + "/" + path).then(response => {
if (response.ok) {
a.href = url + "/" + path;
} else {
a.href = url + "/index.html";
}
}).catch(error => {
a.href = url + "/index.html";
});
}

function add_version_dropdown(json_loc, target_loc, text) {
var dropdown = document.createElement("div");
dropdown.className = "md-flex__cell md-flex__cell--shrink dropdown";
var button = document.createElement("button");
Expand All @@ -9,13 +20,17 @@ function add_version_dropdown(json_loc, target_loc, text) {
dropdown.appendChild(button);
dropdown.appendChild(content);
$.getJSON(json_loc, function(versions) {
var currentURL = window.location.href;
var path = currentURL.split("_site")[1];
path = path.split("/");
path = path.slice(2, path.length);
path = path.join("/");
for (var key in versions) {
if (versions.hasOwnProperty(key)) {
console.log(key, versions[key]);
var a = document.createElement("a");
a.innerHTML = key;
a.title = key;
a.href = target_loc + versions[key];
assign_href(a, target_loc + versions[key], path);
content.appendChild(a);
}
}
Expand Down
21 changes: 18 additions & 3 deletions latest/_static/javascripts/version_dropdown.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
function add_version_dropdown(json_loc, target_loc, text) {
function assign_href(a, url, path) {
fetch(url + "/" + path).then(response => {
if (response.ok) {
a.href = url + "/" + path;
} else {
a.href = url + "/index.html";
}
}).catch(error => {
a.href = url + "/index.html";
});
}

function add_version_dropdown(json_loc, target_loc, text) {
var dropdown = document.createElement("div");
dropdown.className = "md-flex__cell md-flex__cell--shrink dropdown";
var button = document.createElement("button");
Expand All @@ -9,13 +20,17 @@ function add_version_dropdown(json_loc, target_loc, text) {
dropdown.appendChild(button);
dropdown.appendChild(content);
$.getJSON(json_loc, function(versions) {
var currentURL = window.location.href;
var path = currentURL.split("_site")[1];
path = path.split("/");
path = path.slice(2, path.length);
path = path.join("/");
for (var key in versions) {
if (versions.hasOwnProperty(key)) {
console.log(key, versions[key]);
var a = document.createElement("a");
a.innerHTML = key;
a.title = key;
a.href = target_loc + versions[key];
assign_href(a, target_loc + versions[key], path);
content.appendChild(a);
}
}
Expand Down

0 comments on commit 62b1f3a

Please sign in to comment.