Update testTaskGate.ps1
This commit is contained in:
@@ -286,28 +286,7 @@ function Build-Checkboxes {
|
||||
<div id='${taskId}OptionsContainer' style='display:none; margin-top:4px;'>
|
||||
$subHtml
|
||||
</div>
|
||||
<script>
|
||||
(function() {
|
||||
const masterCheckbox = document.getElementById('${taskId}');
|
||||
const container = document.getElementById('${taskId}OptionsContainer');
|
||||
|
||||
if (masterCheckbox && container) {
|
||||
const passwordContainer = document.getElementById("PasswordContainer");
|
||||
const dattoContainer = document.getElementById("dattoRmmContainer");
|
||||
|
||||
function updateDisplay(checked) {
|
||||
container.style.display = checked ? 'block' : 'none';
|
||||
container.querySelectorAll('input[type="checkbox"]').forEach(cb => cb.checked = checked);
|
||||
|
||||
if (passwordContainer) passwordContainer.style.display = checked ? 'block' : 'none';
|
||||
if (dattoContainer) dattoContainer.style.display = checked ? 'block' : 'none';
|
||||
}
|
||||
|
||||
masterCheckbox.addEventListener('change', () => updateDisplay(masterCheckbox.checked));
|
||||
updateDisplay(masterCheckbox.checked);
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
"@
|
||||
}
|
||||
|
||||
@@ -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
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
'@
|
||||
|
||||
Reference in New Issue
Block a user