-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdev.html
117 lines (107 loc) · 3.06 KB
/
dev.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!doctype html>
<html>
<head>
<title>ZeroNetNotifications | Try it!</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="dist/zeronet-notifications.css">
<style>
body {
margin: 0;
padding: 0;
height: 100%;
background-color: #D2CECD;
overflow: hidden
}
body.back {
background-color: #090909
}
a {
color: black
}
</style>
</head>
<body>
<!-- Notifications -->
<div class="notifications">
</div>
</body>
<script src="node_modules/jquery/dist/jquery.js"></script>
<script src="node_modules/jquery.easing/jquery.easing.js"></script>
<script src="dist/zeronet-notifications.js"></script>
<script>
const n = new Notifications($(".notifications"))
var i = 0
const m = 500
function id() {
return "msg" + (i++)
}
function delay(b, c, d) {
const a = id()
setTimeout(n.add.bind(n), i * m, a, b, c, d)
return a
}
delay("done", "Success notification", 0)
delay("error", "Error notification", 0)
delay("info", "Info notification", 0)
delay("ask", "Ask notification", 0)
var p = 0
var p2 = 0
var pid = id()
setTimeout(function() {
var msg = n.add(pid, "progress", "Progress notification (___)", 3000)
const intv = setInterval(function() {
msg.setBody("Progress notification (" + p + "/10)").setProgress(p * 10)
if (p == 10) {
clearInterval(intv)
}
p++
}, 1000)
}, i * m)
var pid2 = id()
setTimeout(function() {
var msg2 = n.add(pid2, "progress", "Failing progress notification (___)", 3000)
const intv2 = setInterval(function() {
if (p2 == 5) {
clearInterval(intv2)
p2 = -1
}
msg2.setBody("Failing progress notification (" + p2 + "/5)").setProgress(p2 * 10)
p2++
}, 1000)
}, i * m)
delay("info", "Auto closing notification", 5000)
function prompt1() {
n.add(id(), "prompt", "Type something", 0, {
cancel_label: "Cancel",
confirm_label: "Ok"
}, function(event, res) {
if (event == "auto" || event == "user" || typeof res == "boolean") {
n.add(id(), "error", "You " + (event == "user" ? "closed" : "canceled") + " the message", 3000)
} else {
n.add(id(), res ? "done" : "error", res ? ("You typed: " + res) : "You typed, nothing!", 3000)
}
setTimeout(prompt1, 3000)
})
}
function prompt2() {
n.add(id(), "confirm", "Restart demo?", 0, {
cancel_label: "Cancel",
confirm_label: "Ok"
}, function(event, res) {
if (event == "auto" || event == "user") {
n.add(id(), "error", "You closed the message", 3000)
} else {
if (res) {
n.add(id(), "info", "Reloading...", 3000);
setTimeout(window.location.reload.bind(window.location), 2000)
} else n.add(id(), "error", "Canceled", 3000)
}
setTimeout(prompt2, 3000)
})
}
setTimeout(prompt1, (i + 1) * m)
setTimeout(prompt2, (i + 2) * m)
</script>
</html>