Page MenuHomeSealhub

notifications.ts
No OneTemporary

notifications.ts

import * as shared from "./shared";
const notifications = document.getElementById("notifications")!;
function create_notification(notification: {
is_ok: boolean;
message: string;
context: string;
}): HTMLElement {
const el = document.createElement("div");
el.addEventListener("click", (_) => {
el.remove();
});
el.classList.add("notification");
if (notification.is_ok) el.classList.add("notification_ok");
else el.classList.add("notification_err");
// el.innerText = notification.message;
el.innerHTML = `
<div><b>${notification.context}</b></div>
<div>
${notification.message
.split("\n")
.map((line) => `<p>${line}</p>`)
.join("")}
</div>`;
return el;
}
export function start_notifications() {
shared.socket.on("notification", (data) => {
let el = create_notification(data);
notifications.appendChild(el);
// a 10 sec timeout
setTimeout(() => {
el.remove();
}, 10000);
});
}

File Metadata

Mime Type
text/x-java
Expires
Sat, Nov 8, 12:02 (21 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1034554
Default Alt Text
notifications.ts (922 B)

Event Timeline