-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtests.html
263 lines (138 loc) · 4.93 KB
/
tests.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<!DOCTYPE html>
<html>
<head>
<title>JSAlert tests</title>
<script src='dist/jsalert.min.js'></script>
<style>
.button {
display: inline-block;
margin: 10px;
padding: 10px 20px;
border: 1px solid #08F;
border-radius: 4px;
color: #08F;
cursor: pointer;
font-family: Helvetica Neue, Helvetica, Arial;
font-size: 15px;
font-weight: bold;
}
</style>
</head>
<body>
<!-- Header -->
<h1>JSAlert tests</h1>
<!-- Test categories -->
<h2>Displaying alerts</h2>
<div id='test01' class='button'>Simple alert</div>
<script>
// Display a simple alert
document.querySelector("#test01").addEventListener("click", function() {
JSAlert.alert("Hello from JSAlert version " + JSAlert.version + "!");
});
</script>
<div id='test02' class='button'>Alert with title</div>
<script>
// Display an alert with a custom title
document.querySelector("#test02").addEventListener("click", function() {
JSAlert.alert("The content goes here.", "My custom alert title");
});
</script>
<div id='test03' class='button'>Queued alerts</div>
<script>
// Display 3 alerts in a row. Alerts are automatically queued.
document.querySelector("#test03").addEventListener("click", function() {
JSAlert.alert("This is the first alert.");
JSAlert.alert("This is the second alert.");
JSAlert.alert("This is the third and final alert.");
});
</script>
<div id='test04' class='button'>Confirm alert</div>
<script>
// Display a confirm alert
document.querySelector("#test04").addEventListener("click", function() {
JSAlert.confirm("Are you sure you want to delete this file?").then(function(result) {
// Check if pressed yes
if (!result)
return;
// User pressed yes!
JSAlert.alert("File deleted!");
});
});
</script>
<div id='test05' class='button'>Prompt</div>
<script>
// Display a confirm alert
document.querySelector("#test05").addEventListener("click", function() {
JSAlert.prompt("Enter your name:", "John Smith").then(function(result) {
// Check if successful
if (!result)
return;
// User entered their name
JSAlert.alert("Hello <b>" + result + "</b>!");
});
});
</script>
<div id='test06' class='button'>Loader</div>
<script>
// Display a loader overlay
document.querySelector("#test06").addEventListener("click", function() {
JSAlert.loader("Please wait...").dismissIn(2000);
});
</script>
<!-- Test categories -->
<h2>Events</h2>
<div id='test-events01' class='button'>Dismiss event</div>
<script>
// Listen for the event.
document.querySelector("#test-events01").addEventListener("click", function() {
JSAlert.alert("This alert has an event listener!").then(function() {
document.querySelector("#test-events01").innerText = "Alert dismissed!";
});
});
</script>
<!-- Test categories -->
<h2>Icons</h2>
<div id='test-icons01' class='button'>Information icon</div>
<script>
// Show with icon
document.querySelector("#test-icons01").addEventListener("click", function() {
JSAlert.alert("<code>JSAlert.Icons.Information</code>", null, JSAlert.Icons.Information);
});
</script>
<div id='test-icons02' class='button'>Warning icon</div>
<script>
// Show with icon
document.querySelector("#test-icons02").addEventListener("click", function() {
JSAlert.alert("<code>JSAlert.Icons.Warning</code>", null, JSAlert.Icons.Warning);
});
</script>
<div id='test-icons03' class='button'>Question icon</div>
<script>
// Show with icon
document.querySelector("#test-icons03").addEventListener("click", function() {
JSAlert.alert("<code>JSAlert.Icons.Question</code>", null, JSAlert.Icons.Question);
});
</script>
<div id='test-icons04' class='button'>Success icon</div>
<script>
// Show with icon
document.querySelector("#test-icons04").addEventListener("click", function() {
JSAlert.alert("<code>JSAlert.Icons.Success</code>", null, JSAlert.Icons.Success);
});
</script>
<div id='test-icons05' class='button'>Failed icon</div>
<script>
// Show with icon
document.querySelector("#test-icons05").addEventListener("click", function() {
JSAlert.alert("<code>JSAlert.Icons.Failed</code>", null, JSAlert.Icons.Failed);
});
</script>
<div id='test-icons06' class='button'>Deleted icon</div>
<script>
// Show with icon
document.querySelector("#test-icons06").addEventListener("click", function() {
JSAlert.alert("<code>JSAlert.Icons.Deleted</code>", null, JSAlert.Icons.Deleted);
});
</script>
</body>
</html>