|
19 | 19 | import {ThemeController} from '../app/theme-controller.js';
|
20 | 20 | import {Application} from '../application.js';
|
21 | 21 | import {getAllPermissions, hasRequiredPermissionsForOptions} from '../data/permissions-util.js';
|
22 |
| -import {querySelectorNotNull} from '../dom/query-selector.js'; |
23 | 22 | import {HotkeyHelpController} from '../input/hotkey-help-controller.js';
|
24 | 23 |
|
25 | 24 | class DisplayController {
|
@@ -67,9 +66,11 @@ class DisplayController {
|
67 | 66 | this._setupOptions(primaryProfile);
|
68 | 67 | }
|
69 | 68 |
|
70 |
| - /** @type {HTMLElement} */ |
71 |
| - const profileSelect = querySelectorNotNull(document, '.action-select-profile'); |
72 |
| - profileSelect.hidden = (profiles.length <= 1); |
| 69 | + /** @type {NodeListOf<HTMLElement>} */ |
| 70 | + const profileSelect = document.querySelectorAll('.action-select-profile'); |
| 71 | + for (let i = 0; i < profileSelect.length; i++) { |
| 72 | + profileSelect[i].hidden = (profiles.length <= 1); |
| 73 | + } |
73 | 74 |
|
74 | 75 | this._updateProfileSelect(profiles, profileCurrent);
|
75 | 76 |
|
@@ -231,23 +232,25 @@ class DisplayController {
|
231 | 232 | * @param {number} profileCurrent
|
232 | 233 | */
|
233 | 234 | _updateProfileSelect(profiles, profileCurrent) {
|
234 |
| - /** @type {HTMLSelectElement} */ |
235 |
| - const select = querySelectorNotNull(document, '#profile-select'); |
236 |
| - /** @type {HTMLElement} */ |
237 |
| - const optionGroup = querySelectorNotNull(document, '#profile-select-option-group'); |
238 |
| - const fragment = document.createDocumentFragment(); |
239 |
| - for (let i = 0, ii = profiles.length; i < ii; ++i) { |
240 |
| - const {name} = profiles[i]; |
241 |
| - const option = document.createElement('option'); |
242 |
| - option.textContent = name; |
243 |
| - option.value = `${i}`; |
244 |
| - fragment.appendChild(option); |
245 |
| - } |
246 |
| - optionGroup.textContent = ''; |
247 |
| - optionGroup.appendChild(fragment); |
248 |
| - select.value = `${profileCurrent}`; |
| 235 | + /** @type {NodeListOf<HTMLSelectElement>} */ |
| 236 | + const selects = document.querySelectorAll('.profile-select'); |
| 237 | + /** @type {NodeListOf<HTMLElement>} */ |
| 238 | + const optionGroups = document.querySelectorAll('.profile-select-option-group'); |
| 239 | + for (let i = 0; i < Math.min(selects.length, optionGroups.length); i++) { |
| 240 | + const fragment = document.createDocumentFragment(); |
| 241 | + for (let j = 0, jj = profiles.length; j < jj; ++j) { |
| 242 | + const {name} = profiles[j]; |
| 243 | + const option = document.createElement('option'); |
| 244 | + option.textContent = name; |
| 245 | + option.value = `${j}`; |
| 246 | + fragment.appendChild(option); |
| 247 | + } |
| 248 | + optionGroups[i].textContent = ''; |
| 249 | + optionGroups[i].appendChild(fragment); |
| 250 | + selects[i].value = `${profileCurrent}`; |
249 | 251 |
|
250 |
| - select.addEventListener('change', this._onProfileSelectChange.bind(this), false); |
| 252 | + selects[i].addEventListener('change', this._onProfileSelectChange.bind(this), false); |
| 253 | + } |
251 | 254 | }
|
252 | 255 |
|
253 | 256 | /**
|
|
0 commit comments