]> begriffs open source - cmsis/blob - version.js
Update documentation for release v6.1.0
[cmsis] / version.js
1 //--- list of versions ---
2 const versions = {
3     "General": {
4         "latest": "6.1.0",
5         "v6.1.0-rc1": "6.1.0-rc1",
6         "main": "6.1.0-rc1.7",
7         "v6.1.0-rc0": "6.1.0-rc0",
8         "v6.0.0": "6.0.0"
9     },
10     "Core": {
11         "latest": "6.1.0",
12         "v6.0.0": "6.0.0"
13     },
14     "Core_A": {
15         "latest": "6.1.0",
16         "v6.0.0": "6.0.0"
17     },
18     "Driver": {
19         "latest": "2.10.0",
20         "v6.1.0-rc1": "2.9.0"
21     },
22     "RTOS2": {
23         "latest": "2.3.0"
24     }
25 }
26 //--- list of versions ---
27
28 const components = {
29   "CMSIS": "General",
30   "CMSIS-Core (Cortex-M)": "Core",
31   "CMSIS-Core (Cortex-A)": "Core_A",
32   "CMSIS-Driver": "Driver",
33   "CMSIS-RTOS2": "RTOS2"
34 }
35
36 var script = document.currentScript
37 if (script && script.src) {
38   var scriptUrl = new URL(script.src);
39   var docUrl = new URL(document.URL);
40   var baseUrl = new URL(scriptUrl)
41   baseUrl.pathname = baseUrl.pathname.split('/').slice(0,-1).join("/")
42
43   function urlForVersion(url, version) {
44       url = new URL(url);
45       pathname = url.pathname.replace(baseUrl.pathname, "");
46       parts = pathname.split("/");
47       parts[1] = version;
48       url.pathname = baseUrl.pathname + parts.join("/");
49       return url
50   }
51
52   function writeVersionDropdown(id) {
53       component = components[id]
54       currentVersion = document.currentScript.parentNode.innerText;
55       document.currentScript.parentNode.classList.add("dropdown");
56       document.currentScript.parentNode.innerText = "";
57       document.write('  <span onclick="myFunction()" class="dropbtn">'+currentVersion+'</span>');
58       document.write('  <div id="myDropdown" class="dropdown-content">');
59       for(var version in versions[component]) {
60           var label = versions[component][version];
61           if (label != version) {
62               label += " ("+version+")"
63           }
64           label = "Version " + label
65           document.write('    <a href="'+urlForVersion(docUrl, version)+'">'+label+'</a>');
66       }
67       document.write('  </div>');
68   };
69 } else {
70   function writeVersionDropdown(id) {}
71 }
72
73 /* When the user clicks on the button,
74 toggle between hiding and showing the dropdown content */
75 function myFunction() {
76   document.getElementById("myDropdown").classList.toggle("show");
77 }
78
79 // Close the dropdown menu if the user clicks outside of it
80 window.onclick = function(event) {
81   if (!event.target.matches('.dropbtn')) {
82     var dropdowns = document.getElementsByClassName("dropdown-content");
83     var i;
84     for (i = 0; i < dropdowns.length; i++) {
85       var openDropdown = dropdowns[i];
86       if (openDropdown.classList.contains('show')) {
87         openDropdown.classList.remove('show');
88       }
89     }
90   }
91 }