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