From 17da2ff7f2170a11a589bcda70521ef260be9d4d Mon Sep 17 00:00:00 2001 From: JulioV Date: Wed, 18 Nov 2020 20:04:23 -0500 Subject: [PATCH] Fix bug when banner displays even on the latest URL --- docs/javascripts/extra.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/javascripts/extra.js b/docs/javascripts/extra.js index e07822c9..10faee99 100644 --- a/docs/javascripts/extra.js +++ b/docs/javascripts/extra.js @@ -1,5 +1,14 @@ window.addEventListener("DOMContentLoaded", function() { - if(!window.location.pathname.endsWith("/latest/")){ - document.querySelector("div[data-md-component=announce]").innerHTML = "
You are seeing the docs for a previous version of RAPIDS, click here to go to the latest
" - } + 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 = "
You are seeing the docs for a previous version of RAPIDS, click here to go to the latest
" + }; + xhr.send(); });