forked from cujojs/curl
/
cycle-correction-hybrid.html
65 lines (51 loc) · 1.11 KB
/
cycle-correction-hybrid.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
<!DOCTYPE HTML>
<html>
<head>
<title>cycle correction for hybrid modules</title>
<script>
curl = {
debug: true,
paths: {
curl: '../src/curl',
loop: 'support/commonjs/loop'
}
};
</script>
<script src="../src/curl.js" type="text/javascript"></script>
<script type="text/javascript">
// doing .next to isolate the domReady resolution from the other modules
curl(['domReady!']).next(['loop/hybrid-loop1']).then(
function (loop1) {
// test add, subtract, and multiple
try {
loop1.add(1, 2);
loop1.subtract(1, 2);
loop1.multiply(1, 2);
success();
}
catch (ex) {
fail(ex);
}
},
fail
);
// fail if we haven't succeeded in 3 seconds. note: this is janky
var timeout = setTimeout(fail, 3000);
function success () {
clearTimeout(timeout);
write('SUCCESS: cycle corrected');
}
function fail (ex) {
clearTimeout(timeout);
write('FAILED: ' + (ex ? ex.message : 'timed out'));
}
function write (msg) {
curl('domReady!', function () {
document.body.appendChild(document.createElement('div')).innerHTML = msg;
});
}
</script>
</head>
<body>
</body>
</html>