You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.1 KiB
JavaScript
69 lines
2.1 KiB
JavaScript
//--- list of versions ---
|
|
const versions = {
|
|
"main": "1.14.4-dev6",
|
|
"latest": "1.14.3",
|
|
"v1.14.2": "1.14.2",
|
|
"v1.14.1": "1.14.1",
|
|
"v1.14.0": "1.14.0",
|
|
"v1.12.0": "1.12.0",
|
|
"v1.11.0": "1.11.0",
|
|
"v1.10.1": "1.10.1"
|
|
}
|
|
//--- list of versions ---
|
|
|
|
var script = document.currentScript
|
|
if (script && script.src) {
|
|
var scriptUrl = new URL(script.src);
|
|
var docUrl = new URL(document.URL);
|
|
var baseUrl = new URL(scriptUrl)
|
|
baseUrl.pathname = baseUrl.pathname.split('/').slice(0,-1).join("/")
|
|
|
|
function urlForVersion(url, version) {
|
|
url = new URL(url);
|
|
pathname = url.pathname.replace(baseUrl.pathname, "");
|
|
parts = pathname.split("/");
|
|
parts[1] = version;
|
|
url.pathname = baseUrl.pathname + parts.join("/");
|
|
return url
|
|
}
|
|
|
|
function writeVersionDropdown() {
|
|
currentVersion = document.currentScript.parentNode.innerText;
|
|
document.currentScript.parentNode.classList.add("dropdown");
|
|
document.currentScript.parentNode.innerText = "";
|
|
document.write(' <span onclick="myFunction()" class="dropbtn">'+currentVersion+'</span>');
|
|
document.write(' <div id="myDropdown" class="dropdown-content">');
|
|
for(var version in versions) {
|
|
var label = versions[version];
|
|
if (label != version) {
|
|
label += " ("+version+")"
|
|
}
|
|
label = "Version " + label
|
|
document.write(' <a href="'+urlForVersion(docUrl, version)+'">'+label+'</a>');
|
|
}
|
|
document.write(' </div>');
|
|
};
|
|
} else {
|
|
function writeVersionDropdown() {}
|
|
}
|
|
|
|
/* When the user clicks on the button,
|
|
toggle between hiding and showing the dropdown content */
|
|
function myFunction() {
|
|
document.getElementById("myDropdown").classList.toggle("show");
|
|
}
|
|
|
|
// Close the dropdown menu if the user clicks outside of it
|
|
window.onclick = function(event) {
|
|
if (!event.target.matches('.dropbtn')) {
|
|
var dropdowns = document.getElementsByClassName("dropdown-content");
|
|
var i;
|
|
for (i = 0; i < dropdowns.length; i++) {
|
|
var openDropdown = dropdowns[i];
|
|
if (openDropdown.classList.contains('show')) {
|
|
openDropdown.classList.remove('show');
|
|
}
|
|
}
|
|
}
|
|
}
|