| 2216 | const data = await api("/api/source-options"); |
| 2217 | state.sourceOptions = data; |
| 2218 | renderChoiceList("arxivCategories", data.arxiv_categories || [], { defaultChecked: "all" }); |
| 2219 | renderChoiceList("conferenceSources", data.conferences || [], { defaultChecked: "none" }); |
| 2220 | renderChoiceList("journalSources", data.journals || [], { defaultChecked: "none" }); |
| 2221 | state.sourceOptionsLoaded = true; |
| 2222 | } |
| 2223 | |
| 2224 | function selectedSourceValues(id) { |
| 2225 | return Array.from($(id).querySelectorAll("input:checked")).map((input) => input.value); |
| 2226 | } |
| 2227 | |
| 2228 | function selectedSettingTagValues(id) { |
| 2229 | return Array.from($(id)?.querySelectorAll("span") || []) |
| 2230 | .map((item) => item.textContent.trim()) |
| 2231 | .filter((value) => value && ![i18n.zh.common.notConfigured, i18n.en.common.notConfigured, i18n.zh.settings.placeholderMissing, i18n.en.settings.placeholderMissing].includes(value)); |
| 2232 | } |
| 2233 | |
| 2234 | function syncChoiceListFromSettings(id, values, enabled = true, options = {}) { |
| 2235 | const target = $(id); |
| 2236 | if (!target) return; |
| 2237 | const configured = new Set(splitListValue(values)); |
| 2238 | const inputs = Array.from(target.querySelectorAll("input[type='checkbox']")); |
| 2239 | const defaultChecked = options.defaultChecked || "none"; |
| 2240 | const useConfigured = options.useConfigured !== false; |
| 2241 | inputs.forEach((input, index) => { |
| 2242 | if (useConfigured && configured.size) { |