ajaxify d2s editor

This commit is contained in:
Hash Borgir
2023-06-02 20:43:18 -06:00
parent ce83c42701
commit 81f1199a96
6 changed files with 223 additions and 70 deletions

View File

@@ -334,9 +334,9 @@ $(document).ready(function () {
// Get the name of the checkbox
var name = $(this).attr("name");
// Get the name of the difficulty
var diff = $(this).attr("diff");
var diff = $(this).attr("diff");
// Get the value of the input named "filePath"
var filePath = $("input[name='filePath']").val();
@@ -358,9 +358,9 @@ $(document).ready(function () {
// Get the name of the checkbox
var name = $(this).attr("name");
// Get the name of the difficulty
var diff = $(this).attr("diff");
var diff = $(this).attr("diff");
// Get the value of the input named "filePath"
var filePath = $("input[name='filePath']").val();
@@ -376,5 +376,41 @@ $(document).ready(function () {
});
});
// Get the value of the input named "filePath"
function constructURL(cmd, name, value, filePath) {
return "/saveCharacter.php?cmd=" + cmd + "&name=" + name + "&value=" + value + "&filePath=" + filePath;
}
$(".charform input[name='Difficulty'], .charform .skill, #CharacterName, #CharacterClass, #CharacterLevel, #CharacterClass").change(function () {
var name = $(this).attr("name");
var newValue = $(this).val();
var cmd = $(this).attr("cmd") || $(this).attr("id") || name;
var parentFormId = $(this).closest("form").attr("id");
var parentFormClass = $(this).closest("form").attr("class");
var filePath = $(`#${parentFormId} input[name='filePath']`).val();
var url = constructURL(cmd, name, newValue, filePath);
console.log(url);
console.log(newValue)
$.get(url, function (response) {
if (cmd == 'CharacterName') {
location.reload();
}
console.log(response);
});
});
});// end document.ready