509196785b
- Create new class to manager global message. My idea is that this class permit to manage audio or text message. - Update html to have main content id and inject html in this. - Create front event to receive startMessage and stopMessage. - Delete impoted variable not used.
21 lines
728 B
TypeScript
21 lines
728 B
TypeScript
export class HtmlUtils {
|
|
public static getElementByIdOrFail<T extends HTMLElement>(id: string): T {
|
|
const elem = document.getElementById(id);
|
|
if (elem === null) {
|
|
throw new Error("Cannot find HTML element with id '"+id+"'");
|
|
}
|
|
// FIXME: does not check the type of the returned type
|
|
return elem as T;
|
|
}
|
|
|
|
public static removeElementByIdOrFail<T extends HTMLElement>(id: string): T {
|
|
const elem = document.getElementById(id);
|
|
if (elem === null) {
|
|
throw new Error("Cannot find HTML element with id '"+id+"'");
|
|
}
|
|
// FIXME: does not check the type of the returned type
|
|
elem.remove();
|
|
return elem as T;
|
|
}
|
|
}
|