1
0
mirror of https://github.com/lus/pasty.git synced 2023-08-10 21:13:09 +03:00
pasty/web/assets/js/notifications.js
Lukas Schulte Pelkum 90f25ec220
Improve the web frontend (#9)
* 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
2021-06-20 15:58:36 +02:00

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);
}