-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
166 lines (151 loc) · 4.37 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
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<!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="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/yeti/bootstrap.min.css">
<link rel="stylesheet" href="dist/zeronet-notifications.min.css">
<style>
body {
margin: 0;
padding: 0;
height: 100%;
background-color: #D2CECD;
overflow: hidden
}
a {
color: black
}
.inner {
margin-left: 32px;
}
.outer {
margin-left: 64px;
position: fixed;
top: 64px;
left: 64px;
}
@media(max-width:425px) {
.outer {
top: 4px;
left: 4px;
margin-left: 4px;
}
.inner {
margin-left: 8px;
}
}
</style>
</head>
<body>
<!-- Notifications -->
<div class="notifications">
</div>
<!-- Content -->
<div class="outer">
<h1>ZeroNet Notifications</h1>
<p>Nice and simple notifications, extracted from the ZeroNet Source Code</p>
<br>
<div class="inner">
<h2><a href="https://github.com/mkg20001/ZeroNetNotifications">» Source on GitHub</a></h2>
<h3><a href="https://github.com/HelloZeroNet/ZeroNet/tree/master/src/Ui/media">» Original Code from ZeroNet</a></h3>
</div>
</div>
</body>
<script src="dist/zeronet-notifications.all.min.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)
})
}
/* function prompt3() {
n.add(id(), "confirm", "Visit GitHub Page?", 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", "Loading...", 3000);
setTimeout(function() {
window.location.href = "https://github.com/mkg20001/ZeroNetNotifications"
}, 2000)
} else n.add(id(), "error", "Canceled", 3000)
}
setTimeout(prompt3, 3000)
})
} */
setTimeout(prompt1, (i + 1) * m)
setTimeout(prompt2, (i + 2) * m)
// setTimeout(prompt3, (i + 3) * m)
</script>
</html>