small changes

This commit is contained in:
Tobias 2023-02-01 21:58:35 +01:00
parent 8d9fdb0f6f
commit 836af1c7e6
2 changed files with 7 additions and 6 deletions

View File

@ -40,16 +40,16 @@
<tr class="table-primary combRow" id="newCombRow"> <tr class="table-primary combRow" id="newCombRow">
<form name="newCombForm" class="combForm was-validated" onsubmit="return false;"> <form name="newCombForm" class="combForm was-validated" onsubmit="return false;">
<td> <td>
<input type="text" maxlength="40" class="form-control combName" form="newComForm" placeholder="Name" required /> <input type="text" maxlength="40" class="form-control combName" form="newCombForm" placeholder="Name" required />
</td> </td>
<td class="col-sm-2"> <td class="col-sm-2">
<input type="number" min="0" max="50" class="form-control combIni" form="newComForm" placeholder="Ini" /> <input type="number" min="0" max="50" class="form-control combIni" form="newCombForm" placeholder="Ini" />
</td> </td>
<td class="col-sm-3"> <td class="col-sm-3">
<div class="input-group"> <div class="input-group">
<input type="number" min="1" max="5" class="form-control combDice" form="newComForm" placeholder="Dice" /> <input type="number" min="1" max="5" class="form-control combDice" form="newCombForm" placeholder="Dice" />
<span class="input-group-text">D+</span> <span class="input-group-text">D+</span>
<input type="number" min="1" max="20" class="form-control combRea" form="newComForm" placeholder="REA" /> <input type="number" min="1" max="20" class="form-control combRea" form="newCombForm" placeholder="REA" />
</div> </div>
</td> </td>
<td> <td>

View File

@ -32,12 +32,12 @@ function handleBlur (e) {
} }
// did value stay the same? do nothing then // did value stay the same? do nothing then
if ( e.target.value == $(e.target).parents("tr").attr("data-ini") ) { if ( e.target.value == $tr.attr("data-ini") ) {
return true; return true;
} }
// value changed => reposition row // value changed => reposition row
$(e.target).parents("tr").attr("data-ini", e.target.value); $tr.attr("data-ini", e.target.value);
let $trc = $tr.clone(true); let $trc = $tr.clone(true);
$tr.remove(); $tr.remove();
insertCombRow($trc); insertCombRow($trc);
@ -229,6 +229,7 @@ function addCombatant (e) {
// add handlers to table row object // add handlers to table row object
$tr.find("input[class*='comb']").on("blur", handleBlur); $tr.find("input[class*='comb']").on("blur", handleBlur);
$tr.find("input[type='number']").bind('keyup input change', handleBlur);
$tr.find("button.act-button").on("click", handleActButtonClick); $tr.find("button.act-button").on("click", handleActButtonClick);
$tr.find("button.remove-button").on("click", handleRemoveButtonClick); $tr.find("button.remove-button").on("click", handleRemoveButtonClick);