From 904667008170ea84af4cbefc579279b5db09f45e Mon Sep 17 00:00:00 2001 From: lopar Date: Wed, 10 Mar 2021 23:06:07 +0200 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=BE=D0=B2=D1=8B=D0=B9=20=D1=81=D0=BF?= =?UTF-8?q?=D0=BE=D1=81=D0=BE=D0=B1=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=83=D0=B2=D0=B5=D0=B4=D0=BE?= =?UTF-8?q?=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/main.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) 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