replace menu items if already present
This commit is contained in:
parent
fafaabb6e7
commit
4069e87872
@ -280,9 +280,11 @@ export class MenuScene extends Phaser.Scene {
|
|||||||
|
|
||||||
public addMenuOption(menuText: string) {
|
public addMenuOption(menuText: string) {
|
||||||
const wrappingSection = document.createElement("section")
|
const wrappingSection = document.createElement("section")
|
||||||
wrappingSection.innerHTML = `<button class="fromApi" id="${HtmlUtils.escapeHtml(menuText)}">${HtmlUtils.escapeHtml(menuText)}</button>`
|
const excapedHtml = HtmlUtils.escapeHtml(menuText);
|
||||||
|
wrappingSection.innerHTML = `<button class="fromApi" id="${excapedHtml}">${excapedHtml}</button>`
|
||||||
const menuItemContainer = this.menuElement.node.querySelector("#gameMenu main");
|
const menuItemContainer = this.menuElement.node.querySelector("#gameMenu main");
|
||||||
if (menuItemContainer) {
|
if (menuItemContainer) {
|
||||||
|
menuItemContainer.querySelector(`#${excapedHtml}.fromApi`)?.remove()
|
||||||
menuItemContainer.insertBefore(wrappingSection, menuItemContainer.querySelector("#socialLinks"))
|
menuItemContainer.insertBefore(wrappingSection, menuItemContainer.querySelector("#socialLinks"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user