forked from bishopZ/Frame.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
90 lines (69 loc) · 2.08 KB
/
example.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
<html>
<head>
<script type="text/javascript" src="frame.debug.js"></script>
</head>
<body>
<h2>Hello! Check the console!</h2>
<script>
Frame.debug = 4;
// Library loader examples
Frame('http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', function(next){
// set Frame.debug = 3 or higher to see titles in console
$('body').append('<p>jQuery loaded callback</p>');
next();
});
// Queue function examples
Frame(800, function(next){
Frame.title('Frame.soon with delay');
next();
});
Frame.later(800, function(next){
Frame.title('Frame.later with delay');
next();
});
Frame.later(function(){
Frame.log("what happens if you dont call the callback? (function times out)");
Frame.log("set Frame.debug = 2 or higher to see errors in the console");
$('body').append('<p>And later, more stuff happens</p>');
});
Frame.now(function(next){
Frame.title('Frame.NOW!');
next();
});
Frame(function(next){
Frame.title('Function started');
setTimeout(function(){
Frame.title('Function finished');
next();
}, 1600);
});
// Variable passing examples
Frame(function(callback, context){
Frame.title('Example of passing in variables');
Frame.log('variables can be passed to a Frame when created');
Frame.log('context should be this');
Frame.log(context);
callback('foo');
}, this);
Frame(function(callback, someValue){
Frame.log('variables can also be passed through the callback');
Frame.log('someValue should equal foo');
Frame.log(someValue);
callback('waterfall value 1', 'waterfall value 2');
});
Frame(function(callback){ // both waterfall and context args received
Frame.log('when both are used, the arguments are concatinated');
Frame.log(Array.prototype.splice.call(arguments, 1));
callback();
}, 'context value 1', 'context value 2');
// report on script execution speeds, in debug version only
Frame.later(function(){
Frame.report();
Frame();
});
// some tricks
// ...
Frame.start(); // same as Frame.init()
</script>
</body>
</html>