diff --git a/js/main.js b/js/main.js index 2906a53..8dca01b 100644 --- a/js/main.js +++ b/js/main.js @@ -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); } \ No newline at end of file