Merge branch 'lars-chat' into 'master'
Fixed chat See merge request !66
This commit was merged in pull request #70.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
include_once("../queries/private_message.php");
|
include_once("../../queries/private_message.php");
|
||||||
|
|
||||||
if (isset($_POST["lastID"]) && $_POST["lastID"] != "") {
|
if (isset($_POST["lastID"]) && $_POST["lastID"] != "") {
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
include_once("../queries/private_message.php");
|
include_once("../../queries/private_message.php");
|
||||||
|
|
||||||
if (isset($_POST["destination"]) &&
|
if (isset($_POST["destination"]) &&
|
||||||
isset($_POST["content"])) {
|
isset($_POST["content"])) {
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
loadMessages();
|
loadMessages();
|
||||||
|
sayEmpty();
|
||||||
|
$(".chat-field").hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
function loadMessages() {
|
function loadMessages() {
|
||||||
$.post(
|
$.post(
|
||||||
"loadMessages.php",
|
"API/loadMessages.php",
|
||||||
$("#lastIDForm").serialize()
|
$("#lastIDForm").serialize()
|
||||||
).done(function(data) {
|
).done(function(data) {
|
||||||
if (data && data != "[]") {
|
if (data && data != "[]") {
|
||||||
@@ -23,7 +25,7 @@ function loadMessages() {
|
|||||||
function sendMessage() {
|
function sendMessage() {
|
||||||
console.log($("#sendMessageForm").serialize());
|
console.log($("#sendMessageForm").serialize());
|
||||||
$.post(
|
$.post(
|
||||||
"sendMessage.php",
|
"API/sendMessage.php",
|
||||||
$("#sendMessageForm").serialize()
|
$("#sendMessageForm").serialize()
|
||||||
).done(function( data ) {
|
).done(function( data ) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
@@ -51,7 +53,14 @@ function addMessages(messages) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function switchUser(userID) {
|
function switchUser(userID) {
|
||||||
|
$(".chat-field").show();
|
||||||
$(".destinationID").val(userID);
|
$(".destinationID").val(userID);
|
||||||
$("#chat-history").html("");
|
$("#chat-history").html("");
|
||||||
$("#lastID").val("");
|
$("#lastID").val("");
|
||||||
|
$(".chat-left .friend-item").removeClass("active-friend-chat");
|
||||||
|
$(".chat-left #friend-item-" + userID).addClass("active-friend-chat");
|
||||||
|
}
|
||||||
|
|
||||||
|
function sayEmpty() {
|
||||||
|
$("#chat-history").html("Begin nu met chatten!");
|
||||||
}
|
}
|
||||||
@@ -89,3 +89,8 @@
|
|||||||
border-radius: 0 10px 10px 0;
|
border-radius: 0 10px 10px 0;
|
||||||
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
|
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.active-friend-chat {
|
||||||
|
background: aquamarine;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
@@ -30,9 +30,14 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.friend-item:hover {
|
||||||
|
background: #845663;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
.menu button {
|
.menu button {
|
||||||
background: none;
|
background: none;
|
||||||
color: #333;
|
color: inherit;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ require("connect.php");
|
|||||||
function selectAllFriends($db, $userID) {
|
function selectAllFriends($db, $userID) {
|
||||||
$stmt = $db->prepare("
|
$stmt = $db->prepare("
|
||||||
SELECT
|
SELECT
|
||||||
|
`userID`,
|
||||||
`username`,
|
`username`,
|
||||||
IFNULL(
|
IFNULL(
|
||||||
`profilepicture`,
|
`profilepicture`,
|
||||||
'img/notbad.png'
|
'img/notbad.jpg'
|
||||||
) AS profilepicture,
|
) AS profilepicture,
|
||||||
`onlinestatus`,
|
`onlinestatus`,
|
||||||
`role`
|
`role`
|
||||||
|
|||||||
@@ -2,13 +2,16 @@
|
|||||||
function getHeaderInfo() {
|
function getHeaderInfo() {
|
||||||
$stmt = $GLOBALS["db"]->prepare("
|
$stmt = $GLOBALS["db"]->prepare("
|
||||||
SELECT
|
SELECT
|
||||||
`fname`,
|
`fname`,
|
||||||
`lname`,
|
`lname`,
|
||||||
`profilepicture`
|
IFNULL(
|
||||||
|
`profilepicture`,
|
||||||
|
'img/notbad.jpg'
|
||||||
|
) AS profilepicture
|
||||||
FROM
|
FROM
|
||||||
`user`
|
`user`
|
||||||
WHERE
|
WHERE
|
||||||
`userID` = :userID
|
`userID` = :userID
|
||||||
");
|
");
|
||||||
$stmt->bindParam(":userID", $_SESSION["userID"]);
|
$stmt->bindParam(":userID", $_SESSION["userID"]);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
include_once("connect.php");
|
require_once("connect.php");
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
// Echo the friend.
|
// Echo the friend.
|
||||||
echo "
|
echo "
|
||||||
<li class='friend-item' onclick='switchUser(\"$userID\")'>
|
<li class='friend-item' id='friend-item-$userID' onclick='switchUser(\"$userID\")'>
|
||||||
<div class='friend'>
|
<div class='friend'>
|
||||||
<img alt='PF' class='profile-picture' src='$pf'/>
|
<img alt='PF' class='profile-picture' src='$pf'/>
|
||||||
$username
|
$username
|
||||||
@@ -38,12 +38,6 @@
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</ul>
|
</ul>
|
||||||
<!-- <a href="#">-->
|
|
||||||
<!-- <div class="chat-conversation">-->
|
|
||||||
<!-- <img class="profile-picture" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTDnuRSeeyPve7KwDvJJ6OBzj3gyghwLcE2z9kZeYBOyZavh3mw">-->
|
|
||||||
<!-- Rudolf Leslo-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- </a>-->
|
|
||||||
</nav>
|
</nav>
|
||||||
<div class="chat-right right">
|
<div class="chat-right right">
|
||||||
<div id="chat-history" class="chat-history platform">
|
<div id="chat-history" class="chat-history platform">
|
||||||
@@ -74,7 +68,7 @@
|
|||||||
<input type="text"
|
<input type="text"
|
||||||
name="content"
|
name="content"
|
||||||
id="newContent"
|
id="newContent"
|
||||||
placeholder="Reageer..."
|
placeholder="Schrijf een bericht..."
|
||||||
autofocus
|
autofocus
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user