mirror of
https://github.com/lus/pasty.git
synced 2023-08-10 21:13:09 +03:00
90f25ec220
* Fix line flowing out of div * Revert line highlighting * Fix tab key behaviour * Move links and version information to a footer * Fix footer hiding last code line * Calculate line number offset based on line overflow * Refactor some code
22 lines
623 B
JavaScript
22 lines
623 B
JavaScript
// element holds the notification containers DOM element
|
|
const element = document.getElementById("notifications");
|
|
|
|
// error shows an error notifications
|
|
export function error(message) {
|
|
create("error", message, 3000);
|
|
}
|
|
|
|
// success shows a success notifications
|
|
export function success(message) {
|
|
create("success", message, 3000);
|
|
}
|
|
|
|
// create creates a new notification
|
|
function create(type, message, duration) {
|
|
const node = document.createElement("div");
|
|
node.classList.add(type);
|
|
node.innerHTML = message;
|
|
|
|
element.appendChild(node);
|
|
setTimeout(() => element.removeChild(node), duration);
|
|
} |