From 3f1772224a4bb0a3ed3df62b4050bcc3934cfdc5 Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Sun, 21 Dec 2025 19:16:19 -0500 Subject: [PATCH] Update samy.js --- samy.js | 74 ++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 57 insertions(+), 17 deletions(-) diff --git a/samy.js b/samy.js index 84c48cf..4200f57 100644 --- a/samy.js +++ b/samy.js @@ -665,29 +665,69 @@ document.addEventListener("DOMContentLoaded", () => { if (!masterCheckbox) return; function updateVisibility() { - const checked = masterCheckbox.checked; - container.style.display = checked ? "block" : "none"; + const checked = masterCheckbox.checked; - const subCbs = container.querySelectorAll('input[type="checkbox"]'); + // Show/hide the sub-options panel + container.style.display = checked ? "block" : "none"; - // 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; + // Only sub-options checkboxes live here (text inputs won’t be touched) + 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)); + + // ========================================================== + // Special-case: Disable Animations sub-options should be user-chosen + // ========================================================== + else if (taskId === "disableAnimations") { + if (!checked) { + // turning OFF -> clear sub-options + subCbs.forEach((cb) => (cb.checked = false)); + } else { + // turning ON -> if nothing selected yet, default to ALL sub-options + const anySelected = Array.from(subCbs).some((cb) => cb.checked); + if (!anySelected) { + subCbs.forEach((cb) => (cb.checked = true)); + } + } + } + + // ========================================================== + // Default behavior: sub-options mirror the master checkbox + // (Datto uses this: check master -> check all sub-options) + // ========================================================== + else { + subCbs.forEach((cb) => (cb.checked = checked)); + } + + // ========================================================== + // Datto extra UI blocks (password + dropdown) tied to master checkbox + // ========================================================== + 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"; + } } + // Keep your Datto UI show/hide behavior if (taskId === "installDattoRMM") { const pwdBox = document.getElementById("PasswordContainer");