Archived
1
0

Implement feature for deleting posts and improving ajax requests

This commit is contained in:
Marcel 2018-10-17 13:56:22 +02:00
parent b32b2790c8
commit 334aa22362
23 changed files with 193 additions and 96 deletions

View File

@ -211,6 +211,39 @@
exit; exit;
} }
if($post[0]['user_id'] != $_SESSION['user']['ID']) {
echo json_encode(['success' => false, 'message' => 'Du kannst keine Posts löschen, die dir nicht gehören.']);
exit;
}
$post = $this->PostsModel->preparePostList($post);
$body = $this->load->view('network/posts/delete_modal', ['post' => $post[0]], true);
echo json_encode(['success' => true, 'title' => 'Post löschen', 'body' => $body]);
}
public function deletePost() {
header('Content-Type: application/json');
if(!isset($_SESSION['user'])) {
echo json_encode(['success' => false, 'message' => 'Du musst eingeloggt sein, um die Posts deines Accounts zu löschen']);
exit;
}
$uuid = $this->input->post('uuid');
$post = $this->PostsModel->getPostByUUID($uuid);
if(empty($post)) {
echo json_encode(['success' => false, 'message' => 'Der angegebene Post existiert nicht.']);
exit;
}
if($post[0]['user_id'] != $_SESSION['user']['ID']) {
echo json_encode(['success' => false, 'message' => 'Du kannst keine Posts löschen, die dir nicht gehören.']);
exit;
}
$this->PostsModel->deletePost($_SESSION['user']['ID'], $uuid);
echo json_encode(['success' => true, 'message' => 'Der Post wurde erfolgreich gelöscht.']);
} }
} }

View File

@ -210,14 +210,13 @@
Bitte erstelle dir entweder Bitte erstelle dir entweder
<a href="<?= base_url('login') ?>">kostenlos einen neuen Account</a> <a href="<?= base_url('login') ?>">kostenlos einen neuen Account</a>
oder oder
<a href="<?= base_url('login') ?>">melde dich an</a>. <a href="<?= base_url('login') ?>">melde dich an</a>
.
</div> </div>
<?php <?php
exit; exit;
} }
var_dump($this->input->post('postMedia'));
$content = $this->input->post('content'); $content = $this->input->post('content');
if (strlen($content) >= 10000) { if (strlen($content) >= 10000) {
?> ?>
@ -247,23 +246,25 @@
} }
$media = $this->input->post('postMedia'); $media = $this->input->post('postMedia');
foreach ($media as $entry) { if (!empty($media)) {
$image = str_replace(' ', '+', $entry['image']); foreach ($media as $entry) {
$image = substr($image, strpos($image, ',') + 1); $image = str_replace(' ', '+', $entry['image']);
$image = base64_decode($image); $image = substr($image, strpos($image, ',') + 1);
$image = base64_decode($image);
$fileUrl = $this->FileModel->uploadFileByContent($image, $entry['name'], $entry['type'], $entry['size']); $fileUrl = $this->FileModel->uploadFileByContent($image, $entry['name'], $entry['type'], $entry['size']);
$this->PostsModel->addImageToPost($postID, $fileUrl); $this->PostsModel->addImageToPost($postID, $fileUrl);
}
?>
<div class="alert alert-success" role="alert">
<b>Dein Post wurde erfolgreich veröffentlicht!</b> Möchtest du nun deine Posts ansehen? <br>
<button type="button" class="btn btn-sm btn-default" data-dismiss="modal">Nein</button>
<a href='<?= base_url('user/' . $_SESSION['user']['username'] . '/posts') ?>' class='btn btn-sm btn-primary'>Ja</a>
</div>
<?php
} }
?>
<div class="alert alert-success" role="alert">
<b>Dein Post wurde erfolgreich veröffentlicht!</b> Möchtest du nun deine Posts ansehen? <br>
<button type="button" class="btn btn-sm btn-default" data-dismiss="modal">Nein</button>
<a href='<?= base_url('user/' . $_SESSION['user']['username'] . '/posts') ?>' class='btn btn-sm btn-primary'>Ja</a>
</div>
<?php
} }
public function followers($user = "") public function followers($user = "")

View File

@ -39,6 +39,15 @@
return $insertedPost[0]['ID']; return $insertedPost[0]['ID'];
} }
public function deletePost($userID, $uuid) {
$postID = $this->db->query('SELECT ID FROM user_posts WHERE user_id = ? AND uuid = ?', [$userID, $uuid])->result_array()[0]['ID'];
$this->db->query('DELETE FROM user_posts WHERE user_id = ? AND uuid = ?', [$userID, $uuid]);
$this->db->query('DELETE FROM user_posts_hashtags WHERE postID = ?', [$postID]);
$this->db->query('DELETE FROM user_posts_mentions WHERE postID = ?', [$postID]);
$this->db->query('DELETE FROM user_posts_likes WHERE postID = ?', [$postID]);
$this->db->query('DELETE FROM user_posts_media WHERE postID = ?', [$postID]);
}
public function addImageToPost($postID, $imageUrl) { public function addImageToPost($postID, $imageUrl) {
$this->db->query('INSERT INTO user_posts_media (postID, mediaType, mediaUrl) VALUES (?, ?, ?)', [$postID, 'image', $imageUrl]); $this->db->query('INSERT INTO user_posts_media (postID, mediaType, mediaUrl) VALUES (?, ?, ?)', [$postID, 'image', $imageUrl]);
} }
@ -284,7 +293,9 @@
} }
public function getPostByUUID($uuid) { public function getPostByUUID($uuid) {
$this->db->cache_off();
$result = $this->db->query('SELECT * FROM user_posts WHERE uuid = ?', [$uuid])->result_array(); $result = $this->db->query('SELECT * FROM user_posts WHERE uuid = ?', [$uuid])->result_array();
$this->db->cache_on();
return $result; return $result;
} }

View File

@ -0,0 +1,21 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<form id="postDeleteForm">
<div class="alert alert-danger" role="alert">
<b>Bist du dir wirklich sicher, dass du diesen Post löschen willst?</b>
<ul class="comment-list" style="pointer-events: none">
<?php
$post['hideActionBtns'] = true;
$this->load->view('network/posts/post_item', $post) ?>
</ul>
<!-- --><?php //var_dump($post) ?>
</div>
<button type="reset" class="btn btn-sm btn-primary round float-right" data-dismiss="modal">
Nein, Post behalten
</button>
<button type="submit" class="btn btn-sm btn-red outline round float-right" onclick="deletePost('<?= $post['uuid'] ?>')">
Ja, endgültig löschen
</button>
</form>

View File

@ -43,39 +43,41 @@
</div> </div>
<?php endif; ?> <?php endif; ?>
</div> </div>
<div class="action-btns"> <?php if (!isset($hideActionBtns) || !$hideActionBtns): ?>
<a href="#" data-uuid="<?= $uuid ?>" class="action-btn reply-button" data-toggle="tooltip" data-placement="top" title="Antworten"> <div class="action-btns">
<i class="far fa-comment"></i> <a href="#" data-uuid="<?= $uuid ?>" class="action-btn reply-button" data-toggle="tooltip" data-placement="top" title="Antworten">
<span><?= $replyCount ?></span> <i class="far fa-comment"></i>
</a> <span><?= $replyCount ?></span>
<a href="#" data-uuid="<?= $uuid ?>" class="action-btn like-button <?= isset($userHasLiked) && $userHasLiked ? 'active' : '' ?>" data-toggle="tooltip" data-placement="top" title="Gefällt mir">
<i class="<?= isset($userHasLiked) && $userHasLiked ? 'fas' : 'far' ?> fa-heart"></i>
<span><?= $likeCount ?></span>
</a>
<div class="action-btn dropdown">
<a href="#" class="action-btn more-options-button" id="postMoreOptionsButton<?= $uuid ?>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-ellipsis-h"></i>
</a> </a>
<a href="#" data-uuid="<?= $uuid ?>" class="action-btn like-button <?= isset($userHasLiked) && $userHasLiked ? 'active' : '' ?>" data-toggle="tooltip" data-placement="top" title="Gefällt mir">
<i class="<?= isset($userHasLiked) && $userHasLiked ? 'fas' : 'far' ?> fa-heart"></i>
<span><?= $likeCount ?></span>
</a>
<div class="action-btn dropdown">
<a href="#" class="action-btn more-options-button" id="postMoreOptionsButton<?= $uuid ?>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-ellipsis-h"></i>
</a>
<div class="dropdown-menu" aria-labelledby="postMoreOptionsButton<?= $uuid ?>"> <div class="dropdown-menu" aria-labelledby="postMoreOptionsButton<?= $uuid ?>">
<a href="#" onclick="copyToClipboard('<?= base_url('user/' . $username . '/post/' . $uuid) ?>')" class="dropdown-item"> <a href="#" onclick="copyToClipboard('<?= base_url('user/' . $username . '/post/' . $uuid) ?>')" class="dropdown-item">
<i class="fa fa-copy"></i> <i class="fa fa-copy"></i>
Link zum Post kopieren Link zum Post kopieren
</a>
<a href="#" onclick="openPostReportModal('<?= $uuid ?>')" class="dropdown-item">
<i class="fa fa-flag"></i>
Post melden
</a>
<?php if (isset($_SESSION['user']) && $_SESSION['user']['username'] == $username): ?>
<div class="dropdown-divider"></div>
<a href="#" onclick="openDeletePostModal('<?= $uuid ?>')" class="dropdown-item text-danger">
<i class="fa fa-trash"></i>
Post löschen
</a> </a>
<?php endif; ?> <a href="#" onclick="openPostReportModal('<?= $uuid ?>')" class="dropdown-item">
<i class="fa fa-flag"></i>
Post melden
</a>
<?php if (isset($_SESSION['user']) && $_SESSION['user']['username'] == $username): ?>
<div class="dropdown-divider"></div>
<a href="#" onclick="openDeletePostModal('<?= $uuid ?>')" class="dropdown-item text-danger">
<i class="fa fa-trash"></i>
Post löschen
</a>
<?php endif; ?>
</div>
</div> </div>
</div> </div>
</div> <?php endif; ?>
</div> </div>
</div> </div>
</div> </div>

View File

@ -166,7 +166,7 @@ $('span').keyup(function (e) {
let tagsList = []; let tagsList = [];
$(function () { $(function () {
$.ajax({ $.ajax({
url: 'http://192.168.178.39/admin/blog/tagsList', url: '/admin/blog/tagsList',
method: 'GET', method: 'GET',
success: function (data) { success: function (data) {
console.log(data); console.log(data);
@ -222,7 +222,7 @@ $(function () {
function getPostData() { function getPostData() {
const postID = $('#postID').val(); const postID = $('#postID').val();
$.ajax({ $.ajax({
url: 'http://192.168.178.39/admin/blog/getPost', url: '/admin/blog/getPost',
method: 'post', method: 'post',
data: { data: {
postID postID
@ -255,7 +255,7 @@ function getContentData() {
const contentID = $('#contentID').val(); const contentID = $('#contentID').val();
const lang = $('#postLanguage').val(); const lang = $('#postLanguage').val();
$.ajax({ $.ajax({
url: 'http://192.168.178.39/admin/blog/getContent', url: '/admin/blog/getContent',
method: 'post', method: 'post',
data: { data: {
postID, contentID, lang postID, contentID, lang
@ -275,7 +275,7 @@ function getTranslationData() {
const translationID = $('#translationID').val(); const translationID = $('#translationID').val();
const lang = $('#postLanguage').val(); const lang = $('#postLanguage').val();
$.ajax({ $.ajax({
url: 'http://192.168.178.39/admin/blog/getTranslationData', url: '/admin/blog/getTranslationData',
method: 'post', method: 'post',
data: { data: {
postID, translationID, lang postID, translationID, lang
@ -294,7 +294,7 @@ function getTranslationData() {
function getPostTags() { function getPostTags() {
const postID = $('#postID').val(); const postID = $('#postID').val();
$.ajax({ $.ajax({
url: 'http://192.168.178.39/admin/blog/getPostTags', url: '/admin/blog/getPostTags',
method: 'POST', method: 'POST',
data: { data: {
postID postID
@ -367,7 +367,7 @@ function sendPost(executionFinished) {
postTags = $('#postTags').tagsinput('items'); postTags = $('#postTags').tagsinput('items');
$.ajax({ $.ajax({
url: 'http://192.168.178.39/admin/blog/sendEdit', url: '/admin/blog/sendEdit',
method: 'post', method: 'post',
data: { data: {
postID, postID,
@ -413,7 +413,7 @@ function publishPost() {
contentFR = $('#switchLanguages').find('> li[data-lang=fr]').data('contentid'); contentFR = $('#switchLanguages').find('> li[data-lang=fr]').data('contentid');
$.ajax({ $.ajax({
url: 'http://192.168.178.39/admin/blog/publishPost', url: '/admin/blog/publishPost',
method: 'post', method: 'post',
data: { data: {
postID, contentID, postID, contentID,
@ -460,7 +460,7 @@ $('.upload-btn').on('change', '.upload-image', function () {
$('.img-container').css('background-image', 'url(' + reader.result + ')'); $('.img-container').css('background-image', 'url(' + reader.result + ')');
$.ajax({ $.ajax({
url: 'http://192.168.178.39/admin/files/uploadImage', url: '/admin/files/uploadImage',
type: 'POST', type: 'POST',
data: { data: {
image: reader.result, image: reader.result,

View File

@ -1,6 +1,6 @@
$(document).ready(function () { $(document).ready(function () {
$.ajax({ $.ajax({
url: "http://192.168.178.39/blog/getComments", url: "/blog/getComments",
data: { data: {
url: window.location.pathname url: window.location.pathname
}, },
@ -33,7 +33,7 @@ var addComment = function () {
var item; var item;
$.ajax({ $.ajax({
url: "http://192.168.178.39/blog/comment", url: "/blog/comment",
method: 'POST', method: 'POST',
data: { data: {
url: window.location.pathname, url: window.location.pathname,
@ -117,7 +117,7 @@ function wait(ms) {
function likeDislike(postID) { function likeDislike(postID) {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "http://192.168.178.39/blog/like", url: "/blog/like",
data: { data: {
postID: postID postID: postID
}, },

View File

@ -2,7 +2,7 @@ let bar = new Nanobar();
function loadPlayer() { function loadPlayer() {
$.ajax({ $.ajax({
url: 'http://192.168.178.39/tools/csgo/data/' + $('#player-id').text(), url: '/tools/csgo/data/' + $('#player-id').text(),
method: 'GET', method: 'GET',
success: function (result) { success: function (result) {
console.log(result); console.log(result);
@ -113,7 +113,7 @@ $(window).keydown(function (event) {
function defaultPage() { function defaultPage() {
$.ajax({ $.ajax({
url: 'http://192.168.178.39/tools/csgo/getDefaultPage/' + $('#player-id').text(), url: '/tools/csgo/getDefaultPage/' + $('#player-id').text(),
method: 'GET', method: 'GET',
success: function (data) { success: function (data) {
bar.go(40); bar.go(40);

View File

@ -244,7 +244,7 @@ $('#new-category-submit').click(function () {
var name = $('input[name=new-category-name]').val(); var name = $('input[name=new-category-name]').val();
var display_name = $('input[name=new-category-display-name]').val(); var display_name = $('input[name=new-category-display-name]').val();
$.ajax({ $.ajax({
url: "http://192.168.178.39/admin/blog/new_category", url: "/admin/blog/new_category",
type: "POST", type: "POST",
data: { data: {
name: name, name: name,
@ -380,7 +380,7 @@ $('#tags-input').keypress(function (event) {
var deletePost = function (id) { var deletePost = function (id) {
var row = $("#post-" + id); var row = $("#post-" + id);
$.ajax({ $.ajax({
url: "http://192.168.178.39/admin/blog/delete", url: "/admin/blog/delete",
data: { data: {
id: id id: id
}, },
@ -434,16 +434,16 @@ $('#deleteModal').on('show.bs.modal', function (event) {
removeButton.removeAttr('disabled'); removeButton.removeAttr('disabled');
switch (type) { switch (type) {
case "Blog-Post": case "Blog-Post":
removeButton.attr('onclick', 'deletePostFinally(' + id + ', "http://192.168.178.39/admin/blog/deleteFinally", "post")'); removeButton.attr('onclick', 'deletePostFinally(' + id + ', "/admin/blog/deleteFinally", "post")');
break; break;
case "Projekt": case "Projekt":
removeButton.attr('onclick', 'deletePostFinally(' + id + ', "http://192.168.178.39/admin/projects/delete", "entry")'); removeButton.attr('onclick', 'deletePostFinally(' + id + ', "/admin/projects/delete", "entry")');
break; break;
case "Projekt-Kategorie": case "Projekt-Kategorie":
removeButton.attr('onclick', 'deletePostFinally(' + id + ', "http://192.168.178.39/admin/projects/delete_category", "category")'); removeButton.attr('onclick', 'deletePostFinally(' + id + ', "/admin/projects/delete_category", "category")');
break; break;
case "Datei": case "Datei":
removeButton.attr('onclick', 'deletePostFinally(' + id + ', "http://192.168.178.39/admin/files/delete", "file")'); removeButton.attr('onclick', 'deletePostFinally(' + id + ', "/admin/files/delete", "file")');
break; break;
} }
removeButton.css('cursor', 'pointer'); removeButton.css('cursor', 'pointer');
@ -502,7 +502,7 @@ function deletePostFinally(id, url, selector) {
function restorePost(id) { function restorePost(id) {
var row = $("#post-" + id); var row = $("#post-" + id);
$.ajax({ $.ajax({
url: "http://192.168.178.39/admin/blog/restore", url: "/admin/blog/restore",
data: { data: {
id: id id: id
}, },
@ -595,7 +595,7 @@ $(".table").DataTable({
function loadNotificationsAsync() { function loadNotificationsAsync() {
$.ajax({ $.ajax({
url: 'http://192.168.178.39/Main/getNotifications', url: '/Main/getNotifications',
method: 'post', method: 'post',
success: (data) => { success: (data) => {
console.log(data); console.log(data);

View File

@ -25,7 +25,7 @@ function activateDownloadSlider() {
var loadDownloadInfo = function (id) { var loadDownloadInfo = function (id) {
$.ajax({ $.ajax({
url: 'http://192.168.178.39/downloads/getDownload', url: '/downloads/getDownload',
data: { data: {
id: id id: id
}, },

View File

@ -28,7 +28,7 @@ $('#statusModal').on('show.bs.modal', (e) => {
function archiveFeedback(id) { function archiveFeedback(id) {
const row = $('#entry-' + id); const row = $('#entry-' + id);
$.ajax({ $.ajax({
url: 'http://192.168.178.39/admin/feedback/archive', url: '/admin/feedback/archive',
method: 'post', method: 'post',
data: { data: {
id id

View File

@ -37,7 +37,7 @@ $(document).ready(function () {
function loadPosts(onLoad) { function loadPosts(onLoad) {
// const category = $('#social-post-container .sort-list-filter > li > a.active').attr('data-filter'); // const category = $('#social-post-container .sort-list-filter > li > a.active').attr('data-filter');
$.ajax({ $.ajax({
url: "http://192.168.178.39/main/getPosts", url: "/main/getPosts",
data: { data: {
amount: amount, amount: amount,
offset: offset, offset: offset,

View File

@ -232,7 +232,7 @@ $(document).ready(function () {
} else { } else {
var loginname = $('#loginname').val(); var loginname = $('#loginname').val();
$.ajax({ $.ajax({
url: 'http://192.168.178.39/login/forget', url: '/login/forget',
method: 'POST', method: 'POST',
data: { data: {
username: loginname username: loginname
@ -278,7 +278,7 @@ $(document).ready(function () {
function registerAccount(username, email, password, passwordRepeat) { function registerAccount(username, email, password, passwordRepeat) {
$.ajax({ $.ajax({
url: "http://192.168.178.39/login/register", url: "/login/register",
method: "POST", method: "POST",
data: { data: {
username: username, username: username,

View File

@ -3,7 +3,7 @@ setInterval(function () {
}, 60000); }, 60000);
function stillAlive() { function stillAlive() {
$.get('http://192.168.178.39/Main/stillAlive'); $.get('/Main/stillAlive');
} }
jQuery(function ($) { jQuery(function ($) {
@ -106,7 +106,7 @@ function sendFeedback() {
$('#feedbackModal #message').addClass('has-error'); $('#feedbackModal #message').addClass('has-error');
} else { } else {
$.ajax({ $.ajax({
url: "http://192.168.178.39/Main/addFeedback", url: "/Main/addFeedback",
method: "POST", method: "POST",
data: { data: {
message: message, message: message,
@ -135,7 +135,7 @@ function sendContactMessage() {
$('#contactModal .modal-body').append('<div class="modal-loading-container"><div class="modal-loading-icon"><i class="fa fa-cog fa-spin"></i></div></div>'); $('#contactModal .modal-body').append('<div class="modal-loading-container"><div class="modal-loading-icon"><i class="fa fa-cog fa-spin"></i></div></div>');
$('#contactModalSend').button('loading'); $('#contactModalSend').button('loading');
$.ajax({ $.ajax({
url: "http://192.168.178.39/Main/contactTeam", url: "/Main/contactTeam",
method: "POST", method: "POST",
data: { data: {
message: message, message: message,
@ -285,7 +285,7 @@ function addReadMoreBtns() {
$('#notificationMenuButton').click(() => { $('#notificationMenuButton').click(() => {
$.ajax({ $.ajax({
url: 'http://192.168.178.39/Main/notificationsRead', url: '/Main/notificationsRead',
method: 'post', method: 'post',
success: (data) => { success: (data) => {
if (data.success) { if (data.success) {
@ -298,7 +298,7 @@ $('#notificationMenuButton').click(() => {
function loadNotificationsAsync() { function loadNotificationsAsync() {
$.ajax({ $.ajax({
url: 'http://192.168.178.39/Main/getNotifications', url: '/Main/getNotifications',
method: 'POST', method: 'POST',
beforeSend: () => { beforeSend: () => {
$('#notificationMenu').prepend('<div class="text-center"><i class="fa fa-cog fa-spin fa-4x my-4"></i></div>'); $('#notificationMenu').prepend('<div class="text-center"><i class="fa fa-cog fa-spin fa-4x my-4"></i></div>');

View File

@ -30,7 +30,7 @@ function generateNickname() {
$.ajax( $.ajax(
{ {
url: "http://192.168.178.39/tools/generators/nickname_functions", url: "/tools/generators/nickname_functions",
cache: false, cache: false,
dataType: 'text', dataType: 'text',
data: { data: {

View File

@ -176,7 +176,7 @@ function submitPost(content, replyTo) {
} }
$.ajax({ $.ajax({
url: "http://192.168.178.39/user/publishPost", url: "/user/publishPost",
method: 'POST', method: 'POST',
data: { data: {
content, content,

View File

@ -5,7 +5,7 @@ function showFullPost(uuid, username) {
defaultUrl += window.location.search; defaultUrl += window.location.search;
$.ajax({ $.ajax({
url: "http://192.168.178.39/user/single_post_data/" + username + "/" + uuid, url: "/user/single_post_data/" + username + "/" + uuid,
beforeSend: () => { beforeSend: () => {
const origin = encodeURI(btoa(window.location.href)); const origin = encodeURI(btoa(window.location.href));
window.history.pushState('', '', '/user/' + username + '/post/' + uuid + '?o=' + origin); window.history.pushState('', '', '/user/' + username + '/post/' + uuid + '?o=' + origin);
@ -113,7 +113,7 @@ function addPostLike(el) {
const text = $('span', el); const text = $('span', el);
const likeCount = parseInt(text.text()); const likeCount = parseInt(text.text());
$.ajax({ $.ajax({
url: 'http://192.168.178.39/posts/addPostLike', url: '/posts/addPostLike',
method: 'post', method: 'post',
data: { data: {
postUUID: uuid postUUID: uuid
@ -196,7 +196,7 @@ function openPostReportModal(uuid) {
function loadPostReportModal(uuid) { function loadPostReportModal(uuid) {
$.ajax({ $.ajax({
url: 'http://192.168.178.39/posts/getReportModal', url: '/posts/getReportModal',
data: { data: {
uuid uuid
}, },
@ -218,7 +218,7 @@ function loadPostReportModal(uuid) {
function submitReportForm(postUuid, reportReason, reportText) { function submitReportForm(postUuid, reportReason, reportText) {
$.ajax({ $.ajax({
url: 'http://192.168.178.39/posts/reportPost', url: '/posts/reportPost',
data: { data: {
uuid: postUuid, uuid: postUuid,
reason: reportReason, reason: reportReason,
@ -252,7 +252,7 @@ function submitReportForm(postUuid, reportReason, reportText) {
function openDeletePostModal(uuid) { function openDeletePostModal(uuid) {
$('body').append(` $('body').append(`
<div class="modal fade" id="postDeleteModal" tabindex="-1" role="dialog" aria-labelledby="postReportLabel"> <div class="modal fade" id="postDeleteModal" tabindex="-1" role="dialog" aria-labelledby="postReportLabel">
<div class="modal-dialog modal-dialog-centered" role="document"> <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h4 class="modal-title" id="postReportTitle">Post löschen</h4> <h4 class="modal-title" id="postReportTitle">Post löschen</h4>
@ -260,7 +260,7 @@ function openDeletePostModal(uuid) {
<span>&times;</span> <span>&times;</span>
</button> </button>
</div> </div>
<div class="modal-body text-center" id="postReportBody"> <div class="modal-body text-center" id="postDeleteBody">
<i class="fa fa-cog fa-spin fa-4x"></i> <i class="fa fa-cog fa-spin fa-4x"></i>
</div> </div>
</div> </div>
@ -278,12 +278,41 @@ function openDeletePostModal(uuid) {
function loadDeletePostModal(uuid) { function loadDeletePostModal(uuid) {
$.ajax({ $.ajax({
url: 'http://192.168.178.39/posts/getDeleteModal', url: '/posts/getDeleteModal',
data: { data: {
uuid uuid
}, },
method: 'post',
success: data => { success: data => {
$('#postDeleteModal').html(data); $('#postReportTitle').text(data.title);
$('#postDeleteBody').removeClass('text-center').html(data.body);
} }
}); });
}
function deletePost(uuid) {
$.ajax({
url: '/posts/deletePost',
method: 'post',
data: { uuid },
beforeSend: () => {
$('#postDeleteBody').addClass('text-center').html('<i class="fa fa-cog fa-spin fa-4x"></i>');
},
success: data => {
if(data.success) {
$('#postDeleteBody').html('<div class="alert alert-success" role="alert"></div>');
} else {
$('#postDeleteBody').html('<div class="alert alert-danger" role="alert"></div>');
}
$('#postDeleteBody').removeClass('text-center').find('.alert').text(data.message);
setTimeout(() => {
$('#postDeleteModal').modal('hide');
$(`.post-item[data-uuid=${uuid}]`).slideUp();
setTimeout(() => {
$('#postDeleteModal').modal('dispose').remove();
$(`.post-item[data-uuid=${uuid}]`).remove();
}, 500);
}, 2000);
}
})
} }

View File

@ -6,9 +6,9 @@ let running = false;
let loadingUrl; let loadingUrl;
if(window.location.pathname.indexOf('popular') !== -1) { if(window.location.pathname.indexOf('popular') !== -1) {
loadingUrl = 'http://192.168.178.39/posts/getPopularPosts'; loadingUrl = '/posts/getPopularPosts';
} else { } else {
loadingUrl = 'http://192.168.178.39/posts/getFeedPosts'; loadingUrl = '/posts/getFeedPosts';
} }
function loadEntries() { function loadEntries() {

View File

@ -18,7 +18,7 @@ function searchEntries() {
if (!s_running && ((s_itemsLeft || val_changed) && (query.val().length > 0 || (type === 'type-users' && (rank !== '' || lang !== '' || country !== ''))))) { if (!s_running && ((s_itemsLeft || val_changed) && (query.val().length > 0 || (type === 'type-users' && (rank !== '' || lang !== '' || country !== ''))))) {
console.log(rank); console.log(rank);
$.ajax({ $.ajax({
url: 'http://192.168.178.39/posts/getSearchPosts', url: '/posts/getSearchPosts',
data: { data: {
query: query.val(), query: query.val(),
type, type,
@ -160,7 +160,7 @@ $('.user-search select').change(() => {
function initUserSearch() { function initUserSearch() {
$.ajax({ $.ajax({
url: 'http://192.168.178.39/posts/getAvailableCountries', url: '/posts/getAvailableCountries',
success: (data) => { success: (data) => {
const countrySelect = $('#searchForCountry').find('.dropdown-menu'); const countrySelect = $('#searchForCountry').find('.dropdown-menu');
console.log(data); console.log(data);
@ -184,7 +184,7 @@ function initUserSearch() {
}); });
$.ajax({ $.ajax({
url: 'http://192.168.178.39/posts/getAvailableLanguages', url: '/posts/getAvailableLanguages',
success: (data) => { success: (data) => {
const langSelect = $('#searchForLang').find('.dropdown-menu'); const langSelect = $('#searchForLang').find('.dropdown-menu');
for (let lang of data.languages) { for (let lang of data.languages) {

View File

@ -75,7 +75,7 @@ function toggleSubbed(isSubbed) {
function sendFollowerRequest() { function sendFollowerRequest() {
$.ajax({ $.ajax({
url: "http://192.168.178.39/user/switchFollowing", url: "/user/switchFollowing",
method: "POST", method: "POST",
success: function (data) { success: function (data) {
console.log(data); console.log(data);

View File

@ -46,7 +46,7 @@ function sendEdit() {
editor.start(); editor.start();
$.ajax({ $.ajax({
url: 'http://192.168.178.39/admin/projects/sendEdit', url: '/admin/projects/sendEdit',
data: data, data: data,
method: 'POST', method: 'POST',
success: data => { success: data => {
@ -128,7 +128,7 @@ $('.upload-btn').on('change', '.upload-image', function () {
$('.uploaded-image-container').css('background-image', `url(${reader.result}`); $('.uploaded-image-container').css('background-image', `url(${reader.result}`);
$.ajax({ $.ajax({
url: 'http://192.168.178.39/admin/files/uploadImage', url: '/admin/files/uploadImage',
type: 'POST', type: 'POST',
data: { data: {
image: reader.result, image: reader.result,

View File

@ -19,7 +19,7 @@ $('.vote-btn').click(function (e) {
$('.vote-container .fa-sync').fadeIn(); $('.vote-container .fa-sync').fadeIn();
$.ajax({ $.ajax({
url: 'http://192.168.178.39/projects/addVote/index', url: '/projects/addVote/index',
method: 'POST', method: 'POST',
data: { data: {
id: $('.vote-container').data('id'), id: $('.vote-container').data('id'),

View File

@ -13,7 +13,7 @@ $(document).ready(() => {
function loadPostData() { function loadPostData() {
$.ajax({ $.ajax({
url: "http://192.168.178.39/user/single_post_data/" + modal.data('username') + "/" + modal.data('uuid'), url: "/user/single_post_data/" + modal.data('username') + "/" + modal.data('uuid'),
success: (data) => { success: (data) => {
$('.modal-body', modal).removeClass('text-center').html(data); $('.modal-body', modal).removeClass('text-center').html(data);
registerPostEvents(); registerPostEvents();