Skip to content

Commit

Permalink
add switcher between release and main
Browse files Browse the repository at this point in the history
  • Loading branch information
brauliorivas committed Jul 12, 2024
1 parent e650135 commit 3d93f29
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
23 changes: 23 additions & 0 deletions css/switch-deploy.css
Original file line number Diff line number Diff line change
@@ -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;
}
6 changes: 6 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<link rel="stylesheet" href="css/information.css">
<link rel="stylesheet" href="css/contact.css">
<link rel="stylesheet" href="css/views.css">
<link rel="stylesheet" href="css/switch-deploy.css">
</head>

<body>
Expand Down Expand Up @@ -148,6 +149,10 @@
</li>
</ul>
</div>
<div id="switch-deploy">
<p id="switch-deploy-text">Switch to</p>
<button id="switch-deploy-button">release</button>
</div>
</div>

<div id="views">
Expand All @@ -162,6 +167,7 @@
<script type="module" src="js/information.js"></script>
<script type="module" src="js/views/views.js"></script>
<script type="module" src="js/menu/filter/filter.js"></script>
<script type="module" src="js/switch-deploy.js"></script>
</body>

</html>
22 changes: 22 additions & 0 deletions js/switch-deploy.js
Original file line number Diff line number Diff line change
@@ -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";
}

0 comments on commit 3d93f29

Please sign in to comment.