-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathalert-box.js
41 lines (31 loc) · 961 Bytes
/
alert-box.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Author: Suraj Aswal
'use strict';
const containerBox = document.querySelector('body');
let classAd;
let alertBtn;
const customAlert = (msg, allowCss, className) => {
const alertBox = document.createElement('div');
containerBox.appendChild(alertBox);
alertBox.innerText = msg;
classAd = alertBox.classList;
classAd.add('custom-alert-box');
customCss(allowCss, className);
const hideAlertBox = function () {
alertBox.remove();
};
setTimeout(hideAlertBox, 2000);
};
const customCss = (permission, className) => {
if (permission == 'allow') {
classAd.add(className);
classAd.remove('custom-alert-box');
}
};
const alertOnClick = function (idName, msg1, allowCss, className) {
alertBtn = document.querySelector('#' + idName);
alertBtn.addEventListener('click', function () {
customAlert(msg1);
customCss(allowCss, className);
// console.log(customCss);
});
};