1/**
2 @template-title StratifiedJS test
3 @template-show-busy-indicator
4 @template-external-script ./bundle.js
5*/
6
7// Shows the builtin conductance loading bar while all
8// modules are loaded in parallel
9withBusyIndicator {||
10 @ = require([
11 'sjs:sequence',
12 'mho:surface',
13 'mho:app',
14 './util', './ui',
15 ]);
16}
17
18@withFakeNetwork {||
19 @mainContent .. @appendContent(@Div()) {|storyDiv|
20 @mainContent .. @appendContent(@spinnerElem) {||
21 try {
22 var story = @getJSON('story.json');
23 storyDiv .. @appendHTML(story.heading);
24 story.chapterUrls ..
25 @transform.par(@getJSON) ..
26 @each {|chapter|
27 storyDiv .. @appendHTML(chapter.html);
28 };
29 storyDiv .. @appendContent("All done");
30 } catch(err) {
31 // catch any error that happened along the way
32 storyDiv .. @appendContent("Argh, broken: " + err.message);
33 }
34 }
35 // When this block ends, `storyDiv` will be automatically removed
36 // from the document. We pause indefinitely with `hold()` so the block
37 // only ends if it is aborted.
38 hold();
39 }
40}
41