2020-03-03 12:46:28 +00:00
|
|
|
window.onload = function () {
|
|
|
|
Array.from(dgcn('method-checkbox')).forEach(checkbox => {
|
|
|
|
// uncheck all the checkboxes every time the page is reloaded
|
|
|
|
checkbox.checked = false;
|
|
|
|
checkbox.onclick = function () {
|
|
|
|
let num = parseInt(this.dataset.number);
|
|
|
|
let prefix = this.parentElement.parentElement.dataset.cbPrefix;
|
|
|
|
let max = this.parentElement.parentElement.children.length;
|
|
|
|
|
|
|
|
if (this.checked) {
|
|
|
|
// check everything before this - if you've done step 6, you've done steps 1-5
|
|
|
|
for (i = num - 1; i > 0; i--) {
|
2020-03-05 19:01:59 +00:00
|
|
|
cb = dgel(`${prefix}-${i}`);
|
|
|
|
cb.checked = true;
|
|
|
|
cb.parentElement.classList.add("checked");
|
2020-03-03 12:46:28 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// uncheck everything after this - you can't have done step 8 if you haven't done step 4
|
|
|
|
console.log(num + 1);
|
|
|
|
for (i = num + 1; i <= max; i++) {
|
2020-03-05 19:01:59 +00:00
|
|
|
cb = dgel(`${prefix}-${i}`);
|
|
|
|
cb.checked = false;
|
|
|
|
cb.parentElement.classList.remove("checked");
|
2020-03-03 12:46:28 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-05 19:01:59 +00:00
|
|
|
|
|
|
|
this.parentElement.classList.toggle("checked");
|
2020-03-03 12:46:28 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function dgcn(cn) {
|
|
|
|
return document.getElementsByClassName(cn);
|
|
|
|
}
|
|
|
|
|
2020-03-01 06:52:39 +00:00
|
|
|
function dgel(id) {
|
|
|
|
return document.getElementById(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
function subrecipe_toggle(id) {
|
|
|
|
dgel(id).classList.toggle("open");
|
|
|
|
}
|