Merge branch 'master' into kevin-prototype

This commit is contained in:
K. Nobel
2017-01-31 12:06:58 +01:00
20 changed files with 250 additions and 76 deletions

View File

@@ -21,7 +21,7 @@ $friends = json_decode($_POST["friends"]);
foreach($friends as $i => $friend) { foreach($friends as $i => $friend) {
$friendshipStatus = getFriendshipStatus($friend->userID); $friendshipStatus = getFriendshipStatus($friend->userID);
?> ?>
<li class='friend-item <?= $extra ?>'> <li class='friend-item'>
<form action='<?= $action ?>' method='<?= $actionType ?>'> <form action='<?= $action ?>' method='<?= $actionType ?>'>
<button type='submit' <button type='submit'
name='username' name='username'

View File

@@ -60,7 +60,6 @@ function adminSearch() {
"API/adminSearchUsers.php", "API/adminSearchUsers.php",
$("#admin-searchform").serialize() $("#admin-searchform").serialize()
).done(function (data) { ).done(function (data) {
console.log(data);
$("#usertable").html(data); $("#usertable").html(data);
}) })
} }

View File

@@ -54,16 +54,25 @@ function addMessages(messages) {
type = "chat-message-other"; type = "chat-message-other";
} }
if (i == 0) { if (i == 0) {
if (thisDate > previousDate) {
previousDate = thisDate;
messagesText += '\
<div class="day-message"> \
<div class="day-message-content">\
' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\
</div> \
</div>';
}
messagesText += '<div class="chat-message"><div class="' + type + '">'; messagesText += '<div class="chat-message"><div class="' + type + '">';
} else if (type != previousType || thisTime != previousTime || thisDate > previousDate) { } else if (type != previousType || thisTime != previousTime || thisDate > previousDate) {
messagesText += '<div class="chat-time">\ messagesText += '<div class="chat-time">\
' + thisTime + '\ ' + thisTime + '\
</div></div></div>'; </div></div></div>';
previousDate = thisDate;
previousTime = thisTime; previousTime = thisTime;
previousType = type; previousType = type;
if (thisDate > previousDate) { if (thisDate > previousDate) {
previousDate = thisDate;
messagesText += '\ messagesText += '\
<div class="day-message"> \ <div class="day-message"> \
<div class="day-message-content">\ <div class="day-message-content">\

View File

@@ -48,9 +48,6 @@ function placeFriendButtons() {
text2 = "Weiger"; text2 = "Weiger";
icon2 = "fa-times"; icon2 = "fa-times";
break; break;
default:
console.log(friendshipStatus);
break;
} }
$buttonContainer.append( $buttonContainer.append(

View File

@@ -1,25 +1,37 @@
$(document).ready(function() { $(document).ready(function() {
// Toggle menu // Toggle menu
$("#own-profile-picture, #open-notifications").click(function() { $("#own-profile-picture, #open-notifications").click(function() {
if ($("#notification-center").css('right') == "-256px") { if ($("#notification-center").css('display') == "none") {
// Make the menu visible and move the content to the left. // Make the menu visible and move the content to the left.
$("#chat-history").width("calc(100% - 587px)"); $(".modal").width("calc(100% - 512px)");
$(".modal").width("calc(100% - 512px)"); $(".content").css("margin-right", "256px");
$(".content").css("margin-right", "256px"); $("#notification-center").css("right", "0px");
$("#notification-center").css("right", "0px"); $("#notification-center").css("display", "block");
$("#contact-menu").css("display", "block");
// Add cookie so the menu stays open on other pages // Add cookie so the menu stays open on other pages
document.cookie = "menu=open; path=/"; if (window.innerWidth > 1080) {
} else { $("#chat-history").width("calc(100% - 587px)");
// Make the menu invisible and move the content to the right. document.cookie = "menu=open; path=/";
$("#chat-history").width("calc(100% - 331px)"); } else {
$(".modal").width("calc(100% - 256px)"); document.cookie = "menu=closed; path=/";
$(".content").css("margin-right", "0px"); }
$("#notification-center").css("right", "-256px"); } else {
$(".modal").width("calc(100% - 256px)");
$(".content").css("margin-right", "0px");
$("#notification-center").css("display", "none");
// Change menu cookie to close if (window.innerWidth > 1080) {
document.cookie = "menu=closed; path=/"; $("#chat-history").width("calc(100% - 331px)");
} } else {
// Make the menu invisible and move the content to the right.
$("#contact-menu").css("display", "none");
}
// Change menu cookie to close
document.cookie = "menu=closed; path=/";
}
}); });
if (getCookie("menu") == "open") { if (getCookie("menu") == "open") {

View File

@@ -10,6 +10,7 @@
<body> <body>
<?php <?php
session_start(); session_start();
if(isset($_SESSION["userID"])){ if(isset($_SESSION["userID"])){
header("location: login.php"); header("location: login.php");
} }

View File

@@ -144,4 +144,22 @@ body {
.chat-message-other .chat-time { .chat-message-other .chat-time {
text-align: right; text-align: right;
}
@media only screen and (max-width: 1080px) {
.chat-message-self, .chat-message-other {
max-width: 75%;
}
.chat {
left: 0;
width: 100%;
}
#chat-recent-panel {
left: 0;
width: 320px;
}
#chat-history {
left: 50%;
width: calc(100% - 390px);
}
} }

View File

@@ -26,7 +26,8 @@ header {
} }
#header-search { #header-search {
padding-left: 42px; margin: 24px 0 24px 32px;
vertical-align: middle;
} }
@@ -49,4 +50,10 @@ header div {
#open-notifications { #open-notifications {
padding: 5px 20px 5px 0px; padding: 5px 20px 5px 0px;
}
@media only screen and (max-width: 1080px) {
#header-logo {
display: none;
}
} }

View File

@@ -293,4 +293,14 @@ div[data-title]:hover:after {
-webkit-border-radius: 20px; -webkit-border-radius: 20px;
border-radius: 20px; border-radius: 20px;
background: #4CAF50; background: #4CAF50;
}
@media only screen and (max-width: 1080px) {
body {
font-size: 28px!important;
}
button {
font-size: 28px;
}
} }

View File

@@ -5,7 +5,7 @@
left: 0; left: 0;
top: 80px; top: 80px;
height: calc(100% - 80px); height: calc(100% - 120px);
width: 236px; width: 236px;
padding: 20px 10px; padding: 20px 10px;
@@ -86,4 +86,18 @@
height: 100%; height: 100%;
padding: 0; padding: 0;
text-align: left; text-align: left;
}
@media only screen and (max-width: 1080px) {
#contact-menu, #notification-center {
display: none;
background: rgba(0, 0, 0, 0.4);
width: calc(50% - 20px);
}
.content {
margin-left: 0;
}
#quick-links i {
font-size: 48px!important;
}
} }

View File

@@ -0,0 +1,47 @@
/* MAIN */
body {
font-size: 28px!important;
}
button {
font-size: 28px;
}
/* HEADER */
#header-logo {
display: none;
}
/* PROFILE */
.post-box {
width: calc(100% - 65px);
}
/* MENU */
#contact-menu, #notification-center {
display: none;
background: rgba(0, 0, 0, 0.4);
width: calc(50% - 20px);
}
.content {
margin-left: 0;
}
#quick-links i {
font-size: 48px!important;
}
/* CHAT */
.chat-message-self, .chat-message-other {
max-width: 75%;
}
.chat {
left: 0;
width: 100%;
}
#chat-recent-panel {
left: 0;
width: 320px;
}
#chat-history {
left: 50%;
width: calc(100% - 390px);
}

View File

@@ -116,7 +116,7 @@ div.posts .post form textarea.newpost {
} }
/* mobile */ /* mobile */
@media only screen and (max-width: 1000px) { @media only screen and (max-width: 1080px) {
.post-box { .post-box {
width: calc(100% - 65px); width: calc(100% - 65px);
} }

View File

@@ -0,0 +1,12 @@
<?php
/**
* calculates the age of a user
* @param string $bdayAsString
* @return int age
*/
function getAge(string $bdayAsString) : int {
$bday = new DateTime($bdayAsString);
$today = new DateTime("now");
$interval = $bday->diff($today);
return $interval->y;
}

View File

@@ -16,7 +16,6 @@ function selectLimitedFriends($userID, $limit) {
`profilepicture`, `profilepicture`,
'../img/avatar-standard.png' '../img/avatar-standard.png'
) AS profilepicture, ) AS profilepicture,
`onlinestatus`,
`role` `role`
FROM FROM
`user` `user`
@@ -56,7 +55,10 @@ function selectAllFriends($userID) {
`profilepicture`, `profilepicture`,
'../img/avatar-standard.png' '../img/avatar-standard.png'
) AS profilepicture, ) AS profilepicture,
`onlinestatus`, CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
WHEN TRUE THEN 'online'
WHEN FALSE THEN 'offline'
END AS `onlinestatus`,
`role` `role`
FROM FROM
`user` `user`
@@ -88,7 +90,10 @@ function selectAllFriendRequests() {
`profilepicture`, `profilepicture`,
'../img/avatar-standard.png' '../img/avatar-standard.png'
) AS profilepicture, ) AS profilepicture,
`onlinestatus`, CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
WHEN TRUE THEN 'online'
WHEN FALSE THEN 'offline'
END AS `onlinestatus`,
`role` `role`
FROM FROM
`user` `user`
@@ -235,7 +240,10 @@ function searchSomeFriends($n, $m, $search) {
`profilepicture`, `profilepicture`,
'../img/avatar-standard.png' '../img/avatar-standard.png'
) AS profilepicture, ) AS profilepicture,
`onlinestatus`, CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
WHEN TRUE THEN 'online'
WHEN FALSE THEN 'offline'
END AS `onlinestatus`,
`role` `role`
FROM FROM
`user` `user`

View File

@@ -110,20 +110,31 @@ function updateSettings() {
WHERE WHERE
`userID` = :userID `userID` = :userID
"); ");
$bday = new DateTime();
$bday->setDate(test_input($_POST["year"]), test_input($_POST["month"]), test_input($_POST["day"]));
checkBday($bday);
$stmt->bindValue(":fname", test_input($_POST["fname"])); $stmt->bindValue(":fname", test_input($_POST["fname"]));
$stmt->bindValue(":lname", test_input($_POST["lname"])); $stmt->bindValue(":lname", test_input($_POST["lname"]));
$stmt->bindValue(":location", test_input($_POST["location"])); $stmt->bindValue(":location", test_input($_POST["location"]));
$stmt->bindValue(":bday", test_input($_POST["bday"])); $stmt->bindValue(":bday", $bday->format("Ymd"));
$stmt->bindValue(":bio", test_input($_POST["bio"])); $stmt->bindValue(":bio", test_input($_POST["bio"]));
$stmt->bindValue(":showEmail", test_input($_POST["showEmail"])); $stmt->bindValue(":showEmail", (array_key_exists("showEmail", $_POST) ? "1" : "0"));
$stmt->bindValue(":showBday", test_input($_POST["showBday"])); $stmt->bindValue(":showBday", (array_key_exists("showBday", $_POST) ? "1" : "0"));
$stmt->bindValue(":userID", $_SESSION["userID"]); $stmt->bindValue(":userID", $_SESSION["userID"]);
$stmt->execute(); $stmt->execute();
throw new HappyAlert("Instellingen zijn opgeslagen."); throw new HappyAlert("Instellingen zijn opgeslagen.");
} }
function checkBday(DateTime $bday) {
$today = new DateTime();
if ($bday >= $today) {
throw new AngryAlert("Jij bent vast niet in de toekomst geboren toch? ;)");
}
}
/** /**
* Change * Change
* @throws AngryAlert * @throws AngryAlert

View File

@@ -45,7 +45,10 @@ function selectUser($me, $other) {
) AS profilepicture, ) AS profilepicture,
`bio`, `bio`,
`user`.`creationdate`, `user`.`creationdate`,
`onlinestatus`, CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
WHEN TRUE THEN 'online'
WHEN FALSE THEN 'offline'
END AS `onlinestatus`,
`role`, `role`,
`fname`, `fname`,
`lname`, `lname`,

View File

@@ -12,6 +12,8 @@
@import url("styles/header.css"); @import url("styles/header.css");
@import url("styles/menu.css"); @import url("styles/menu.css");
@import url("styles/footer.css"); @import url("styles/footer.css");
@import url("styles/mobilefriendly.css") screen and (orientation: portrait);
</style> </style>
<?php <?php

View File

@@ -1,4 +1,4 @@
<nav class="menu"> <nav class="menu" id="contact-menu">
<section id="friends-menu-section"> <section id="friends-menu-section">
<h4> <h4>
Recente vrienden Recente vrienden

View File

@@ -3,7 +3,9 @@
<img class="profile-picture main-picture" src="<?= $user["profilepicture"] ?>"><br /> <img class="profile-picture main-picture" src="<?= $user["profilepicture"] ?>"><br />
<div class="platform"> <div class="platform">
<div class="status-buttons-container"> <div class="status-buttons-container">
<button disabled class="gray"><?= $user["onlinestatus"] ?></button> <button disabled class="gray">
<?= $user["onlinestatus"] ?>
</button>
<button disabled class="gray"><?= $user["role"] ?></button> <button disabled class="gray"><?= $user["role"] ?></button>
</div> </div>
<div class="friend-button-container"> <div class="friend-button-container">

View File

@@ -4,13 +4,11 @@ $settings = getSettings();
<div class="content"> <div class="content">
<div class="settings"> <div class="settings">
<?php <?php if ($_SERVER["REQUEST_METHOD"] == "POST"): ?>
if ($_SERVER["REQUEST_METHOD"] == "POST") { <div class='platform settings-message <?=$alertClass?>'>
echo "<div class='platform settings-message $alertClass '> <?=$alertMessage?>
$alertMessage </div>
</div>"; <?php endif; ?>
}
?>
<form class="settings-profile platform" method="post"> <form class="settings-profile platform" method="post">
<h5>Profiel Instellingen</h5> <h5>Profiel Instellingen</h5>
<ul> <ul>
@@ -21,7 +19,7 @@ $settings = getSettings();
id="fname" id="fname"
placeholder="Voornaam" placeholder="Voornaam"
title="Voornaam" title="Voornaam"
value="<?= $settings["fname"]?>" value="<?=$settings["fname"]?>"
> >
</li> </li>
<li> <li>
@@ -30,7 +28,7 @@ $settings = getSettings();
name="lname" name="lname"
id="lname" id="lname"
placeholder="Achternaam" placeholder="Achternaam"
value="<?= $settings["lname"]?>" value="<?=$settings["lname"]?>"
> >
</li> </li>
<li> <li>
@@ -39,43 +37,61 @@ $settings = getSettings();
name="location" name="location"
id="location" id="location"
placeholder="Locatie" placeholder="Locatie"
value="<?= $settings["location"]?>" value="<?=$settings["location"]?>"
> >
</li> </li>
<li> <li>
<?php $currentbday = new DateTime($settings["birthdate"]); ?>
<label for="bday">Geboortedatum</label> <label for="bday">Geboortedatum</label>
<input type="date" <select name='day' id="bday">
name="bday" <?php for ($day = 1; $day <= 31; $day++): ?>
id="bday" <option value='<?=$day?>'
placeholder="yyyy-mm-dd" <?=($day == $currentbday->format("d")) ? "selected" : ""?>
value="<?= $settings["birthdate"]?>" >
> <?=$day?>
</option>
<?php endfor; ?>
</select>
<select name='month' id="bday">
<?php
$months = array ("januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus",
"september", "oktober", "november", "december");
for ($month = 1; $month <= 12; $month++):
?>
<option value='<?=$month?>'
<?=($month == $currentbday->format("m")) ? "selected" : ""?>
>
<?=$months[$month - 1]?>
</option>
<?php endfor; ?>
</select>
<select name='year' id="bday">
<?php
$now = (new DateTime)->format("Y");
for ($year = $now; $year >= 1900; $year--): ?>
<option value='<?=$year?>'
<?=($year == $currentbday->format("Y")) ? "selected" : ""?>
>
<?=$year?>
</option>
<?php endfor; ?>
</select>
</li> </li>
<li> <li>
<label for="showBday">Toon leeftijd</label> <label for="showBday">Toon leeftijd</label>
<input type="radio" <input type="checkbox"
name="showBday" name="showBday"
value="1" id="showBday"
<?php echo ($settings["showBday"] ? "checked" : "")?> <?=($settings["showBday"] ? "checked" : "")?>
> Ja >
<input type="radio"
name="showBday"
value="0"
<?php echo ($settings["showBday"] ? "" : "checked")?>
> Nee
</li> </li>
<li> <li>
<label for="showEmail">Toon Email</label> <label for="showEmail">Toon Email</label>
<input type="radio" <input type="checkbox"
name="showEmail" name="showEmail"
value="1" id="showEmail"
<?php echo ($settings["showEmail"] ? "checked" : "")?> <?=($settings["showEmail"] ? "checked" : "")?>
> Ja >
<input type="radio"
name="showEmail"
value="0"
<?php echo ($settings["showEmail"] ? "" : "checked")?>
> Nee
</li> </li>
<li> <li>
<label for="bio">Bio</label> <label for="bio">Bio</label>
@@ -83,7 +99,7 @@ $settings = getSettings();
rows="5" rows="5"
title="bio" title="bio"
id="bio" id="bio"
><?= $settings["bio"]?></textarea> ><?=$settings["bio"]?></textarea>
</li> </li>
<li> <li>
<label></label> <label></label>
@@ -99,7 +115,7 @@ $settings = getSettings();
<ul> <ul>
<li> <li>
<label>Huidige profielfoto</label> <label>Huidige profielfoto</label>
<img src="<?= $settings["profilepicture"] ?>" <img src="<?=$settings["profilepicture"]?>"
class="profile-picture" class="profile-picture"
> >
</li> </li>
@@ -124,24 +140,30 @@ $settings = getSettings();
<h5>Verander Wachtwoord</h5> <h5>Verander Wachtwoord</h5>
<ul> <ul>
<li> <li>
<label>Oud wachtwoord</label> <label for="password-old">Oud wachtwoord</label>
<input type="password" <input type="password"
name="password-old" name="password-old"
id="password-old"
placeholder="Oud wachtwoord" placeholder="Oud wachtwoord"
autocomplete="current-password"
> >
</li> </li>
<li> <li>
<label>Nieuw wachtwoord</label> <label for="password-new">Nieuw wachtwoord</label>
<input type="password" <input type="password"
name="password-new" name="password-new"
id="password-new"
placeholder="Nieuw wachtwoord" placeholder="Nieuw wachtwoord"
autocomplete="new-password"
> >
</li> </li>
<li> <li>
<label>Bevestig wachtwoord</label> <label for="password-confirm">Bevestig wachtwoord</label>
<input type="password" <input type="password"
name="password-confirm" name="password-confirm"
id="password-confirm"
placeholder="Bevestig wachtwoord" placeholder="Bevestig wachtwoord"
autocomplete="new-password"
> >
</li> </li>
<li> <li>
@@ -160,7 +182,7 @@ $settings = getSettings();
<label for="email-old">Huidig Email </label> <label for="email-old">Huidig Email </label>
<input type="email" <input type="email"
id="email-old" id="email-old"
value="<?= $settings["email"]?>" value="<?=$settings["email"]?>"
disabled disabled
> >
</li> </li>