()
| 81 | ] |
| 82 | |
| 83 | async function initSettings() { |
| 84 | SETTINGS_IDS_LIST.forEach((id) => { |
| 85 | var element = document.getElementById(id) |
| 86 | if (!element) { |
| 87 | console.error(`Missing settings element ${id}`) |
| 88 | } |
| 89 | if (id in SETTINGS) { |
| 90 | // don't create it again |
| 91 | return |
| 92 | } |
| 93 | SETTINGS[id] = { |
| 94 | key: id, |
| 95 | element: element, |
| 96 | label: getSettingLabel(element), |
| 97 | default: getSetting(element), |
| 98 | value: getSetting(element), |
| 99 | ignore: IGNORE_BY_DEFAULT.includes(id), |
| 100 | } |
| 101 | element.addEventListener("input", settingChangeHandler) |
| 102 | element.addEventListener("change", settingChangeHandler) |
| 103 | }) |
| 104 | var unsorted_settings_ids = [...SETTINGS_IDS_LIST] |
| 105 | SETTINGS_SECTIONS.forEach((section) => { |
| 106 | var name = section.name |
| 107 | var element = document.getElementById(section.id) |
| 108 | var unsorted_ids = unsorted_settings_ids.map((id) => `#${id}`).join(",") |
| 109 | var children = unsorted_ids == "" ? [] : Array.from(element.querySelectorAll(unsorted_ids)) |
| 110 | section.keys = [] |
| 111 | children.forEach((e) => { |
| 112 | section.keys.push(e.id) |
| 113 | }) |
| 114 | unsorted_settings_ids = unsorted_settings_ids.filter((id) => children.find((e) => e.id == id) == undefined) |
| 115 | }) |
| 116 | loadSettings() |
| 117 | } |
| 118 | |
| 119 | function getSetting(element) { |
| 120 | if (element.dataset && "path" in element.dataset) { |
nothing calls this directly
no test coverage detected