Новый способ отображения уведомлений.

This commit is contained in:
lopar 2021-03-10 23:06:07 +02:00
parent fec3857435
commit 9046670081
1 changed files with 36 additions and 0 deletions

View File

@ -1,3 +1,39 @@
function hrefToFrame(link) {
top.frames['gameframe'].location = link
}
/**
* Отображаем уведомление на 5 секунд.
* @top Отступ сверху.
* @right Отступ справа.
* @className Тип уведомления.
* @html Текст уведомления в HTML формате.
*/
function showNotification({top = 0, right = 0, className, html}) {
let notification = document.createElement('div');
notification.style.cssText = `
position: fixed;
z-index: 1000;
padding: 5px;
border: 1px solid black;
font-size: 20px;
background: white;
text-align: center;
`;
if (className === "danger") {
notification.style.cssText += `
background: #b80000;
color: yellow;
`;
}
notification.style.top = top + 'px';
notification.style.right = right + 'px';
notification.innerHTML = html;
document.body.append(notification);
setTimeout(() => notification.remove(), 5000);
}