Merge branch 'master' into hendrik-post
This commit is contained in:
@@ -54,7 +54,7 @@ function switchUser(userID) {
|
||||
$("#chat-history").html("");
|
||||
$("#lastID").val("");
|
||||
$("#chat-recent-panel .friend-item").removeClass("active-friend-chat");
|
||||
$("#chat-left #friend-item-" + userID).addClass("active-friend-chat");
|
||||
$("#friend-item-" + userID).addClass("active-friend-chat");
|
||||
}
|
||||
|
||||
function sayEmpty() {
|
||||
|
||||
24
website/public/js/friendButtons.js
Normal file
24
website/public/js/friendButtons.js
Normal file
@@ -0,0 +1,24 @@
|
||||
function placeFriendButtons() {
|
||||
$.post("API/getFriendshipStatus.php", { usr: userID })
|
||||
.done(function(data) {
|
||||
friendshipStatus = data;
|
||||
$buttonContainer = $("div.friend-button-container");
|
||||
$buttonContainer.children().remove();
|
||||
if (friendshipStatus == -1) {
|
||||
return;
|
||||
} else if(friendshipStatus == 0) {
|
||||
$buttonContainer.append($("<button class=\"green friend-button\" value=\"request\"><i class=\"fa fa-handshake-o\"></i> Bevriend</button>"));
|
||||
} else if(friendshipStatus == 1) {
|
||||
$buttonContainer.append($("<button class=\"red friend-button\" value=\"delete\"><i class=\"fa fa-times\"></i> Verwijder</button>"));
|
||||
} else if(friendshipStatus == 2) {
|
||||
$buttonContainer.append($("<button class=\"red friend-button\" value=\"delete\"><i class=\"fa fa-times\"></i> Trek verzoek in</button>"));
|
||||
} else if(friendshipStatus == 3) {
|
||||
$buttonContainer.append($("<button class=\"red friend-button\" value=\"delete\"><i class=\"fa fa-times\"></i> Weiger</button>"));
|
||||
$buttonContainer.append($("<button class=\"green friend-button\" value=\"accept\"><i class=\"fa fa-check\"></i> Accepteer</button>"));
|
||||
}
|
||||
|
||||
$buttonContainer.children().click(function() {
|
||||
editFriendship(userID, this.value);
|
||||
});
|
||||
});
|
||||
}
|
||||
45
website/public/js/main.js
Normal file
45
website/public/js/main.js
Normal file
@@ -0,0 +1,45 @@
|
||||
function editFriendship(userID, value) {
|
||||
$.post("API/editFriendship.php", { usr: userID, action: value })
|
||||
.done(function() {
|
||||
placeFriendButtons();
|
||||
});
|
||||
}
|
||||
|
||||
function showFriends(friends, list) {
|
||||
if(friends && friends != "[]") {
|
||||
$(list).load("bits/friend-item.php", {
|
||||
"friends": friends
|
||||
});
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function showFriendsPlus(friends, list, limit, action, actionType) {
|
||||
if(friends && friends != "[]") {
|
||||
$(list).load("bits/friend-item.php", {
|
||||
"friends": friends,
|
||||
"limit": limit,
|
||||
"action": action,
|
||||
"actionType": actionType
|
||||
});
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function showGroups(groups, list) {
|
||||
if(groups && groups != "[]") {
|
||||
$(list).load("bits/group-item.php", {
|
||||
"groups": groups
|
||||
});
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -11,12 +11,10 @@ function scrollbarMargin(width, overflow) {
|
||||
});
|
||||
}
|
||||
|
||||
function requestPost(post) {
|
||||
function requestPost(postID) {
|
||||
$(".modal").show();
|
||||
$.get(
|
||||
"API/loadPost.php",
|
||||
$(post).children("form").serialize()
|
||||
).done(function (data) {
|
||||
|
||||
$.get("API/loadPost.php", { postID : postID }).done(function(data) {
|
||||
$('.modal-default').hide();
|
||||
var scrollBarWidth = window.innerWidth - document.body.offsetWidth;
|
||||
scrollbarMargin(scrollBarWidth, 'hidden');
|
||||
@@ -26,37 +24,55 @@ function requestPost(post) {
|
||||
}
|
||||
|
||||
$(window).on("load", function() {
|
||||
console.log("LOADED");
|
||||
container = $("div.posts");
|
||||
posts = container.children();
|
||||
posts.remove();
|
||||
|
||||
column = $('<div class="column"></div>').append(posts);
|
||||
container.append(column);
|
||||
|
||||
mansonry();
|
||||
mansonry();
|
||||
$(".modal-close").click(function () {
|
||||
$(".modal").hide();
|
||||
scrollbarMargin(0, 'auto');
|
||||
$('#modal-response').hide();
|
||||
$('.modal-default').show();
|
||||
});
|
||||
});
|
||||
|
||||
var masonryMode = 0;
|
||||
|
||||
$(window).resize(function() {
|
||||
clearTimeout(window.resizedFinished);
|
||||
window.resizeFinished = setTimeout(function() {
|
||||
mansonry();
|
||||
masonry(masonryMode);
|
||||
}, 250);
|
||||
});
|
||||
|
||||
function mansonry() {
|
||||
var $container = $(".posts");
|
||||
|
||||
function masonry(mode) {
|
||||
masonryMode = mode;
|
||||
$container.children().remove();
|
||||
columnCount = Math.floor($(".posts").width() / 250);
|
||||
console.log("columns: " + columnCount);
|
||||
|
||||
/*
|
||||
* Initialise columns.
|
||||
*/
|
||||
var columns = new Array(columnCount);
|
||||
var $columns = new Array(columnCount);
|
||||
for (i = 0; i < columnCount; i++) {
|
||||
columns[i] = [0, []];
|
||||
console.log(columns[i]);
|
||||
$column = $("<div class=\"column\">");
|
||||
$column.width(100/columnCount + "%");
|
||||
$container.append($column);
|
||||
columns[i] = [0, $column];
|
||||
}
|
||||
|
||||
if(mode == 1) {
|
||||
$postInput = $("<div class=\"post platform\">");
|
||||
$form = $("<form action=\"API/postPost.php\" method=\"post\">");
|
||||
$postInput.append($form);
|
||||
|
||||
$form.append($("<input class=\"newpost\" name=\"newpost-title\" placeholder=\"Titel\" type=\"text\">"));
|
||||
$form.append($("<textarea class=\"newpost\" name=\"newpost-content\" placeholder=\"Schrijf een berichtje...\">"));
|
||||
$form.append($("<input value=\"Plaats!\" type=\"submit\">"));
|
||||
columns[0][1].append($postInput);
|
||||
|
||||
$postInput.on("load", function() {
|
||||
columns[0][0] = $postInput.height() + margin;
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -70,38 +86,29 @@ function mansonry() {
|
||||
column = columns[i];
|
||||
}
|
||||
}
|
||||
|
||||
return column;
|
||||
}
|
||||
|
||||
/*
|
||||
* Rearange the objects.
|
||||
* Get the posts from the server.
|
||||
*/
|
||||
j = 0;
|
||||
posts.each(function(i) {
|
||||
post = posts[i];
|
||||
shortestColumn = getShortestColumn(columns);
|
||||
shortestColumn[0] = shortestColumn[0] + $(post).height() + margin;
|
||||
shortestColumn[1].push(post);
|
||||
$.post("API/getPosts.php", { usr : userID })
|
||||
.done(function(data) {
|
||||
posts = JSON.parse(data);
|
||||
|
||||
});
|
||||
|
||||
container.children().remove();
|
||||
/*
|
||||
* Display the objects again in the correct order.
|
||||
*/
|
||||
for (i = 0; i < columnCount; i++) {
|
||||
column = $('<div class="column"></div>').append(columns[i][1]);
|
||||
console.log(column);
|
||||
container.append(column);
|
||||
}
|
||||
/*
|
||||
* Rearange the objects.
|
||||
*/
|
||||
jQuery.each(posts, function() {
|
||||
$post = $("<div class=\"post platform\" onclick=\"requestPost(\'"+this['postID']+"\')\">");
|
||||
$post.append($("<h2>").text(this["title"]));
|
||||
$post.append($("<p>").html(this["content"]));
|
||||
$post.append($("<p class=\"subscript\">").text(this["nicetime"]));
|
||||
|
||||
$("div.posts div.column").width(100/columnCount + "%");
|
||||
shortestColumn = getShortestColumn(columns);
|
||||
shortestColumn[1].append($post);
|
||||
shortestColumn[0] = shortestColumn[0] + $post.height() + margin;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$(".modal-close").click(function () {
|
||||
$(".modal").hide();
|
||||
scrollbarMargin(0, 'auto');
|
||||
$('#modal-response').hide();
|
||||
$('.modal-default').show();
|
||||
});
|
||||
}
|
||||
@@ -1,39 +1,108 @@
|
||||
|
||||
$(document).ready(function() {
|
||||
$(".extra-menu-items").hide();
|
||||
$("#menu-back").hide();
|
||||
// Show more friends/users
|
||||
|
||||
// Show more friends
|
||||
$("#more-friends-click").click(function() {
|
||||
// Show only friends
|
||||
$("#groups-menu-section").slideUp();
|
||||
$("#friends-menu-section li").show();
|
||||
// $("#more-friends-click").click(function() {
|
||||
// // Show only friends
|
||||
// $("#groups-menu-section").slideUp();
|
||||
// $("#friends-menu-section li").show();
|
||||
//
|
||||
// // Change buttons
|
||||
// $("#more-friends-click").hide();
|
||||
// $("#menu-back").show();
|
||||
// });
|
||||
//
|
||||
// // Show more groups
|
||||
// $("#more-groups-click").click(function() {
|
||||
// // Show only groups
|
||||
// $("#friends-menu-section").slideUp();
|
||||
// $("#groups-menu-section li").show();
|
||||
//
|
||||
// // Change buttons
|
||||
// $("#more-groups-click").hide();
|
||||
// $("#menu-back").show();
|
||||
// });
|
||||
|
||||
// Change buttons
|
||||
$("#more-friends-click").hide();
|
||||
$("#menu-back").show();
|
||||
});
|
||||
// // Go back
|
||||
// $("#menu-back").click(function() {
|
||||
// // Show overview of friends and groups
|
||||
// $("#friends-menu-section").slideDown();
|
||||
// $("#groups-menu-section").slideDown();
|
||||
// $(".extra-menu-items").hide();
|
||||
//
|
||||
// // Change buttons
|
||||
// $("#menu-back").hide();
|
||||
// $("#more-groups-click").show();
|
||||
// $("#more-friends-click").show();
|
||||
// });
|
||||
|
||||
// Show more groups
|
||||
$("#more-groups-click").click(function() {
|
||||
// Show only groups
|
||||
$("#friends-menu-section").slideUp();
|
||||
$("#groups-menu-section li").show();
|
||||
|
||||
// Change buttons
|
||||
$("#more-groups-click").hide();
|
||||
$("#menu-back").show();
|
||||
});
|
||||
|
||||
// Go back
|
||||
$("#menu-back").click(function() {
|
||||
// Show overview of friends and groups
|
||||
$("#friends-menu-section").slideDown();
|
||||
$("#groups-menu-section").slideDown();
|
||||
$(".extra-menu-items").hide();
|
||||
|
||||
// Change buttons
|
||||
$("#menu-back").hide();
|
||||
$("#more-groups-click").show();
|
||||
$("#more-friends-click").show();
|
||||
});
|
||||
loadMenuFriends(5);
|
||||
loadNotificationFriends();
|
||||
loadUnreadMessages();
|
||||
loadMenuGroups();
|
||||
});
|
||||
|
||||
|
||||
function loadMenuFriends(limit) {
|
||||
$.post(
|
||||
"API/loadFriends.php",
|
||||
{
|
||||
limit: 5
|
||||
}
|
||||
).done(function(data) {
|
||||
if (showFriends(data, "#menu-friends-list", 5, "profile.php", "GET", limit)) {
|
||||
$("#friends-menu-section").show();
|
||||
} else {
|
||||
$("#friends-menu-section").hide();
|
||||
}
|
||||
});
|
||||
|
||||
setTimeout(loadMenuFriends, 3000, limit);
|
||||
}
|
||||
|
||||
function loadMenuGroups() {
|
||||
$.post(
|
||||
"API/loadGroups.php",
|
||||
{
|
||||
limit: 5
|
||||
}
|
||||
).done(function(data) {
|
||||
if (showGroups(data, "#menu-groups-list")) {
|
||||
$("#groups-menu-section").show();
|
||||
} else {
|
||||
$("#groups-menu-section").hide();
|
||||
}
|
||||
});
|
||||
|
||||
setTimeout(loadMenuGroups, 3000);
|
||||
}
|
||||
|
||||
function loadNotificationFriends() {
|
||||
$.post(
|
||||
"API/loadFriendRequest.php"
|
||||
).done(function(data) {
|
||||
if (showFriendsPlus(data, "#friend-requests-list", 5, "profile.php", "GET")) {
|
||||
$("#friend-request-section").show();
|
||||
} else {
|
||||
$("#friend-request-section").hide();
|
||||
}
|
||||
});
|
||||
|
||||
setTimeout(loadNotificationFriends, 3000);
|
||||
}
|
||||
|
||||
function loadUnreadMessages() {
|
||||
$.post(
|
||||
"API/loadChatNotifications.php"
|
||||
).done(function(data) {
|
||||
if (showFriendsPlus(data, "#unread-chat-list", 5, "chat.php", "GET")) {
|
||||
console.log(data);
|
||||
$("#unread-messages-section").show();
|
||||
} else {
|
||||
$("#unread-messages-section").hide();
|
||||
}
|
||||
});
|
||||
|
||||
setTimeout(loadUnreadMessages, 3000);
|
||||
}
|
||||
@@ -1,89 +1,43 @@
|
||||
function showFriendNotifications(notifications) {
|
||||
$("#friendrequestslist").html("");
|
||||
for (i in notifications) {
|
||||
var outgoing = "";
|
||||
if (notifications[i].friend_state == "3") {
|
||||
outgoing = "<button\
|
||||
name='accept' \
|
||||
class='accept-notification' \
|
||||
value='"+ notifications[i].userID +"'> \
|
||||
<i class='fa fa-check'></i> \
|
||||
</button>";
|
||||
}
|
||||
|
||||
$("#friendrequestslist").append(" \
|
||||
<li class='friend-item'> \
|
||||
<form action='profile.php' method='get'> \
|
||||
<button type='submit' \
|
||||
name='username' \
|
||||
value='"+ notifications[i].username +"'> \
|
||||
<div class='friend'> \
|
||||
<img alt='PF' class='profile-picture' src='"+ notifications[i].profilepicture +"'/> \
|
||||
"+ notifications[i].username +" \
|
||||
</div> \
|
||||
</button> \
|
||||
</form> \
|
||||
<div class='notification-options'>\
|
||||
<form action='API/edit_friendship.php' method='post'> \
|
||||
<input type='hidden' name='userID' value='"+ notifications[i].userID +"' /> \
|
||||
"+ outgoing +" \
|
||||
<button type='submit' \
|
||||
name='delete' \
|
||||
class='deny-notification' \
|
||||
value='"+ notifications[i].userID +"'> \
|
||||
<i class='fa fa-times'></i> \
|
||||
</button>\
|
||||
<form>\
|
||||
</div> \
|
||||
</li> \
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
function showChatNotifications(notifications) {
|
||||
$("#unreadChatlist").html("");
|
||||
for (i in notifications) {
|
||||
$("#unreadChatlist").append(" \
|
||||
<li class='friend-item'> \
|
||||
<form action='chat.php' method='get'> \
|
||||
<button type='submit' \
|
||||
name='chatID' \
|
||||
value='"+ notifications[i].userID +"'> \
|
||||
<div class='friend'> \
|
||||
<img alt='PF' class='profile-picture' src='"+ notifications[i].profilepicture +"'/> \
|
||||
<div class='friend-name'> \
|
||||
"+ notifications[i].name +"<br/> \
|
||||
<span style='color: #666'>"+ notifications[i].content +"</span> \
|
||||
</div> \
|
||||
</div> \
|
||||
</button> \
|
||||
</form> \
|
||||
</li> \
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
function loadNotifications() {
|
||||
$.post(
|
||||
"API/loadFriendRequestNotifications.php"
|
||||
).done(function(data) {
|
||||
if (data && data != "[]") {
|
||||
showFriendNotifications(JSON.parse(data));
|
||||
}
|
||||
});
|
||||
$.post(
|
||||
"API/loadChatNotifications.php"
|
||||
).done(function(data) {
|
||||
if (data && data != "[]") {
|
||||
showChatNotifications(JSON.parse(data));
|
||||
}
|
||||
});
|
||||
|
||||
setTimeout(loadNotifications, 10000);
|
||||
}
|
||||
$(document).ready(function() {
|
||||
loadNotifications();
|
||||
});
|
||||
// function showChatNotifications(notifications) {
|
||||
// $("#unreadChatlist").html("");
|
||||
// for (i in notifications) {
|
||||
// $("#unreadChatlist").append(" \
|
||||
// <li class='friend-item'> \
|
||||
// <form action='chat.php' method='get'> \
|
||||
// <button type='submit' \
|
||||
// name='chatID' \
|
||||
// value='"+ notifications[i].userID +"'> \
|
||||
// <div class='friend'> \
|
||||
// <img alt='PF' class='profile-picture' src='"+ notifications[i].profilepicture +"'/> \
|
||||
// <div class='friend-name'> \
|
||||
// "+ notifications[i].name +"<br/> \
|
||||
// <span style='color: #666'>"+ notifications[i].content +"</span> \
|
||||
// </div> \
|
||||
// </div> \
|
||||
// </button> \
|
||||
// </form> \
|
||||
// </li> \
|
||||
// ");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// function loadNotifications() {
|
||||
// $.post(
|
||||
// "API/loadChatNotifications.php"
|
||||
// ).done(function(data) {
|
||||
// if (data && data != "[]") {
|
||||
// $("#unread-messages-section").show();
|
||||
// showChatNotifications(JSON.parse(data));
|
||||
// } else {
|
||||
// $("#unread-messages-section").hide();
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// setTimeout(loadNotifications, 10000);
|
||||
// }
|
||||
// $(document).ready(function() {
|
||||
// loadNotifications();
|
||||
// });
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -12,4 +12,4 @@ function bannedAlert(){
|
||||
|
||||
function emailNotConfirmed(){
|
||||
alert("Your account has not been verified yet!\nAnother email has been sent to you")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user