Change how the demo page is populated (use launcher script.)
Chris Pressey
5 years ago
0 | function launch(prefix, container, config) { | |
1 | if (typeof container === 'string') { | |
2 | container = document.getElementById(container); | |
3 | } | |
4 | config = config || {}; | |
5 | ||
6 | function loadThese(deps, callback) { | |
7 | var loaded = 0; | |
8 | for (var i = 0; i < deps.length; i++) { | |
9 | var elem = document.createElement('script'); | |
10 | elem.src = prefix + deps[i]; | |
11 | elem.onload = function() { | |
12 | if (++loaded < deps.length) return; | |
13 | callback(); | |
14 | } | |
15 | document.body.appendChild(elem); | |
16 | } | |
17 | } | |
18 | ||
19 | loadThese([ | |
20 | "lexeduct-transformers.js", | |
21 | "yoob/element-factory.js", | |
22 | "lexeduct-browser.js" | |
23 | ], function() { | |
24 | var initialText = "" + | |
25 | "A thing of beauty is a joy for ever:\n" + | |
26 | "Its loveliness increases; it will never\n" + | |
27 | "Pass into nothingness; but still will keep\n" + | |
28 | "A bower quiet for us, and a sleep\n" + | |
29 | "Full of sweet dreams, and health, and quiet breathing.\n" + | |
30 | "Therefore, on every morrow, are we wreathing\n" + | |
31 | "A flowery band to bind us to the earth,\n" + | |
32 | "Spite of despondence, of the inhuman dearth\n" + | |
33 | "Of noble natures, of the gloomy days,\n" + | |
34 | "Of all the unhealthy and o'er-darkened ways\n" + | |
35 | "Made for our searching: yes, in spite of all,\n" + | |
36 | "Some shape of beauty moves away the pall\n" + | |
37 | "From our dark spirits. Such the sun, the moon,\n" + | |
38 | "Trees old and young, sprouting a shady boon\n" + | |
39 | "For simple sheep; and such are daffodils\n" + | |
40 | "With the green world they live in; and clear rills\n" + | |
41 | "That for themselves a cooling covert make\n" + | |
42 | "'Gainst the hot season; the mid forest brake,\n" + | |
43 | "Rich with a sprinkling of fair musk-rose blooms:\n" + | |
44 | "And such too is the grandeur of the dooms\n" + | |
45 | "We have imagined for the mighty dead;\n" + | |
46 | "All lovely tales that we have heard or read:\n" + | |
47 | "An endless fountain of immortal drink,\n" + | |
48 | "Pouring unto us from the heaven's brink.\n"; | |
49 | ||
50 | (new LexeductUI()).init({ | |
51 | container: container, | |
52 | initialText: initialText, | |
53 | liveMode: true | |
54 | }); | |
55 | }); | |
56 | } |
6 | 6 | |
7 | 7 | <header> |
8 | 8 | <h1>Lexeduct</h1> |
9 | <p> | |
10 | <i>If the page is blank and says <code>lexeduct-transformers.js</code> can't be loaded, | |
11 | you need to run <code>make.sh</code>.</i> | |
12 | </p> | |
9 | 13 | </header> |
10 | 14 | |
11 | 15 | <div id="container"></div> |
12 | 16 | |
13 | <pre style="display: none;" id="initial-text"> | |
14 | A thing of beauty is a joy for ever: | |
15 | Its loveliness increases; it will never | |
16 | Pass into nothingness; but still will keep | |
17 | A bower quiet for us, and a sleep | |
18 | Full of sweet dreams, and health, and quiet breathing. | |
19 | Therefore, on every morrow, are we wreathing | |
20 | A flowery band to bind us to the earth, | |
21 | Spite of despondence, of the inhuman dearth | |
22 | Of noble natures, of the gloomy days, | |
23 | Of all the unhealthy and o'er-darkened ways | |
24 | Made for our searching: yes, in spite of all, | |
25 | Some shape of beauty moves away the pall | |
26 | From our dark spirits. Such the sun, the moon, | |
27 | Trees old and young, sprouting a shady boon | |
28 | For simple sheep; and such are daffodils | |
29 | With the green world they live in; and clear rills | |
30 | That for themselves a cooling covert make | |
31 | 'Gainst the hot season; the mid forest brake, | |
32 | Rich with a sprinkling of fair musk-rose blooms: | |
33 | And such too is the grandeur of the dooms | |
34 | We have imagined for the mighty dead; | |
35 | All lovely tales that we have heard or read: | |
36 | An endless fountain of immortal drink, | |
37 | Pouring unto us from the heaven's brink. | |
38 | </pre> | |
39 | ||
40 | 17 | </body> |
41 | <script src="lexeduct-transformers.js"></script> | |
42 | <script src="yoob/element-factory.js"></script> | |
43 | <script src="lexeduct-browser.js"></script> | |
18 | <script src="launch-lexeduct.js"></script> | |
44 | 19 | <script> |
45 | (new LexeductUI()).init({ | |
46 | container: document.getElementById('container'), | |
47 | initialText: document.getElementById('initial-text').innerHTML, | |
48 | liveMode: true | |
49 | }); | |
20 | launch("", "container"); | |
50 | 21 | </script> |