nose-pluto/src/js/statusbar.ts

27 lines
574 B
TypeScript

////
// Temporarily display a message to the user in the status bar.
import { $ } from "./dom"
const STATUS_MSG_LENGTH = 3000
const statusbar = $("statusbar") as HTMLDivElement
const statusbarMsg = $("statusbar-msg") as HTMLSpanElement
let timer: NodeJS.Timeout
export function status(msg: string) {
showStatusMsg()
statusbarMsg.textContent = msg
if (timer) clearTimeout(timer)
timer = setTimeout(hideStatusMsg, STATUS_MSG_LENGTH)
}
function showStatusMsg() {
statusbar.classList.add("showing-msg")
}
function hideStatusMsg() {
statusbar.className = ""
}