From 3d93f2973ceb7a0c76c1be3ee0718214562d485c Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Thu, 11 Jul 2024 19:33:10 -0500 Subject: [PATCH] add switcher between release and main --- css/switch-deploy.css | 23 +++++++++++++++++++++++ index.html | 6 ++++++ js/switch-deploy.js | 22 ++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 css/switch-deploy.css create mode 100644 js/switch-deploy.js diff --git a/css/switch-deploy.css b/css/switch-deploy.css new file mode 100644 index 00000000..5f496930 --- /dev/null +++ b/css/switch-deploy.css @@ -0,0 +1,23 @@ +#switch-deploy { + display: flex; + flex-direction: row; + align-items: center; +} + +#switch-deploy-button { + cursor: pointer; + background-color: #fff; + border: 1px solid #000; + padding: 5px; + border-radius: 5px; + font-family: sans-serif; + font-size: 14px; +} + +#switch-deploy-button:hover { + background-color: #c5c5c5; +} + +#switch-deploy-text { + margin: 0 10px 0 0; +} diff --git a/index.html b/index.html index 3cb6744e..700ccfbf 100644 --- a/index.html +++ b/index.html @@ -17,6 +17,7 @@ + @@ -148,6 +149,10 @@ +
+

Switch to

+ +
@@ -162,6 +167,7 @@ + \ No newline at end of file diff --git a/js/switch-deploy.js b/js/switch-deploy.js new file mode 100644 index 00000000..445ae82b --- /dev/null +++ b/js/switch-deploy.js @@ -0,0 +1,22 @@ +const button = document.getElementById("switch-deploy-button"); + +button.addEventListener("click", () => { + const currentUrl = window.location.href; + + if (currentUrl.includes("/main")) { + window.location.href = currentUrl.replace("/main", "/release"); + } else if (currentUrl.includes("/release")) { + window.location.href = currentUrl.replace("/release", "/main"); + } else { + window.location.href = "https://key4hep.github.io/eede/release/index.html"; + } +}); + +const url = window.location.href; +if (url.includes("/main")) { + button.innerText = "Release"; +} else if (url.includes("/release")) { + button.innerText = "Main"; +} else { + button.innerText = "Release"; +}