diff --git a/testTaskGate.ps1 b/testTaskGate.ps1 index da418c2..fc108dc 100644 --- a/testTaskGate.ps1 +++ b/testTaskGate.ps1 @@ -286,28 +286,7 @@ function Build-Checkboxes { - "@ } @@ -596,6 +575,41 @@ $style = @' fetch("/quit", { method: "GET" }) .finally(() => window.close()); } + + // ======================================================================= + // Sub-Options Auto-Toggle for Tasks + // ======================================================================= + + + document.addEventListener('DOMContentLoaded', function () { + // Auto-handle visibility and checking for tasks with sub-options + const tasksWithSubOptions = document.querySelectorAll('[id$="OptionsContainer"]'); + + tasksWithSubOptions.forEach(container => { + const taskId = container.id.replace('OptionsContainer', ''); + const masterCheckbox = document.getElementById(taskId); + + if (!masterCheckbox) return; + + function updateVisibility() { + const checked = masterCheckbox.checked; + container.style.display = checked ? 'block' : 'none'; + container.querySelectorAll('input[type="checkbox"]').forEach(cb => cb.checked = checked); + + // Show/hide Password and RMM only if it's installDattoRMM + if (taskId === 'installDattoRMM') { + const pwdBox = document.getElementById('PasswordContainer'); + const rmmBox = document.getElementById('dattoRmmContainer'); + if (pwdBox) pwdBox.style.display = checked ? 'block' : 'none'; + if (rmmBox) rmmBox.style.display = checked ? 'block' : 'none'; + } + } + + masterCheckbox.addEventListener('change', updateVisibility); + updateVisibility(); // call once on load + }); + }); + '@