Neuigkeiten/News/Blog-Editing und Bugfixes
This commit is contained in:
96
public/js/blog/blog.js
Normal file
96
public/js/blog/blog.js
Normal file
@@ -0,0 +1,96 @@
|
||||
$(function() {
|
||||
$('select[autocomplete="off"]').each(function() {
|
||||
let selectedValue = $(this).find('option[selected]').val();
|
||||
if (selectedValue) {
|
||||
$(this).val(selectedValue);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function addBlog(){
|
||||
|
||||
let b = {};
|
||||
b.title = $('#blogTitle_new').val();
|
||||
b.body = $('#blogBody_new').val();
|
||||
b.published = $('#blogPublished_new').is(":checked") ? "1" : "0";
|
||||
b.language = $('#blogLanguage_new').val();
|
||||
|
||||
console.log(b);
|
||||
|
||||
if(window.confirm('Eintrag wirklich speichern?')){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/intern/nachrichten/add",
|
||||
data: b,
|
||||
dataType: "json",
|
||||
success:function(r){
|
||||
if(r.messageStatus === "success"){
|
||||
$('#blogTitle_new').val("");
|
||||
$('#blogBody_new').val("");
|
||||
$('#blogLanguage_new').val("de");
|
||||
location.reload();
|
||||
} else {
|
||||
alert(r.errorMessage);
|
||||
}
|
||||
},
|
||||
error:function(r, a, e){
|
||||
alert(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function editBlog(blogId){
|
||||
let b = {};
|
||||
b.id = blogId;
|
||||
b.title = $('#blogTitle_'+blogId).val();
|
||||
b.body = $('#blogBody_'+blogId).val();
|
||||
b.published = $('#blogPublished_'+blogId).is(":checked") ? "1" : "0";
|
||||
b.language = $('#blogLanguage_'+blogId).val();
|
||||
|
||||
if(window.confirm('Eintrag wirklich speichern?')){
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
url: "/intern/nachrichten/edit",
|
||||
data: b,
|
||||
dataType: "json",
|
||||
success:function(r){
|
||||
if(r.messageStatus === "success"){
|
||||
location.reload();
|
||||
} else {
|
||||
alert(r.errorMessage);
|
||||
}
|
||||
},
|
||||
error:function(r, a, e){
|
||||
alert(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function deleteBlog(blogId){
|
||||
let b = {};
|
||||
b.id = blogId;
|
||||
|
||||
if(window.confirm('Eintrag wirklich löschen?')){
|
||||
$.ajax({
|
||||
type:"DELETE",
|
||||
url:"/intern/nachrichten/delete",
|
||||
data:b,
|
||||
dataType:"json",
|
||||
success:function(r){
|
||||
if(r.messageStatus === "success"){
|
||||
$('#blogDelete_' + blogId).closest('.blogEdit').fadeOut(300, function() {
|
||||
$(this).remove();
|
||||
location.reload();
|
||||
});
|
||||
} else {
|
||||
alert(r.errorMessage);
|
||||
}
|
||||
},
|
||||
error:function(r, a, e){
|
||||
alert(e);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user