(id, values, enabled = true, options = {})
| 2124 | } |
| 2125 | |
| 2126 | function syncChoiceListFromSettings(id, values, enabled = true, options = {}) { |
| 2127 | const target = $(id); |
| 2128 | if (!target) return; |
| 2129 | const configured = new Set(splitListValue(values)); |
| 2130 | const inputs = Array.from(target.querySelectorAll("input[type='checkbox']")); |
| 2131 | const defaultChecked = options.defaultChecked || "none"; |
| 2132 | const useConfigured = options.useConfigured !== false; |
| 2133 | inputs.forEach((input, index) => { |
| 2134 | if (useConfigured && configured.size) { |
| 2135 | input.checked = configured.has(input.value); |
| 2136 | } else { |
| 2137 | input.checked = defaultCheckedForSource(index, defaultChecked); |
| 2138 | } |
| 2139 | input.disabled = !enabled; |
| 2140 | input.closest("label")?.classList.toggle("disabled", !enabled); |
| 2141 | }); |
| 2142 | } |
| 2143 | |
| 2144 | function syncDailySourceControls(sourcePrefs = {}) { |
| 2145 | syncChoiceListFromSettings( |
no test coverage detected