Implement feature for deleting posts and improving ajax requests
This commit is contained in:
@@ -166,7 +166,7 @@ $('span').keyup(function (e) {
|
||||
let tagsList = [];
|
||||
$(function () {
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/admin/blog/tagsList',
|
||||
url: '/admin/blog/tagsList',
|
||||
method: 'GET',
|
||||
success: function (data) {
|
||||
console.log(data);
|
||||
@@ -222,7 +222,7 @@ $(function () {
|
||||
function getPostData() {
|
||||
const postID = $('#postID').val();
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/admin/blog/getPost',
|
||||
url: '/admin/blog/getPost',
|
||||
method: 'post',
|
||||
data: {
|
||||
postID
|
||||
@@ -255,7 +255,7 @@ function getContentData() {
|
||||
const contentID = $('#contentID').val();
|
||||
const lang = $('#postLanguage').val();
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/admin/blog/getContent',
|
||||
url: '/admin/blog/getContent',
|
||||
method: 'post',
|
||||
data: {
|
||||
postID, contentID, lang
|
||||
@@ -275,7 +275,7 @@ function getTranslationData() {
|
||||
const translationID = $('#translationID').val();
|
||||
const lang = $('#postLanguage').val();
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/admin/blog/getTranslationData',
|
||||
url: '/admin/blog/getTranslationData',
|
||||
method: 'post',
|
||||
data: {
|
||||
postID, translationID, lang
|
||||
@@ -294,7 +294,7 @@ function getTranslationData() {
|
||||
function getPostTags() {
|
||||
const postID = $('#postID').val();
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/admin/blog/getPostTags',
|
||||
url: '/admin/blog/getPostTags',
|
||||
method: 'POST',
|
||||
data: {
|
||||
postID
|
||||
@@ -367,7 +367,7 @@ function sendPost(executionFinished) {
|
||||
postTags = $('#postTags').tagsinput('items');
|
||||
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/admin/blog/sendEdit',
|
||||
url: '/admin/blog/sendEdit',
|
||||
method: 'post',
|
||||
data: {
|
||||
postID,
|
||||
@@ -413,7 +413,7 @@ function publishPost() {
|
||||
contentFR = $('#switchLanguages').find('> li[data-lang=fr]').data('contentid');
|
||||
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/admin/blog/publishPost',
|
||||
url: '/admin/blog/publishPost',
|
||||
method: 'post',
|
||||
data: {
|
||||
postID, contentID,
|
||||
@@ -460,7 +460,7 @@ $('.upload-btn').on('change', '.upload-image', function () {
|
||||
$('.img-container').css('background-image', 'url(' + reader.result + ')');
|
||||
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/admin/files/uploadImage',
|
||||
url: '/admin/files/uploadImage',
|
||||
type: 'POST',
|
||||
data: {
|
||||
image: reader.result,
|
||||
|
@@ -1,6 +1,6 @@
|
||||
$(document).ready(function () {
|
||||
$.ajax({
|
||||
url: "http://192.168.178.39/blog/getComments",
|
||||
url: "/blog/getComments",
|
||||
data: {
|
||||
url: window.location.pathname
|
||||
},
|
||||
@@ -33,7 +33,7 @@ var addComment = function () {
|
||||
|
||||
var item;
|
||||
$.ajax({
|
||||
url: "http://192.168.178.39/blog/comment",
|
||||
url: "/blog/comment",
|
||||
method: 'POST',
|
||||
data: {
|
||||
url: window.location.pathname,
|
||||
@@ -117,7 +117,7 @@ function wait(ms) {
|
||||
function likeDislike(postID) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "http://192.168.178.39/blog/like",
|
||||
url: "/blog/like",
|
||||
data: {
|
||||
postID: postID
|
||||
},
|
||||
|
@@ -2,7 +2,7 @@ let bar = new Nanobar();
|
||||
|
||||
function loadPlayer() {
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/tools/csgo/data/' + $('#player-id').text(),
|
||||
url: '/tools/csgo/data/' + $('#player-id').text(),
|
||||
method: 'GET',
|
||||
success: function (result) {
|
||||
console.log(result);
|
||||
@@ -113,7 +113,7 @@ $(window).keydown(function (event) {
|
||||
|
||||
function defaultPage() {
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/tools/csgo/getDefaultPage/' + $('#player-id').text(),
|
||||
url: '/tools/csgo/getDefaultPage/' + $('#player-id').text(),
|
||||
method: 'GET',
|
||||
success: function (data) {
|
||||
bar.go(40);
|
||||
|
@@ -244,7 +244,7 @@ $('#new-category-submit').click(function () {
|
||||
var name = $('input[name=new-category-name]').val();
|
||||
var display_name = $('input[name=new-category-display-name]').val();
|
||||
$.ajax({
|
||||
url: "http://192.168.178.39/admin/blog/new_category",
|
||||
url: "/admin/blog/new_category",
|
||||
type: "POST",
|
||||
data: {
|
||||
name: name,
|
||||
@@ -380,7 +380,7 @@ $('#tags-input').keypress(function (event) {
|
||||
var deletePost = function (id) {
|
||||
var row = $("#post-" + id);
|
||||
$.ajax({
|
||||
url: "http://192.168.178.39/admin/blog/delete",
|
||||
url: "/admin/blog/delete",
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
@@ -434,16 +434,16 @@ $('#deleteModal').on('show.bs.modal', function (event) {
|
||||
removeButton.removeAttr('disabled');
|
||||
switch (type) {
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
removeButton.css('cursor', 'pointer');
|
||||
@@ -502,7 +502,7 @@ function deletePostFinally(id, url, selector) {
|
||||
function restorePost(id) {
|
||||
var row = $("#post-" + id);
|
||||
$.ajax({
|
||||
url: "http://192.168.178.39/admin/blog/restore",
|
||||
url: "/admin/blog/restore",
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
@@ -595,7 +595,7 @@ $(".table").DataTable({
|
||||
|
||||
function loadNotificationsAsync() {
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/Main/getNotifications',
|
||||
url: '/Main/getNotifications',
|
||||
method: 'post',
|
||||
success: (data) => {
|
||||
console.log(data);
|
||||
|
@@ -25,7 +25,7 @@ function activateDownloadSlider() {
|
||||
|
||||
var loadDownloadInfo = function (id) {
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/downloads/getDownload',
|
||||
url: '/downloads/getDownload',
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
|
@@ -28,7 +28,7 @@ $('#statusModal').on('show.bs.modal', (e) => {
|
||||
function archiveFeedback(id) {
|
||||
const row = $('#entry-' + id);
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/admin/feedback/archive',
|
||||
url: '/admin/feedback/archive',
|
||||
method: 'post',
|
||||
data: {
|
||||
id
|
||||
|
@@ -37,7 +37,7 @@ $(document).ready(function () {
|
||||
function loadPosts(onLoad) {
|
||||
// const category = $('#social-post-container .sort-list-filter > li > a.active').attr('data-filter');
|
||||
$.ajax({
|
||||
url: "http://192.168.178.39/main/getPosts",
|
||||
url: "/main/getPosts",
|
||||
data: {
|
||||
amount: amount,
|
||||
offset: offset,
|
||||
|
@@ -232,7 +232,7 @@ $(document).ready(function () {
|
||||
} else {
|
||||
var loginname = $('#loginname').val();
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/login/forget',
|
||||
url: '/login/forget',
|
||||
method: 'POST',
|
||||
data: {
|
||||
username: loginname
|
||||
@@ -278,7 +278,7 @@ $(document).ready(function () {
|
||||
|
||||
function registerAccount(username, email, password, passwordRepeat) {
|
||||
$.ajax({
|
||||
url: "http://192.168.178.39/login/register",
|
||||
url: "/login/register",
|
||||
method: "POST",
|
||||
data: {
|
||||
username: username,
|
||||
|
@@ -3,7 +3,7 @@ setInterval(function () {
|
||||
}, 60000);
|
||||
|
||||
function stillAlive() {
|
||||
$.get('http://192.168.178.39/Main/stillAlive');
|
||||
$.get('/Main/stillAlive');
|
||||
}
|
||||
|
||||
jQuery(function ($) {
|
||||
@@ -106,7 +106,7 @@ function sendFeedback() {
|
||||
$('#feedbackModal #message').addClass('has-error');
|
||||
} else {
|
||||
$.ajax({
|
||||
url: "http://192.168.178.39/Main/addFeedback",
|
||||
url: "/Main/addFeedback",
|
||||
method: "POST",
|
||||
data: {
|
||||
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>');
|
||||
$('#contactModalSend').button('loading');
|
||||
$.ajax({
|
||||
url: "http://192.168.178.39/Main/contactTeam",
|
||||
url: "/Main/contactTeam",
|
||||
method: "POST",
|
||||
data: {
|
||||
message: message,
|
||||
@@ -285,7 +285,7 @@ function addReadMoreBtns() {
|
||||
|
||||
$('#notificationMenuButton').click(() => {
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/Main/notificationsRead',
|
||||
url: '/Main/notificationsRead',
|
||||
method: 'post',
|
||||
success: (data) => {
|
||||
if (data.success) {
|
||||
@@ -298,7 +298,7 @@ $('#notificationMenuButton').click(() => {
|
||||
|
||||
function loadNotificationsAsync() {
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/Main/getNotifications',
|
||||
url: '/Main/getNotifications',
|
||||
method: 'POST',
|
||||
beforeSend: () => {
|
||||
$('#notificationMenu').prepend('<div class="text-center"><i class="fa fa-cog fa-spin fa-4x my-4"></i></div>');
|
||||
|
@@ -30,7 +30,7 @@ function generateNickname() {
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
url: "http://192.168.178.39/tools/generators/nickname_functions",
|
||||
url: "/tools/generators/nickname_functions",
|
||||
cache: false,
|
||||
dataType: 'text',
|
||||
data: {
|
||||
|
@@ -176,7 +176,7 @@ function submitPost(content, replyTo) {
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "http://192.168.178.39/user/publishPost",
|
||||
url: "/user/publishPost",
|
||||
method: 'POST',
|
||||
data: {
|
||||
content,
|
||||
|
@@ -5,7 +5,7 @@ function showFullPost(uuid, username) {
|
||||
defaultUrl += window.location.search;
|
||||
|
||||
$.ajax({
|
||||
url: "http://192.168.178.39/user/single_post_data/" + username + "/" + uuid,
|
||||
url: "/user/single_post_data/" + username + "/" + uuid,
|
||||
beforeSend: () => {
|
||||
const origin = encodeURI(btoa(window.location.href));
|
||||
window.history.pushState('', '', '/user/' + username + '/post/' + uuid + '?o=' + origin);
|
||||
@@ -113,7 +113,7 @@ function addPostLike(el) {
|
||||
const text = $('span', el);
|
||||
const likeCount = parseInt(text.text());
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/posts/addPostLike',
|
||||
url: '/posts/addPostLike',
|
||||
method: 'post',
|
||||
data: {
|
||||
postUUID: uuid
|
||||
@@ -196,7 +196,7 @@ function openPostReportModal(uuid) {
|
||||
|
||||
function loadPostReportModal(uuid) {
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/posts/getReportModal',
|
||||
url: '/posts/getReportModal',
|
||||
data: {
|
||||
uuid
|
||||
},
|
||||
@@ -218,7 +218,7 @@ function loadPostReportModal(uuid) {
|
||||
|
||||
function submitReportForm(postUuid, reportReason, reportText) {
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/posts/reportPost',
|
||||
url: '/posts/reportPost',
|
||||
data: {
|
||||
uuid: postUuid,
|
||||
reason: reportReason,
|
||||
@@ -252,7 +252,7 @@ function submitReportForm(postUuid, reportReason, reportText) {
|
||||
function openDeletePostModal(uuid) {
|
||||
$('body').append(`
|
||||
<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-header">
|
||||
<h4 class="modal-title" id="postReportTitle">Post löschen</h4>
|
||||
@@ -260,7 +260,7 @@ function openDeletePostModal(uuid) {
|
||||
<span>×</span>
|
||||
</button>
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
@@ -278,12 +278,41 @@ function openDeletePostModal(uuid) {
|
||||
|
||||
function loadDeletePostModal(uuid) {
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/posts/getDeleteModal',
|
||||
url: '/posts/getDeleteModal',
|
||||
data: {
|
||||
uuid
|
||||
},
|
||||
method: 'post',
|
||||
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);
|
||||
}
|
||||
})
|
||||
}
|
@@ -6,9 +6,9 @@ let running = false;
|
||||
let loadingUrl;
|
||||
|
||||
if(window.location.pathname.indexOf('popular') !== -1) {
|
||||
loadingUrl = 'http://192.168.178.39/posts/getPopularPosts';
|
||||
loadingUrl = '/posts/getPopularPosts';
|
||||
} else {
|
||||
loadingUrl = 'http://192.168.178.39/posts/getFeedPosts';
|
||||
loadingUrl = '/posts/getFeedPosts';
|
||||
}
|
||||
|
||||
function loadEntries() {
|
||||
|
@@ -18,7 +18,7 @@ function searchEntries() {
|
||||
if (!s_running && ((s_itemsLeft || val_changed) && (query.val().length > 0 || (type === 'type-users' && (rank !== '' || lang !== '' || country !== ''))))) {
|
||||
console.log(rank);
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/posts/getSearchPosts',
|
||||
url: '/posts/getSearchPosts',
|
||||
data: {
|
||||
query: query.val(),
|
||||
type,
|
||||
@@ -160,7 +160,7 @@ $('.user-search select').change(() => {
|
||||
|
||||
function initUserSearch() {
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/posts/getAvailableCountries',
|
||||
url: '/posts/getAvailableCountries',
|
||||
success: (data) => {
|
||||
const countrySelect = $('#searchForCountry').find('.dropdown-menu');
|
||||
console.log(data);
|
||||
@@ -184,7 +184,7 @@ function initUserSearch() {
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/posts/getAvailableLanguages',
|
||||
url: '/posts/getAvailableLanguages',
|
||||
success: (data) => {
|
||||
const langSelect = $('#searchForLang').find('.dropdown-menu');
|
||||
for (let lang of data.languages) {
|
||||
|
@@ -75,7 +75,7 @@ function toggleSubbed(isSubbed) {
|
||||
|
||||
function sendFollowerRequest() {
|
||||
$.ajax({
|
||||
url: "http://192.168.178.39/user/switchFollowing",
|
||||
url: "/user/switchFollowing",
|
||||
method: "POST",
|
||||
success: function (data) {
|
||||
console.log(data);
|
||||
|
@@ -46,7 +46,7 @@ function sendEdit() {
|
||||
editor.start();
|
||||
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/admin/projects/sendEdit',
|
||||
url: '/admin/projects/sendEdit',
|
||||
data: data,
|
||||
method: 'POST',
|
||||
success: data => {
|
||||
@@ -128,7 +128,7 @@ $('.upload-btn').on('change', '.upload-image', function () {
|
||||
$('.uploaded-image-container').css('background-image', `url(${reader.result}`);
|
||||
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/admin/files/uploadImage',
|
||||
url: '/admin/files/uploadImage',
|
||||
type: 'POST',
|
||||
data: {
|
||||
image: reader.result,
|
||||
|
@@ -19,7 +19,7 @@ $('.vote-btn').click(function (e) {
|
||||
$('.vote-container .fa-sync').fadeIn();
|
||||
|
||||
$.ajax({
|
||||
url: 'http://192.168.178.39/projects/addVote/index',
|
||||
url: '/projects/addVote/index',
|
||||
method: 'POST',
|
||||
data: {
|
||||
id: $('.vote-container').data('id'),
|
||||
|
@@ -13,7 +13,7 @@ $(document).ready(() => {
|
||||
|
||||
function loadPostData() {
|
||||
$.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) => {
|
||||
$('.modal-body', modal).removeClass('text-center').html(data);
|
||||
registerPostEvents();
|
||||
|
Reference in New Issue
Block a user