First commit

This commit is contained in:
2026-01-13 20:46:44 -06:00
commit d63e4e823a
241 changed files with 59142 additions and 0 deletions

105
public/js/ajaxcrud.js vendored Normal file
View File

@@ -0,0 +1,105 @@
$(document).on('click', 'pagination a', function (event) {
event.preventDefault();
ajaxLoad($(this).attr('href'));
});
$(document).on('submit', 'form#frm', function (event) {
event.preventDefault();
var form = $(this);
var data = new FormData($(this)[0]);
var url = form.attr("action");
$.ajax({
type: form.attr('method'),
url: url,
data: data,
cache: false,
contentType: false,
processData: false,
success: function (data) {
$('.is-invalid').removeClass('is-invalid');
if (data.fail) {
for (control in data.errors) {
$('#' + control).addClass('is-invalid');
$('#error-' + control).html(data.errors[control]);
}
} else {
ajaxLoad(data.redirect_url);
}
},
error: function (xhr, textStatus, errorThrown) {
alert("Error: " + errorThrown);
}
});
return false;
});
function ajaxLoad(filename, content) {
content = typeof content !== 'undefined' ? content : 'content';
$('.loading').show();
$.ajax({
type: "GET",
url: filename,
contentType: false,
success: function (data) {
$("#" + content).html(data);
$('.loading').hide();
},
error: function (xhr, status, error) {
alert(xhr.responseText);
}
});
}
function ajaxDelete(filename, token, content) {
content = typeof content !== 'undefined' ? content : 'content';
$('.loading').show();
$.ajax({
type: 'POST',
data: {_method: 'DELETE', _token: token},
url: filename,
success: function (data) {
window.location.href = filename.slice(0, -9);
$("#" + content).html(data);
$('.loading').hide();
},
error: function (xhr, status, error) {
alert(xhr.responseText);
}
});
}
function ajaxDeleteComments(filename, token, content) {
content = typeof content !== 'undefined' ? content : 'content';
$('.loading').show();
$.ajax({
type: 'POST',
data: {_method: 'DELETE', _token: token},
url: filename,
success: function (data) {
window.location.href = filename.replace("delete/", "");
$("#" + content).html(data);
$('.loading').hide();
},
error: function (xhr, status, error) {
alert(xhr.responseText);
}
});
}
function ajaxRedirect(filename, token, content) {
content = typeof content !== 'undefined' ? content : 'content';
$('.loading').show();
$.ajax({
type: 'POST',
data: {_method: 'PUT', _token: token},
url: filename,
success: function (data) {
window.location.href = filename.slice(0, -14);
$("#" + content).html(data);
$('.loading').hide();
},
error: function (xhr, status, error) {
alert(xhr.responseText);
}
});
}