Fix #1
This commit is contained in:
parent
e7fe9a9254
commit
77ef279b7f
26
index.html
26
index.html
|
@ -79,6 +79,8 @@
|
|||
///
|
||||
//////
|
||||
|
||||
const $ = query => document.querySelector(query);
|
||||
|
||||
const doAfterLoad = fun => {
|
||||
const oldOnLoad = window.onload || (() => {
|
||||
});
|
||||
|
@ -126,15 +128,17 @@
|
|||
|
||||
|
||||
// Functions
|
||||
inputTable.getTable = () => document.querySelector("#dieSettings tbody");
|
||||
inputTable.getTable = () => $("#dieSettings tbody");
|
||||
|
||||
inputTable.dieRowCount = () => inputTable.getTable().querySelectorAll(".dieEyes").length;
|
||||
|
||||
inputTable.highestDieRowIndex = () => {
|
||||
const table = inputTable.getTable();
|
||||
|
||||
let highestDieRowIndex = -1;
|
||||
iterateNodeList(table.getElementsByTagName("tr"), (node) => {
|
||||
if (!isNaN(node.dataset.index))
|
||||
highestDieRowIndex = Math.max(highestDieRowIndex, node.dataset.index);
|
||||
if ("index" in node.dataset)
|
||||
highestDieRowIndex = Math.max(highestDieRowIndex, +node.dataset.index);
|
||||
});
|
||||
|
||||
return highestDieRowIndex;
|
||||
|
@ -146,8 +150,8 @@
|
|||
input.id = className + index;
|
||||
input.className = className;
|
||||
input.type = "number";
|
||||
input.min = 1;
|
||||
input.step = 1;
|
||||
input.min = "1";
|
||||
input.step = "1";
|
||||
input.value = value;
|
||||
input.addEventListener("keypress", (e) => {
|
||||
if (e.key === "Enter")
|
||||
|
@ -171,7 +175,7 @@
|
|||
const table = inputTable.getTable();
|
||||
const newIndex = inputTable.highestDieRowIndex() + 1;
|
||||
|
||||
const row = table.insertRow(newIndex);
|
||||
const row = table.insertRow(inputTable.dieRowCount());
|
||||
row.dataset.index = newIndex;
|
||||
|
||||
row.insertCell().appendChild(createNumberInput(newIndex, "dieEyes", 6));
|
||||
|
@ -204,11 +208,11 @@
|
|||
|
||||
|
||||
// Handlers
|
||||
document.getElementById("addDieRowButton").onclick = inputTable.addDieRow;
|
||||
$("#addDieRowButton").onclick = inputTable.addDieRow;
|
||||
|
||||
|
||||
// Init
|
||||
doAfterLoad(() => document.getElementById("addDieRowButton").click());
|
||||
doAfterLoad(() => $("#addDieRowButton").click());
|
||||
|
||||
|
||||
//////
|
||||
|
@ -265,11 +269,11 @@
|
|||
|
||||
|
||||
// Handlers
|
||||
document.getElementById("submit").onclick = outputChart.updateProbGraph;
|
||||
$("#submit").onclick = outputChart.updateProbGraph;
|
||||
|
||||
|
||||
// Init
|
||||
const ctx = document.getElementById("probChart").getContext("2d");
|
||||
const ctx = $("#probChart").getContext("2d");
|
||||
const probChart = new Chart(ctx, {
|
||||
type: "line",
|
||||
data: {},
|
||||
|
@ -288,7 +292,7 @@
|
|||
}
|
||||
});
|
||||
|
||||
doAfterLoad(() => document.getElementById("submit").click());
|
||||
doAfterLoad(() => $("#submit").click());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue