From b91dd249590571c57e9bf9dcac2478df50267e1e Mon Sep 17 00:00:00 2001 From: Jared Date: Fri, 22 Jan 2021 04:11:05 -0800 Subject: [PATCH] Add AppendChild helper. --- Server/wwwroot/src/Main/App.ts | 3 ++- Server/wwwroot/src/Shared/UI.ts | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Server/wwwroot/src/Main/App.ts b/Server/wwwroot/src/Main/App.ts index bf90154e..1180a2fc 100644 --- a/Server/wwwroot/src/Main/App.ts +++ b/Server/wwwroot/src/Main/App.ts @@ -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; diff --git a/Server/wwwroot/src/Shared/UI.ts b/Server/wwwroot/src/Shared/UI.ts index e9ea783d..066b1162 100644 --- a/Server/wwwroot/src/Shared/UI.ts +++ b/Server/wwwroot/src/Shared/UI.ts @@ -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");