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

View File

@ -2,7 +2,9 @@ window.addEventListener('load', async () => {
console.log("Seite geladen"); console.log("Seite geladen");
//getNewUniqueLink(); //getNewUniqueLink();
setActiveNav();
document.getElementById('btnCreateTan').addEventListener('click' , async (event) => getNewUniqueLink()); document.getElementById('btnCreateTan').addEventListener('click' , async (event) => getNewUniqueLink());
}) })
async function getNewUniqueLink() { async function getNewUniqueLink() {
@ -45,3 +47,19 @@ function getCookieValue(a) {
var b = document.cookie.match('(^|;)\\s*' + a + '\\s*=\\s*([^;]+)'); var b = document.cookie.match('(^|;)\\s*' + a + '\\s*=\\s*([^;]+)');
return b ? b.pop() : ''; 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> <h1>This is our Footer it foots you :D</h1>
<p>This is a paragraph... ya don´t say</p> <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"> <div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto"> <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> <a class="nav-link" href="index.php?page=home">Home <span class="sr-only">(current)</span></a>
</li> </li>
<li class="nav-item"> <li id="navItemEntry" class="nav-item">
<a class="nav-link" href="index.php?page=newEntry">New Entry</a> <a class="nav-link" href="index.php?page=newEntry">New Entry</a>
</li> </li>
</ul> </ul>

View File

@ -25,13 +25,13 @@
<div class="collapse navbar-collapse" id="navbarSupportedContent"> <div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto"> <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> <a class="nav-link" href="index.php?page=home">Home <span class="sr-only">(current)</span></a>
</li> </li>
<li class="nav-item"> <li id="navItemEntry" class="nav-item">
<a class="nav-link" href="index.php?page=newEntry">New Entry</a> <a class="nav-link" href="index.php?page=newEntry">New Entry</a>
</li> </li>
<li class="nav-item"> <li id="navItemDashboard" class="nav-item">
<a class="nav-link" href="index.php?page=myFriendsBook">My FriendsBook</a> <a class="nav-link" href="index.php?page=myFriendsBook">My FriendsBook</a>
</li> </li>
</ul> </ul>
@ -40,8 +40,15 @@
<!-- Button Logout --> <!-- Button Logout -->
<!-- <button id="btnLogout" onclick=window.location.href = 'http://www.google.com' type="button" class="btn btn-secondary">Logout</button> --> <!-- <button id="btnLogout" onclick=window.location.href = 'http://www.google.com' type="button" class="btn btn-secondary">Logout</button> -->
<form action="" method="post"> <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> <input class="btn btn-secondary" onClick="window.location.href = 'php/logout.php'" type="button" value="Logout"></input>
</form> </form>
</div> </div>
</form> </form>