-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
64 lines (50 loc) · 1.38 KB
/
demo.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
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
</head>
<body>
<button class="btn-start">start!</button>
<button class="btn-clear">clear!</button>
<script src="job_queue.min.js"></script>
<script>
var test_queue = new job_queue();
test_queue.init($('body'), 'test');
$(document).ready(function(){
test_queue.reg_first(function(){
$('body').append('<div>first</div>');
});
test_queue.reg_last(function(){
$('body').append('<div>last</div>');
});
for(var i =0; i < 5; i++) {
test_queue.reg(function(){ // <---dont't add any function paramater
$('body').append('<div>no.' + test_queue.number() + '</div>');
if(1==2) {
alert('error');
//stop & clear
test_queue.clear();
}
//next
test_queue.next();
});
}
for(var i =0; i < 5; i++) {
test_queue.reg(function(){
$('body').append('<div>no.' + test_queue.number() + '</div>');
});
}
$('.btn-start').click(function(){
//start & restart
test_queue.next();
});
$('.btn-clear').click(function(){
$('div').remove();
//stop & clear
test_queue.clear();
});
});
</script>
</body>
</html>