From ee9bdca28d7559d2a48ec6984caf71e64bd1385b Mon Sep 17 00:00:00 2001 From: Jonatan Antoni Date: Thu, 30 Jun 2022 16:50:14 +0200 Subject: [PATCH] Add dropdown box to navigate between versions. --- dropdown.png | Bin 0 -> 159 bytes main/index.html | 5 ++++- v1.10.1/index.html | 5 ++++- version.css | 44 ++++++++++++++++++++++++++++++++++++++ version.js | 52 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 dropdown.png create mode 100644 version.css create mode 100644 version.js diff --git a/dropdown.png b/dropdown.png new file mode 100644 index 0000000000000000000000000000000000000000..1a8a9ed59f5cabf517986adbaa5b7c6277bd03a4 GIT binary patch literal 159 zcmeAS@N?(olHy`uVBq!ia0vp^oFL4>1|%O$WD@{VjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCf`#@Q5sCVBk9p!i>lBSEK+1O*~y3Lo|YuC0ZIbW_`N&KfuiI0Ef~C&79L) y(^#~b7<0HBxg1Pl1UVG6TQm=F8Th6oFfc4<6kMKjhesNypTX1B&t;ucLK6T+vM8hg literal 0 HcmV?d00001 diff --git a/main/index.html b/main/index.html index 03754c93..b9cfdc4f 100644 --- a/main/index.html +++ b/main/index.html @@ -7,9 +7,11 @@ CMSIS-DSP: CMSIS DSP Software Library + + @@ -32,9 +34,10 @@ Logo
CMSIS-DSP -   diff --git a/v1.10.1/index.html b/v1.10.1/index.html index 03754c93..b9cfdc4f 100644 --- a/v1.10.1/index.html +++ b/v1.10.1/index.html @@ -7,9 +7,11 @@ CMSIS-DSP: CMSIS DSP Software Library + + @@ -32,9 +34,10 @@ Logo
CMSIS-DSP -   diff --git a/version.css b/version.css new file mode 100644 index 00000000..99744954 --- /dev/null +++ b/version.css @@ -0,0 +1,44 @@ +/* Dropdown Button */ +.dropbtn { + margin: 0px; + padding: 0px 0px 0px 1em; + background-image: url(dropdown.png); + background-repeat: no-repeat; + background-size: 0.75em; + background-position: left center; +} + +/* Dropdown button on hover & focus */ +.dropbtn:hover, .dropbtn:focus { + background-color: #2980B9; +} + +/* The container
- needed to position the dropdown content */ +.dropdown { + position: relative; + display: inline-block; +} + +/* Dropdown Content (Hidden by Default) */ +.dropdown-content { + display: none; + position: absolute; + background-color: #f1f1f1; + min-width: 160px; + box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); + z-index: 1; +} + +/* Links inside the dropdown */ +.dropdown-content a { + color: black; + padding: 4px 6px; + text-decoration: none; + display: block; +} + +/* Change color of dropdown links on hover */ +.dropdown-content a:hover {background-color: #ddd} + +/* Show the dropdown menu (use JS to add this class to the .dropdown-content container when the user clicks on the dropdown button) */ +.show {display:block;} diff --git a/version.js b/version.js new file mode 100644 index 00000000..3307f57a --- /dev/null +++ b/version.js @@ -0,0 +1,52 @@ +const versions = { + "main": "v1.10.2-dev1+g4b4c680 (main)", + "v1.10.1": "v1.10.1 (latest)" +}; + +var scripts = document.getElementsByTagName("script"), +scriptUrl = new URL(scripts[scripts.length-1].src); +docUrl = new URL(document.URL); +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(' '+currentVersion+''); + document.write(' '); +}; + +/* 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'); + } + } + } +}