fixed friends and comments (for the most part)
do you ever just...
This commit is contained in:
parent
9a0c8a9c78
commit
ff422ab7e2
3 changed files with 33 additions and 55 deletions
|
@ -26,7 +26,7 @@ class CommentsController extends Controller
|
||||||
public function post(string $category = '', int $reply = 0): string
|
public function post(string $category = '', int $reply = 0): string
|
||||||
{
|
{
|
||||||
// Check if the user can comment
|
// Check if the user can comment
|
||||||
if (session_check()) {
|
if (!session_check()) {
|
||||||
$error = "Your session expired, refresh the page!";
|
$error = "Your session expired, refresh the page!";
|
||||||
return $this->json(compact('error'));
|
return $this->json(compact('error'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ class FriendsController extends Controller
|
||||||
$user = CurrentSession::$user;
|
$user = CurrentSession::$user;
|
||||||
|
|
||||||
// Check if the user can comment
|
// Check if the user can comment
|
||||||
if (session_check()) {
|
if (!session_check()) {
|
||||||
$error = "Your session expired, refresh the page!";
|
$error = "Your session expired, refresh the page!";
|
||||||
return $this->json(compact('error'));
|
return $this->json(compact('error'));
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ class FriendsController extends Controller
|
||||||
$user = CurrentSession::$user;
|
$user = CurrentSession::$user;
|
||||||
|
|
||||||
// Check if the user can comment
|
// Check if the user can comment
|
||||||
if (session_check()) {
|
if (!session_check()) {
|
||||||
$error = "Your session expired, refresh the page!";
|
$error = "Your session expired, refresh the page!";
|
||||||
return $this->json(compact('error'));
|
return $this->json(compact('error'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,100 +70,78 @@
|
||||||
function commentAdd(obj) {
|
function commentAdd(obj) {
|
||||||
var container = document.createElement('li');
|
var container = document.createElement('li');
|
||||||
container.id = "comment-" + obj.id;
|
container.id = "comment-" + obj.id;
|
||||||
|
container.className = 'comment-container';
|
||||||
|
|
||||||
var inner = document.createElement('div');
|
var inner = document.createElement('div');
|
||||||
inner.className = 'comment';
|
inner.className = 'comment';
|
||||||
|
|
||||||
var avatar = document.createElement('a');
|
var avatar = document.createElement('a');
|
||||||
avatar.className = 'comment-avatar clean';
|
avatar.className = 'avatar avatar--border comment__avatar';
|
||||||
|
|
||||||
|
if (!obj.reply) {
|
||||||
|
avatar.className += ' comment__avatar--big';
|
||||||
|
}
|
||||||
|
|
||||||
avatar.href = "{{ route('user.profile', 1) }}".replace(1, obj.user);
|
avatar.href = "{{ route('user.profile', 1) }}".replace(1, obj.user);
|
||||||
avatar.style.backgroundImage = "url('{{ route('user.avatar', 1) }}')".replace(1, obj.user);
|
avatar.style.backgroundImage = "url('{{ route('user.avatar', 1) }}')".replace(1, obj.user);
|
||||||
inner.appendChild(avatar);
|
inner.appendChild(avatar);
|
||||||
|
|
||||||
var pointer = document.createElement('div');
|
var pointer = document.createElement('div');
|
||||||
pointer.className = 'comment-pointer';
|
pointer.className = 'comment__pointer';
|
||||||
inner.appendChild(pointer);
|
inner.appendChild(pointer);
|
||||||
|
|
||||||
var content = document.createElement('div');
|
var content = document.createElement('div');
|
||||||
content.className = 'comment-content';
|
content.className = 'comment__content';
|
||||||
|
|
||||||
var controls = document.createElement('div');
|
var controls = document.createElement('div');
|
||||||
controls.className = 'comment-controls';
|
controls.className = 'comment__controls';
|
||||||
|
|
||||||
var controlsInner = document.createElement('ul');
|
var controlsInner = document.createElement('ul');
|
||||||
|
|
||||||
if (Sakura.Cookies.Get(sakuraVars.cookie.prefix + 'id') == obj.user) {
|
if (Sakura.Config.LoggedIn && Sakura.Config.UserId === obj.user) {
|
||||||
var controlsTrashContainer = document.createElement('li');
|
var controlsTrash = document.createElement('div');
|
||||||
var controlsTrash = document.createElement('a');
|
|
||||||
controlsTrash.href = 'javascript:void(0);';
|
|
||||||
controlsTrash.title = 'Delete';
|
controlsTrash.title = 'Delete';
|
||||||
controlsTrash.className = 'clean fa fa-trash-o';
|
controlsTrash.className = 'fa fa-trash-o comment__control';
|
||||||
controlsTrash.setAttribute('onclick', 'commentDelete(' + obj.id + ');');
|
controlsTrash.setAttribute('onclick', 'commentDelete(' + obj.id + ');');
|
||||||
controlsTrashContainer.appendChild(controlsTrash);
|
controls.appendChild(controlsTrash);
|
||||||
controlsInner.appendChild(controlsTrashContainer);
|
|
||||||
} else {
|
|
||||||
var controlsReportContainer = document.createElement('li');
|
|
||||||
var controlsReport = document.createElement('a');
|
|
||||||
controlsReport.href = '#';
|
|
||||||
controlsReport.title = 'Report';
|
|
||||||
controlsReport.className = 'clean fa fa-trash-o';
|
|
||||||
controlsReportContainer.appendChild(controlsReport);
|
|
||||||
controlsInner.appendChild(controlsReportContainer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var controlsReplyContainer = document.createElement('li');
|
var controlsReply = document.createElement('div');
|
||||||
var controlsReply = document.createElement('a');
|
|
||||||
controlsReply.href = 'javascript:void(0);';
|
|
||||||
controlsReply.title = 'Reply';
|
controlsReply.title = 'Reply';
|
||||||
controlsReply.className = 'clean fa fa-reply';
|
controlsReply.className = 'fa fa-reply comment__control';
|
||||||
controlsReply.setAttribute('onclick', 'commentReply(' + obj.id + ', "{{ session_id() }}", "{{ route("user.avatar", user.id) }}");');
|
controlsReply.setAttribute('onclick', 'commentReply(' + obj.id + ', "{{ session_id() }}", "{{ route("user.avatar", user.id) }}");');
|
||||||
controlsReplyContainer.appendChild(controlsReply);
|
controls.appendChild(controlsReply);
|
||||||
controlsInner.appendChild(controlsReplyContainer);
|
|
||||||
|
|
||||||
var controlsLikeContainer = document.createElement('li');
|
var controlsLike = document.createElement('div');
|
||||||
controlsLikeContainer.className = 'shown voting like';
|
|
||||||
var controlsLike = document.createElement('a');
|
|
||||||
controlsLike.href = 'javascript:void(0);';
|
|
||||||
controlsLike.setAttribute('onclick', 'commentVote(' + obj.id + ', 1);');
|
controlsLike.setAttribute('onclick', 'commentVote(' + obj.id + ', 1);');
|
||||||
controlsLike.className = 'clean';
|
controlsLike.className = 'comment__control comment__control--vote comment__control--vote-up';
|
||||||
var controlsLikeIcon = document.createElement('span');
|
var controlsLikeIcon = document.createElement('span');
|
||||||
controlsLikeIcon.className = 'fa fa-thumbs-up';
|
controlsLikeIcon.className = 'fa fa-chevron-up';
|
||||||
controlsLike.appendChild(controlsLikeIcon);
|
controlsLike.appendChild(controlsLikeIcon);
|
||||||
controlsLike.innerHTML += "\r\n";
|
controlsLike.innerHTML += "\r\n";
|
||||||
var controlsLikeCount = document.createElement('span');
|
var controlsLikeCount = document.createElement('span');
|
||||||
controlsLikeCount.id = 'comment-' + obj.id + '-likes';
|
controlsLikeCount.id = 'comment-' + obj.id + '-likes';
|
||||||
controlsLikeCount.innerText = obj.upvotes;
|
controlsLikeCount.innerText = obj.upvotes;
|
||||||
controlsLike.appendChild(controlsLikeCount);
|
controlsLike.appendChild(controlsLikeCount);
|
||||||
controlsLikeContainer.appendChild(controlsLike);
|
controls.appendChild(controlsLike);
|
||||||
controlsInner.appendChild(controlsLikeContainer);
|
|
||||||
|
|
||||||
var controlsDislikeContainer = document.createElement('li');
|
var controlsDislike = document.createElement('div');
|
||||||
controlsDislikeContainer.className = 'shown voting dislike';
|
|
||||||
var controlsDislike = document.createElement('a');
|
|
||||||
controlsDislike.href = 'javascript:void(0);';
|
|
||||||
controlsDislike.setAttribute('onclick', 'commentVote(' + obj.id + ', 0);');
|
controlsDislike.setAttribute('onclick', 'commentVote(' + obj.id + ', 0);');
|
||||||
controlsDislike.className = 'clean';
|
controlsDislike.className = 'comment__control comment__control--vote comment__control--vote-down';
|
||||||
var controlsDislikeIcon = document.createElement('span');
|
var controlsDislikeIcon = document.createElement('span');
|
||||||
controlsDislikeIcon.className = 'fa fa-thumbs-down';
|
controlsDislikeIcon.className = 'fa fa-chevron-down';
|
||||||
controlsDislike.appendChild(controlsDislikeIcon);
|
controlsDislike.appendChild(controlsDislikeIcon);
|
||||||
controlsDislike.innerHTML += "\r\n";
|
controlsDislike.innerHTML += "\r\n";
|
||||||
var controlsDislikeCount = document.createElement('span');
|
var controlsDislikeCount = document.createElement('span');
|
||||||
controlsDislikeCount.id = 'comment-' + obj.id + '-dislikes';
|
controlsDislikeCount.id = 'comment-' + obj.id + '-dislikes';
|
||||||
controlsDislikeCount.innerText = obj.upvotes;
|
controlsDislikeCount.innerText = obj.upvotes;
|
||||||
controlsDislike.appendChild(controlsDislikeCount);
|
controlsDislike.appendChild(controlsDislikeCount);
|
||||||
controlsDislikeContainer.appendChild(controlsDislike);
|
controls.appendChild(controlsDislike);
|
||||||
controlsInner.appendChild(controlsDislikeContainer);
|
|
||||||
|
|
||||||
controls.appendChild(controlsInner);
|
|
||||||
|
|
||||||
var clear = document.createElement('div');
|
|
||||||
clear.className = 'clear';
|
|
||||||
controls.appendChild(clear);
|
|
||||||
|
|
||||||
content.appendChild(controls);
|
content.appendChild(controls);
|
||||||
|
|
||||||
var text = document.createElement('text');
|
var text = document.createElement('text');
|
||||||
text.className = 'comment-text';
|
text.className = 'comment__text';
|
||||||
text.innerHTML = obj.text;
|
text.innerHTML = obj.text;
|
||||||
content.appendChild(text);
|
content.appendChild(text);
|
||||||
|
|
||||||
|
@ -171,7 +149,7 @@
|
||||||
container.appendChild(inner);
|
container.appendChild(inner);
|
||||||
|
|
||||||
var replies = document.createElement('ul');
|
var replies = document.createElement('ul');
|
||||||
replies.className = 'comment-replies';
|
replies.className = 'comment__replies';
|
||||||
container.appendChild(replies);
|
container.appendChild(replies);
|
||||||
|
|
||||||
var discussion = document.getElementById('comments').querySelector('.comments__list');
|
var discussion = document.getElementById('comments').querySelector('.comments__list');
|
||||||
|
@ -248,10 +226,10 @@
|
||||||
replyContainer.appendChild(replyDiv);
|
replyContainer.appendChild(replyDiv);
|
||||||
|
|
||||||
// Insert the HTML
|
// Insert the HTML
|
||||||
if (replyingTo.querySelector('.comment-replies').children.length > 0) {
|
if (replyingTo.querySelector('.comment__replies').children.length > 0) {
|
||||||
replyingTo.querySelector('.comment-replies').insertBefore(replyContainer, replyingTo.querySelector('.comment-replies').firstChild);
|
replyingTo.querySelector('.comment__replies').insertBefore(replyContainer, replyingTo.querySelector('.comment__replies').firstChild);
|
||||||
} else {
|
} else {
|
||||||
replyingTo.querySelector('.comment-replies').appendChild(replyContainer);
|
replyingTo.querySelector('.comment__replies').appendChild(replyContainer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue