added name to header and changing active nav item

This commit is contained in:
Marcel Schwarz 2018-06-20 15:53:52 +02:00
parent b220e68d1a
commit ce8d56ead0
5 changed files with 39 additions and 22 deletions

View File

@ -23,7 +23,6 @@
</head>
<body>
<!-- PARTICLES JS -->
<!-- particles.js container -->
@ -46,9 +45,6 @@
<?php #include('segments/_indexTestLoginVals.php'); ?><!-- For forms testing -->
<!-- Welche seite soll geladen werden-->
<?php
$page = '_404.html';
@ -82,16 +78,12 @@
require('segments/'.$page);
?>
<div id="footer">
<div id="footer">
<div id="content">
<?php
if(isset($_SESSION['username'])){
echo("<br><span> Herzlich Willkomen " . $_SESSION['username'] . "</span>");
}
?>
<br>
</div>
</div>
</div>
<!-- Include the footer-->
<?php include('segments/_footer.html'); ?>

View File

@ -2,7 +2,9 @@ window.addEventListener('load', async () => {
console.log("Seite geladen");
//getNewUniqueLink();
setActiveNav();
document.getElementById('btnCreateTan').addEventListener('click' , async (event) => getNewUniqueLink());
})
async function getNewUniqueLink() {
@ -45,3 +47,19 @@ function getCookieValue(a) {
var b = document.cookie.match('(^|;)\\s*' + a + '\\s*=\\s*([^;]+)');
return b ? b.pop() : '';
}
function setActiveNav(){
if(window.location.href.indexOf("?") >= 0){
if(window.location.href.indexOf("page=home") >= 0){
$("#navItemHome").addClass('active');
} else if (window.location.href.indexOf("page=newEntry") >= 0){
$("#navItemEntry").addClass('active');
} else if (window.location.href.indexOf("page=myFriendsBook") >= 0){
$("#navItemDashboard").addClass('active');
} else if (window.location.href.indexOf("page=newEntry") >= 0){
$("#navItemEntry").addClass('active');
}
} else {
$("#navItemHome").addClass('active');
}
}

View File

@ -1,4 +1,4 @@
<div id="footer">
<footer id="footer" class="footer">
<h1>This is our Footer it foots you :D</h1>
<p>This is a paragraph... ya don´t say</p>
</div>
</footer>

View File

@ -23,10 +23,10 @@
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<li id="navItemHome" class="nav-item">
<a class="nav-link" href="index.php?page=home">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<li id="navItemEntry" class="nav-item">
<a class="nav-link" href="index.php?page=newEntry">New Entry</a>
</li>
</ul>

View File

@ -25,13 +25,13 @@
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<li id="navItemHome" class="nav-item">
<a class="nav-link" href="index.php?page=home">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<li id="navItemEntry" class="nav-item">
<a class="nav-link" href="index.php?page=newEntry">New Entry</a>
</li>
<li class="nav-item">
<li id="navItemDashboard" class="nav-item">
<a class="nav-link" href="index.php?page=myFriendsBook">My FriendsBook</a>
</li>
</ul>
@ -40,8 +40,15 @@
<!-- Button Logout -->
<!-- <button id="btnLogout" onclick=window.location.href = 'http://www.google.com' type="button" class="btn btn-secondary">Logout</button> -->
<form action="" method="post">
<?php
if(isset($_SESSION['username'])){
echo('<input class="btn btn-primary" type="button" value="Herzlich Willkommen ' . $_SESSION['username'] . '"></input>');
}
?>
<input class="btn btn-secondary" onClick="window.location.href = 'php/logout.php'" type="button" value="Logout"></input>
</form>
</div>
</form>