(title, id, options, defaultOption)
| 4387 | |
| 4388 | // TODO - Why is this duplicated? |
| 4389 | const addToMenu = (title, id, options, defaultOption) => { |
| 4390 | const span = this.createElement("span"); |
| 4391 | span.innerText = title; |
| 4392 | |
| 4393 | const current = this.createElement("div"); |
| 4394 | current.innerText = ""; |
| 4395 | current.classList.add("ejs_settings_main_bar_selected"); |
| 4396 | span.appendChild(current); |
| 4397 | |
| 4398 | const menu = this.createElement("div"); |
| 4399 | menus.push(menu); |
| 4400 | menu.setAttribute("hidden", ""); |
| 4401 | menu.classList.add("ejs_parent_option_div"); |
| 4402 | const button = this.createElement("button"); |
| 4403 | const goToHome = () => { |
| 4404 | const homeSize = this.getElementSize(home); |
| 4405 | nested.style.width = (homeSize.width + 20) + "px"; |
| 4406 | nested.style.height = homeSize.height + "px"; |
| 4407 | menu.setAttribute("hidden", ""); |
| 4408 | home.removeAttribute("hidden"); |
| 4409 | } |
| 4410 | this.addEventListener(button, "click", goToHome); |
| 4411 | |
| 4412 | button.type = "button"; |
| 4413 | button.classList.add("ejs_back_button"); |
| 4414 | menu.appendChild(button); |
| 4415 | const pageTitle = this.createElement("span"); |
| 4416 | pageTitle.innerText = title; |
| 4417 | pageTitle.classList.add("ejs_menu_text_a"); |
| 4418 | button.appendChild(pageTitle); |
| 4419 | |
| 4420 | const optionsMenu = this.createElement("div"); |
| 4421 | optionsMenu.classList.add("ejs_setting_menu"); |
| 4422 | |
| 4423 | let buttons = []; |
| 4424 | let opts = options; |
| 4425 | if (Array.isArray(options)) { |
| 4426 | opts = {}; |
| 4427 | for (let i = 0; i < options.length; i++) { |
| 4428 | opts[options[i]] = options[i]; |
| 4429 | } |
| 4430 | } |
| 4431 | allOpts[id] = opts; |
| 4432 | |
| 4433 | funcs.push((title) => { |
| 4434 | if (id !== title) return; |
| 4435 | for (let j = 0; j < buttons.length; j++) { |
| 4436 | buttons[j].classList.toggle("ejs_option_row_selected", buttons[j].getAttribute("ejs_value") === this.disks[id]); |
| 4437 | } |
| 4438 | this.menuOptionChanged(id, this.disks[id]); |
| 4439 | current.innerText = opts[this.disks[id]]; |
| 4440 | }); |
| 4441 | |
| 4442 | for (const opt in opts) { |
| 4443 | const optionButton = this.createElement("button"); |
| 4444 | buttons.push(optionButton); |
| 4445 | optionButton.setAttribute("ejs_value", opt); |
| 4446 | optionButton.type = "button"; |
nothing calls this directly
no test coverage detected