Fix bug when banner displays even on the latest URL

pull/103/head
JulioV 2020-11-18 20:04:23 -05:00
parent 27564bab98
commit 17da2ff7f2
1 changed files with 12 additions and 3 deletions

View File

@ -1,5 +1,14 @@
window.addEventListener("DOMContentLoaded", function() {
if(!window.location.pathname.endsWith("/latest/")){
document.querySelector("div[data-md-component=announce]").innerHTML = "<div id='announce-msg'>You are seeing the docs for a previous version of RAPIDS, <a href='latest/'>click here to go to the latest</a></div>"
}
var xhr = new XMLHttpRequest();
xhr.open("GET", window.location + "../versions.json");
xhr.onload = function() {
var versions = JSON.parse(this.responseText);
latest_version = ""
for(id in versions)
if(versions[id]["aliases"].length > 0 && versions[id]["aliases"].includes("latest"))
latest_version = "/" + versions[id].version + "/"
if(!window.location.pathname.includes("/latest/") && (latest_version.length > 0 && !window.location.pathname.includes(latest_version)))
document.querySelector("div[data-md-component=announce]").innerHTML = "<div id='announce-msg'>You are seeing the docs for a previous version of RAPIDS, <a href='" + window.location.href + "latest/'>click here to go to the latest</a></div>"
};
xhr.send();
});