github.io/static/old/it1/js/navbar.js

41 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-03-27 21:24:01 +00:00
$('#navbar').parent().html(`
<nav class="navbar navbar-expand-sm bg-dark navbar-dark" id="navbar">
<a class="navbar-brand" href="/old/it1/">IT1 firebase stuff</a>
2020-03-27 21:24:01 +00:00
<!-- <ul class="navbar-nav">
<li class="nav-item right">
<a class="nav-link" href="/old/it1/about.html">About</a>
2020-03-27 21:24:01 +00:00
</li>
</ul> -->
<ul class="navbar-nav ml-auto">
<li class="nav-item right">
<a class="nav-link" id="login-btn" href="/old/it1/bruker/"></a>
2020-03-27 21:24:01 +00:00
</li>
</ul>
</nav>`)
var signout = function() {
firebase.auth()
.signOut()
.then(function() {
document.location.href = '/old/it1/'
2020-03-27 21:24:01 +00:00
}).catch(function(error) {
alert('could not log out: '+error.message)
})
}
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
$('#login-btn').attr('href', 'javascript: signout()')
$('#login-btn').html('Logout')
} else {
$('#login-btn').attr('href', '/old/it1/bruker/')
2020-03-27 21:24:01 +00:00
$('#login-btn').html('Login')
}
})
for (var i = 0; i < $('#navbar').children().length; i++) {
$('#navbar').children().css('color', 'springgreen')
}