mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2025-10-13 16:34:23 -05:00
add jquery ui and modal dialogs to reload and delete buttons
This commit is contained in:
124
res/app.js
124
res/app.js
@@ -317,18 +317,7 @@ $(document).ready(function () {
|
||||
window.open('/genDocs.php?cmd=genDocUniqueItems', '_blank');
|
||||
});
|
||||
|
||||
// Delete button event
|
||||
$('.btn-delete').click(function (event) {
|
||||
event.preventDefault(); // Prevent default button click behavior
|
||||
|
||||
// delete item index
|
||||
$.get('/ajax/uniqueitems.php?cmd=delete&index=' + $(".uniqueform input[name='index']").val(), function (response) {
|
||||
// Handle the response from the server
|
||||
// remove option from list
|
||||
$('.uniqueitems-select option[value="' + $(".uniqueform input[name='index']").val() + '"]').remove();
|
||||
console.log(response);
|
||||
});
|
||||
});
|
||||
|
||||
// Save button event
|
||||
$('.btn-save').click(function (event) {
|
||||
@@ -500,31 +489,100 @@ $(document).ready(function () {
|
||||
|
||||
// Reload Mod files
|
||||
$('#reload-button').on('click', function () {
|
||||
$("#TabContent").hide();
|
||||
showLoadingSpinner();
|
||||
$.get('/reload.php')
|
||||
.done(function (response) {
|
||||
console.log('Request successful');
|
||||
console.log(response);
|
||||
// Create a dialog with OK/Cancel buttons
|
||||
$('<div>').html(
|
||||
"Warning: Reloading all TXT/TBL files!<br><br>" +
|
||||
"This action will reload all the TXT/TBL files into the database, overwriting any existing data. It will not modify your TXT/TBL files or mod files.<br><br>" +
|
||||
"Please note that while this step is generally safe, it's always recommended to back up your mod files before proceeding.<br><br>" +
|
||||
"Are you absolutely sure you want to proceed with this operation?"
|
||||
).dialog({
|
||||
title: "Confirmation",
|
||||
modal: true,
|
||||
resizable: false,
|
||||
buttons: {
|
||||
OK: function () {
|
||||
// OK button clicked
|
||||
console.log("OK button clicked");
|
||||
|
||||
// Perform additional actions or handle the response here
|
||||
hideLoadingSpinner();
|
||||
$("#TabContent").show();
|
||||
})
|
||||
.fail(function (jqXHR, textStatus, errorThrown) {
|
||||
console.log('Request failed');
|
||||
console.log(jqXHR);
|
||||
console.log(textStatus);
|
||||
console.log(errorThrown);
|
||||
// Show loading spinner and disable the button
|
||||
$("#TabContent").hide();
|
||||
showLoadingSpinner();
|
||||
$('#reload-button').prop('disabled', true);
|
||||
|
||||
// Handle the error or show an error message
|
||||
// Send the request to reload.php
|
||||
$.get('/reload.php')
|
||||
.done(function (response) {
|
||||
console.log('Request successful');
|
||||
console.log(response);
|
||||
|
||||
})
|
||||
.always(function () {
|
||||
// Hide the loading overlay and enable the button
|
||||
$('#loading-overlay').fadeOut();
|
||||
$('#reload-button').prop('disabled', false);
|
||||
});
|
||||
// Perform additional actions or handle the response here
|
||||
hideLoadingSpinner();
|
||||
$("#TabContent").show();
|
||||
})
|
||||
.fail(function (jqXHR, textStatus, errorThrown) {
|
||||
console.log('Request failed');
|
||||
console.log(jqXHR);
|
||||
console.log(textStatus);
|
||||
console.log(errorThrown);
|
||||
|
||||
// Handle the error or show an error message
|
||||
})
|
||||
.always(function () {
|
||||
// Hide the loading overlay and enable the button
|
||||
$('#loading-overlay').fadeOut();
|
||||
$('#reload-button').prop('disabled', false);
|
||||
});
|
||||
|
||||
$(this).dialog("close");
|
||||
},
|
||||
Cancel: function () {
|
||||
// Cancel button clicked
|
||||
console.log("Cancel button clicked");
|
||||
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Reload Mod files
|
||||
$('.btn-delete').on('click', function () {
|
||||
event.preventDefault(); // Prevent default button click behavior
|
||||
// Create a dialog with OK/Cancel buttons
|
||||
$('<div>').html(
|
||||
"Warning: This will delete the item from the database and the TXT file on disk!<br><br>" +
|
||||
"There is no UNDO for this. Make sure you want to delete this row before you proceed.<br><br>" +
|
||||
"It's always recommended to back up your mod files before proceeding.<br><br>" +
|
||||
"Are you absolutely sure you want to proceed with this operation?"
|
||||
).dialog({
|
||||
title: "Confirmation",
|
||||
modal: true,
|
||||
resizable: false,
|
||||
buttons: {
|
||||
OK: function () {
|
||||
// OK button clicked
|
||||
console.log("OK button clicked");
|
||||
// Delete button event
|
||||
|
||||
// delete item index
|
||||
$.get('/ajax/uniqueitems.php?cmd=delete&index=' + $(".uniqueform input[name='index']").val(), function (response) {
|
||||
// Handle the response from the server
|
||||
// remove option from list
|
||||
$('.uniqueitems-select option[value="' + $(".uniqueform input[name='index']").val() + '"]').remove();
|
||||
console.log(response);
|
||||
});
|
||||
|
||||
|
||||
$(this).dialog("close");
|
||||
},
|
||||
Cancel: function () {
|
||||
// Cancel button clicked
|
||||
console.log("Cancel button clicked");
|
||||
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user