From ff07d0c067bcb92b9af424ccc1bf58408fa04856 Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Fri, 5 Dec 2025 14:32:27 -0500 Subject: [PATCH] Update samy.js --- samy.js | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/samy.js b/samy.js index 9400e87..f027c98 100644 --- a/samy.js +++ b/samy.js @@ -347,7 +347,9 @@ function renderPrintersForClient(clientCode) { const id = `printer_${clientCode}_${idx}`; const label = document.createElement("label"); label.style.display = "block"; + label.style.marginBottom = "4px"; + //Install-Checkbox const cb = document.createElement("input"); cb.type = "checkbox"; cb.id = id; @@ -363,16 +365,36 @@ function renderPrintersForClient(clientCode) { cb.dataset.driverName = p.DriverName; cb.dataset.driverInfPath = p.DriverInfPath; - const nameText = - p.DisplayName || p.ProfileName || "Unnamed printer"; + const nameText = p.DisplayName || p.ProfileName || "Unnamed printer"; const locText = p.Location || "Unknown location"; + // Line 1: install checkbox + printer label label.appendChild(cb); label.appendChild(document.createTextNode(" ")); label.appendChild( document.createTextNode(`${nameText} (${locText})`) ); + // Line 2: radio for "Make default" + const defaultWrapper = document.createElement("div"); + defaultWrapper.style.marginLeft = "24px"; + defaultWrapper.style.fontSize = "0.85em"; + defaultWrapper.style.opacity = "0.9"; + + const radio = document.createElement("input"); + radio.type = "radio"; + radio.name = "defaultPrinter"; + radio.value = id; // associate default choice with this checkbox/printer + + const radioLabel = document.createElement("span"); + radioLabel.textContent = " Make default"; + + defaultWrapper.appendChild(radio); + defaultWrapper.appendChild(radioLabel); + + label.appendChild(document.createElement("br")); + label.appendChild(defaultWrapper); + container.appendChild(label); }); @@ -389,6 +411,12 @@ async function installSelectedPrinters() { return; } + // See which radio is checked for "Make default" + const defaultRadio = container.querySelector( + 'input[type=radio][name="defaultPrinter"]:checked' + ); + const defaultId = defaultRadio ? defaultRadio.value : null; + const selected = Array.from(checked).map((cb) => ({ ClientCode: cb.dataset.clientCode, ProfileName: cb.dataset.profileName, @@ -399,6 +427,8 @@ async function installSelectedPrinters() { ShareName: cb.dataset.shareName, DriverName: cb.dataset.driverName, DriverInfPath: cb.dataset.driverInfPath, + // Only the printer whose checkbox id matches the selected radio gets SetAsDefault=true + SetAsDefault: defaultId !== null && cb.id === defaultId, })); try {