76 lines
2.6 KiB
Plaintext

<nav class="navbar" role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<a class="navbar-item primary" href="/">
<i class="bi bi-cup-straw"></i>
</a>
<a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div id="navbarBasicExample" class="navbar-menu">
<div class="navbar-start">
<a class="navbar-item" href="/">Screensaver</a>
<a class="navbar-item" href="/user_select">user_select</a>
<a class="navbar-item" href="/product_select">product_select</a>
<a class="navbar-item" href="/test">Test <span class="tag is-info">Dev</span></a>
<!--<div class="navbar-item has-dropdown is-hoverable">
<a class="navbar-link">More</a>
<div class="navbar-dropdown">
<a class="navbar-item">About</a>
<a class="navbar-item is-selected">Jobs</a>
<a class="navbar-item">Contact</a>
<hr class="navbar-divider">
<a class="navbar-item">Report an issue</a>
</div>
</div>-->
</div>
<div class="navbar-end">
<div class="navbar-item is-hidden" id="showOnLogin">
<strong>Hey, <span id="nav_username"></span></strong>
<button class="button" onclick="window.location='/pay_up'" >Zur Abrechnung</button>
</div>
<div class="navbar-item is-hidden" id="onlyShowRoot">
<button class="button" onclick="window.location='/admin/'" >Zur Administration</button>
</div>
<div class="navbar-item is-hidden" id="onlyShowAdmin">
<button class="button" onclick="window.location='/admin/'" >Zur Administration</button>
<button class="button" onclick="window.location='/'" >Abmelden</button>
</div>
</div>
<script>
// Check if ?user is set
if (window.location.search.includes('user')) {
// Show the sign up button
document.querySelector('#showOnLogin').classList.remove('is-hidden');
// Get the username from the cookie
username = document.cookie.split('; ').find(row => row.startsWith('name')).split('=')[1];
// Set the username in the nav
document.getElementById('nav_username').innerText = username;
}
// Check if /user_select is the current page
if (window.location.pathname == '/user_select') {
// Show the sign up button
document.querySelector('#onlyShowRoot').classList.remove('is-hidden');
}
// If admin is contained in url
if (window.location.pathname.includes('admin')) {
// Show the sign up button
document.querySelector('#onlyShowAdmin').classList.remove('is-hidden');
}
</script>
</div>
</nav>