-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
53 lines (47 loc) · 1.53 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- add you own logo here ! -->
<!-- <link rel="icon" type="image" href="music.png" /> -->
<link rel="stylesheet" href="style.css" />
<title>Notification</title>
</head>
<body>
<div class="buttons">
<button onclick="showToast(successMsg)">Success</button>
<button onclick="showToast(errorMsg)">Error</button>
<button onclick="showToast(invalidMsg)">Invalid</button>
</div>
<div id="toastbox"></div>
<script
src="https://kit.fontawesome.com/9bf23ddcb3.js"
crossorigin="anonymous"
></script>
<script>
let toastBox = document.getElementById("toastbox");
let successMsg =
" <i class='fa-solid fa-badge-check'></i> Successfully submitted";
let errorMsg =
"<i class='fa-sharp fa-solid fa-circle-exclamation'></i> Please fix the error !";
let invalidMsg =
" <i class='fa-solid fa-circle-xmark'></i> Invalid message!! ";
function showToast(msg) {
let toast = document.createElement("div");
toast.classList.add("toast");
toast.innerHTML = msg;
toastBox.appendChild(toast);
if (msg.includes("error")) {
toast.classList.add("error");
}
if (msg.includes("Invalid")) {
toast.classList.add("Invalid");
}
setTimeout(() => {
toast.remove();
}, 6000);
}
</script>
</body>
</html>