Add AppendChild helper.

This commit is contained in:
Jared 2021-01-22 04:11:05 -08:00 committed by Jared Goodwin
parent cbe3447e70
commit b91dd24959
2 changed files with 9 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import { UserSettings } from "./UserSettings.js";
import { ApplyInputEventHandlers } from "./InputEventHandlers.js";
import { Sound } from "../Shared/Sound.js";
import * as Console from "./Console.js";
import { AppendChild } from "../Shared/UI.js";
export const MainApp = {
Commands: {
@ -35,7 +36,7 @@ export const MainApp = {
return;
}
UI.MotdAlert.innerHTML += content;
AppendChild(UI.MotdAlert, content, "span");
UI.MotdAlert.removeAttribute("hidden");
UI.MotdAlert.querySelector("button").addEventListener("click", () => {
localStorage["remotely-motd"] = content;

View File

@ -2,6 +2,13 @@
export var ToastsWrapper = document.getElementById("toastsWrapper") as HTMLDivElement;
export function AppendChild(parentElement: HTMLElement, childContent: string, childTag: string) {
var childElement = document.createElement(childTag);
childElement.innerText = childContent;
parentElement.appendChild(childElement);
}
export function ShowMessage(message: string) {
var messageDiv = document.createElement("div");
messageDiv.classList.add("toast-message");