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