Fixed: prepend charname before for= and id=. One problem remains, sometimes q_all and wp_all don't check when all quests or wps are checked

This commit is contained in:
Hash Borgir
2023-06-12 02:23:35 -06:00
parent 46a7bbd378
commit e9fdeede11
2 changed files with 47 additions and 110 deletions

View File

@@ -1,29 +1,29 @@
/*
Copyright (C) 2021 Hash Borgir
This file is part of D2Modder
Redistribution and use in source and binary forms, with
or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* This software must not be used for commercial purposes
* without my consent. Any sales or commercial use are prohibited
* without my express knowledge and consent.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY!
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
@@ -37,7 +37,7 @@
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// highlight json dump for item debugger
function syntaxHighlight(json) {
@@ -400,11 +400,11 @@ $(document).ready(function () {
return "/saveCharacter.php?cmd=" + cmd + "&name=" + name + "&value=" + value + "&filePath=" + filePath;
}
$(".charform input[name='Difficulty'], .charform .skill, #CharacterName, #CharacterClass, #CharacterLevel, #CharacterClass, .stats input, .form-check-input, #statsdiv input,#setallskills,.wp_all,.q_all").change(function () {
$(".charform input[name='Difficulty'], .charform .skill, .CharacterName, .CharacterClass, .CharacterLevel, .stats input, .form-check-input, .statsdiv input,.setallskills").change(function () {
var name = $(this).attr("name");
var newValue = $(this).val();
var cmd = $(this).attr("cmd") || $(this).attr("id") || name;
var cmd = $(this).attr("cmd") || name;
var parentFormId = $(this).closest("form").attr("id");
var parentFormClass = $(this).closest("form").attr("class");
@@ -424,41 +424,31 @@ $(document).ready(function () {
});
$('.q_all, .wp_all').click(function () {
var parentFormId = $(this).closest("form").attr("id");
var targetClass = $(this).attr('class') === 'q_all' ? `#${parentFormId} .qcheck` : `#${parentFormId} .wpcheck`;
var parentForm = $(this).closest('form');
var targetClass = $(this).hasClass('q_all') ? '.qcheck' : '.wpcheck';
var isChecked = $(this).prop('checked');
$(targetClass).prop('checked', isChecked);
parentForm.find(targetClass).prop('checked', isChecked);
});
$('.qcheck').change(function () {
var parentFormId = $(this).closest("form").attr("id");
var qallChecked = $(`#${parentFormId} .qcheck:checked`).length === $(`#${parentFormId} .qcheck`).length;
if (qallChecked == true) {
var qchecked = 'checked';
var val = 1;
} else {
qchecked = '';
var val = 0;
}
$(`#${parentFormId} .q_all`).prop('checked', qchecked).val(val);
});
$('.wpcheck').change(function () {
var parentFormId = $(this).closest("form").attr("id");
var wpallChecked = $(`#${parentFormId} .wpcheck:checked`).length === $(`#${parentFormId} .wpcheck`).length;
if (wpallChecked == true) {
var wpchecked = 'checked';
var val = 1;
} else {
wpchecked = '';
var val = 0;
}
var wpchecked = wpallChecked ? 'checked' : '';
var val = wpallChecked ? 1 : 0;
$(`#${parentFormId} .wp_all`).prop('checked', wpchecked).val(val);
});
$('#setallskills').change(function () {
$('.qcheck').change(function () {
var parentFormId = $(this).closest("form").attr("id");
var qallChecked = $(`#${parentFormId} .qcheck:checked`).length === $(`#${parentFormId} .qcheck`).length;
var qchecked = qallChecked ? 'checked' : '';
var val = qallChecked ? 1 : 0;
$(`#${parentFormId} .q_all`).prop('checked', qchecked).val(val);
});
$('.setallskills').change(function () {
var value = $(this).val();
var parentFormId = $(this).closest("form").attr("id");
$(`#${parentFormId} .skill`).attr('value', value);