1 //--- list of versions ---
9 //--- list of versions ---
11 var script = document.currentScript
12 if (script && script.src) {
13 var scriptUrl = new URL(script.src);
14 var docUrl = new URL(document.URL);
15 var baseUrl = new URL(scriptUrl)
16 baseUrl.pathname = baseUrl.pathname.split('/').slice(0,-1).join("/")
18 function urlForVersion(url, version) {
20 pathname = url.pathname.replace(baseUrl.pathname, "");
21 parts = pathname.split("/");
23 url.pathname = baseUrl.pathname + parts.join("/");
27 function writeVersionDropdown() {
28 currentVersion = document.currentScript.parentNode.innerText;
29 document.currentScript.parentNode.classList.add("dropdown");
30 document.currentScript.parentNode.innerText = "";
31 document.write(' <span onclick="myFunction()" class="dropbtn">'+currentVersion+'</span>');
32 document.write(' <div id="myDropdown" class="dropdown-content">');
33 for(var version in versions) {
34 var label = versions[version];
35 if (label != version) {
36 label += " ("+version+")"
38 label = "Version " + label
39 document.write(' <a href="'+urlForVersion(docUrl, version)+'">'+label+'</a>');
41 document.write(' </div>');
44 function writeVersionDropdown() {}
47 /* When the user clicks on the button,
48 toggle between hiding and showing the dropdown content */
49 function myFunction() {
50 document.getElementById("myDropdown").classList.toggle("show");
53 // Close the dropdown menu if the user clicks outside of it
54 window.onclick = function(event) {
55 if (!event.target.matches('.dropbtn')) {
56 var dropdowns = document.getElementsByClassName("dropdown-content");
58 for (i = 0; i < dropdowns.length; i++) {
59 var openDropdown = dropdowns[i];
60 if (openDropdown.classList.contains('show')) {
61 openDropdown.classList.remove('show');