-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
58 lines (54 loc) · 1.82 KB
/
index.html
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Destinations</title>
<link rel="stylesheet" href="static/css/style.css">
<!-- Scripts -->
<script src="./scripts/app.js" type="module" defer></script>
</head>
<body>
<!-- Notifications -->
<div>
<div class="notification loadingBox">
Loading …
</div>
<div class="notification infoBox">
Info
</div>
<div class="notification errorBox">
Error: destination name can't be empty!
</div>
</div>
<div id="container">
<div id="root"></div>
<!-- Footer -->
<footer>@SoftUni Destinations 2020</footer>
</div>
<script>
function notify(message, type = 'notification loadingBox') {
let notificationElement;
console.log(notificationElement)
switch (type) {
case 'notification infoBox':
notificationElement = document.getElementsByClassName('notification infoBox')[0];
break;
case 'notification errorBox':
notificationElement = document.getElementsByClassName('notification errorBox')[0];
break;
case 'notification loadingBox':
notificationElement = document.getElementsByClassName('notification loadingBox')[0];
break;
}
notificationElement.innerText = message;
notificationElement.style.display = 'block';
setTimeout(() => {
notificationElement.style.display = 'none';
}, 3000);
notificationElement.addEventListener("click", (e) => {
notificationElement.style.display = 'none';
})
}
</script>
</body>
</html>