Update samy.js

This commit is contained in:
2025-12-21 18:36:42 -05:00
parent fa324e361a
commit 2d8fe9f921

38
samy.js
View File

@@ -665,20 +665,38 @@ document.addEventListener("DOMContentLoaded", () => {
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));
const checked = masterCheckbox.checked;
container.style.display = checked ? "block" : "none";
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";
const subCbs = container.querySelectorAll('input[type="checkbox"]');
// Special-case: 1Password sub-options should be user-chosen
if (taskId === "install1Password") {
if (!checked) {
// turning OFF -> clear sub-options
subCbs.forEach((cb) => (cb.checked = false));
} else {
// turning ON -> if nothing selected yet, default to desktop
const anySelected = Array.from(subCbs).some((cb) => cb.checked);
if (!anySelected) {
const desktop = container.querySelector('input[type="checkbox"][value="desktop"]');
if (desktop) desktop.checked = true;
}
}
} else {
// Default behavior for other tasks (Datto, etc): mirror master checkbox
subCbs.forEach((cb) => (cb.checked = checked));
}
// Keep your Datto UI show/hide behavior
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();
});