Update samy.js
This commit is contained in:
74
samy.js
74
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");
|
||||
|
||||
Reference in New Issue
Block a user